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.1485946 0.8010817 0.7265742 0.2452224 0.2797832 1.3859905 1.5912075
#> [8] 0.1651390 1.6588474 2.7138778 1.1951131 0.4982750 1.2804863 0.6121312
#> [15] 3.8098501 0.2701678 0.7169791 2.4447328 0.1680631 0.7180609 1.6144222
#> [22] 1.3163777 0.1287815 0.4760385 0.5364609 0.9546622 1.1552338 0.2031314
#> [29] 0.5252252 0.1528608
sprinvgauss(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 1.4516100 0.9364866 1.1125500 0.2919037 1.33570042
#> [2,] 0.4886443 0.4222069 2.0727051 0.6582940 1.08268100
#> [3,] 0.5294327 1.1571159 2.8861232 0.4988847 0.25784777
#> [4,] 0.7080498 0.5896975 0.3688691 0.1603751 0.09357553
#> [5,] 0.1322017 0.2607225 0.5892198 0.2233560 1.00169963
#> [6,] 0.1902988 0.9848220 0.8057711 1.0413005 2.80702421
#> [7,] 0.5389787 0.4590057 2.6765495 0.1313937 2.70370122
#> [8,] 0.7036179 0.5144100 1.2391460 0.5202858 0.27282829
#> [9,] 0.1570300 0.4371131 0.1233297 0.7006270 1.76984438
#> [10,] 1.5308836 1.5059862 2.7814915 1.0324497 0.37788958
#> [11,] 0.7310935 0.3730227 0.4102543 0.7097166 1.96192741
#> [12,] 2.6278824 0.5322208 1.4686491 1.1065469 0.23215664
#> [13,] 0.2122493 0.2532362 0.9110282 0.6895638 0.22917389
#> [14,] 2.6941681 1.8634511 1.7250094 0.6290500 0.28600489
#> [15,] 0.2503849 0.9622060 1.3687886 0.7487017 0.72252680
#> [16,] 0.7781355 0.1857550 0.8428252 0.6136945 4.55536982
#> [17,] 0.6404776 0.7244533 0.3089884 0.4158282 0.23801676
#> [18,] 2.4797404 0.9528518 0.1410591 0.7104054 0.25598817
#> [19,] 0.2887465 0.8532277 0.3825989 0.3782207 0.84185844
#> [20,] 2.2260643 0.2424950 1.0738033 2.7795787 3.67226106
#> [21,] 1.7214428 1.1637604 1.3590423 0.7359883 0.69465793
#> [22,] 0.4969987 1.7366107 1.0000836 0.4714949 0.06215611
#> [23,] 0.9031513 0.4173714 0.5332602 1.7304472 0.77394940
#> [24,] 0.4682711 0.7904163 0.1692009 1.0024523 0.70685058
#> [25,] 0.4577151 0.2429884 0.3521586 3.2579350 2.14803101
#> [26,] 0.7774874 0.4192960 0.1876836 0.6398956 0.45550476
#> [27,] 0.6739988 3.7043277 0.9437263 0.1808055 0.69647195
#> [28,] 2.1478802 2.0237366 2.0563698 2.0470568 0.89474793
#> [29,] 1.5078930 0.4587599 0.2112512 2.3293649 0.89804701
#> [30,] 1.8134279 1.7402841 1.3594810 0.2850804 0.19817701