Simulate a spatial inverse gaussian random variable with a specific mean and covariance structure.
Usage
sprinvgauss(
spcov_params,
dispersion = 1,
mean = 0,
samples = 1,
data,
randcov_params,
partition_factor,
...
)
Arguments
- spcov_params
An
spcov_params()
object.- dispersion
The dispersion value.
- mean
A numeric vector representing the mean.
mean
must have length 1 (in which case it is recycled) or length equal to the number of rows indata
. The default is0
.- samples
The number of independent samples to generate. The default is
1
.- data
A data frame or
sf
object containing spatial information.- randcov_params
A
randcov_params()
object.- partition_factor
A formula indicating the partition factor.
- ...
Additional arguments passed to
sprnorm()
.
Value
If samples
is 1, a vector of random variables for each row of data
is returned. If samples
is greater than one, a matrix of random variables
is returned, where the rows correspond to each row of data
and the columns
correspond to independent samples.
Details
The values of spcov_params
, mean
, and randcov_params
are assumed to be on the link scale. They are used to simulate a latent normal (Gaussian)
response variable using sprnorm()
. This latent variable is the
conditional mean used with dispersion
to simulate a inverse gaussian random variable.
Examples
spcov_params_val <- spcov_params("exponential", de = 0.2, ie = 0.1, range = 1)
sprinvgauss(spcov_params_val, data = caribou, xcoord = x, ycoord = y)
#> [1] 1.2534963 1.8852705 1.6990904 0.2424917 1.1197950 1.0623844 1.5881868
#> [8] 0.3155117 0.2542643 0.1230621 2.7272764 0.3808098 1.7052962 0.2614825
#> [15] 0.1316975 1.3728684 1.1496338 0.1277504 8.0841319 1.3945683 0.4426084
#> [22] 0.2493617 3.3286051 2.8245883 1.5357637 0.4829636 0.8590400 6.8663751
#> [29] 0.7809411 0.3760825
sprinvgauss(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 4.3051309 0.4002684 0.4111202 4.08983615 1.64168190
#> [2,] 16.6152515 2.9278268 0.8290295 0.14009609 0.25954927
#> [3,] 1.7748620 0.2673919 0.8986413 0.93156251 0.89086119
#> [4,] 1.5885107 0.7356586 1.8335793 2.74351916 0.61603889
#> [5,] 0.7680410 4.4033629 0.6944953 0.33118581 0.26802394
#> [6,] 0.1894717 0.7593578 0.7290757 0.19277742 1.73285575
#> [7,] 1.6991797 1.4206243 0.2715626 5.31402803 0.81167694
#> [8,] 0.6417420 0.1007103 0.8001581 0.14019652 2.36555315
#> [9,] 14.5618078 3.2652316 0.4047866 1.20825766 0.27071961
#> [10,] 0.4790183 1.9159671 0.4726914 0.55115830 0.34978368
#> [11,] 1.8871173 0.6491061 0.4032595 0.12717264 0.05307062
#> [12,] 0.8426527 4.3534258 0.1455735 0.19981985 0.40526904
#> [13,] 2.5862033 0.7670476 0.2664029 0.57840630 0.51157729
#> [14,] 1.5724068 0.1921909 0.5471144 1.14319101 1.18996388
#> [15,] 0.9035831 0.5509831 1.6166197 0.30744615 1.17741938
#> [16,] 0.3825540 0.4352411 0.4729082 0.49579240 0.57194269
#> [17,] 0.4075483 1.2070400 6.5149321 1.10603000 0.29461214
#> [18,] 0.6592167 0.6145927 0.5105872 0.42573364 1.80653687
#> [19,] 1.0997091 0.9464847 0.8681295 0.69711062 0.45177454
#> [20,] 0.3443833 2.2024652 1.2741554 0.07899849 4.77677927
#> [21,] 3.6570166 1.2424276 0.3538784 1.92590999 0.08027962
#> [22,] 2.1684785 1.2908146 0.6479463 0.80403588 0.92592795
#> [23,] 2.8760705 2.8673863 0.4918806 2.34713387 2.08892350
#> [24,] 0.5355007 0.1898943 0.2829576 1.04622827 3.85029630
#> [25,] 0.5560211 1.6851165 0.1054868 0.38844213 3.84699121
#> [26,] 0.1741231 2.1203776 0.9664836 1.04412932 1.77066563
#> [27,] 1.4049974 0.1905883 2.3619618 2.82475244 0.28899985
#> [28,] 0.1590180 0.2461962 1.5990540 1.17954072 1.31317641
#> [29,] 2.9532807 0.6812748 0.4453301 1.83513504 1.81103084
#> [30,] 0.4608798 0.4648403 0.2183787 0.52567511 0.47665144