Simulate a spatial inverse gaussian random variable with a specific mean and covariance structure.
sprinvgauss(
spcov_params,
dispersion = 1,
mean = 0,
samples = 1,
data,
randcov_params,
partition_factor,
...
)
An spcov_params()
object.
The dispersion value.
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 in data
. The default is 0
.
The number of independent samples to generate. The default
is 1
.
A data frame or sf
object containing spatial information.
A randcov_params()
object.
A formula indicating the partition factor.
Additional arguments passed to sprnorm()
.
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.
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.
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] 2.29527151 3.42017655 0.26392787 1.81500823 1.15248489 0.42154704
#> [7] 0.56851168 0.96893835 0.39006233 0.97578811 0.46590499 1.25937157
#> [13] 0.92796729 0.22387811 1.62881399 1.42456882 0.53965477 0.22130707
#> [19] 1.64131833 0.16933350 0.62248858 2.67488082 0.63707453 0.37870944
#> [25] 0.25971596 0.41523593 0.48299128 0.06967475 0.86433751 0.91504695
sprinvgauss(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.90702198 0.12478166 5.17678684 3.8246364 0.24014591
#> [2,] 0.74990838 0.37713127 1.40714446 0.2049181 0.23260188
#> [3,] 0.13568819 0.09872632 0.26812237 1.0342868 0.31159586
#> [4,] 13.79049030 2.41638960 1.31160395 0.5346617 0.10785454
#> [5,] 0.17673935 0.52258663 0.85749331 0.4367147 0.82346956
#> [6,] 0.18325457 0.36587525 0.59718967 0.4895160 0.24979700
#> [7,] 1.05523847 0.62383793 0.34865687 0.7214000 0.18181517
#> [8,] 3.34316449 0.69953108 0.30689922 1.2350775 1.71730321
#> [9,] 4.53974216 0.62779339 5.60463915 0.3144129 2.24850014
#> [10,] 1.17362528 0.39001266 1.77595105 0.9879465 1.16348333
#> [11,] 0.57480769 0.49074157 0.25033458 1.9290429 0.15157354
#> [12,] 0.14220886 0.30955293 0.08492373 0.8024948 1.22702755
#> [13,] 0.03789491 0.08006891 0.51361351 0.5270878 0.70460296
#> [14,] 0.24070672 0.51731746 2.35131491 0.2092567 2.81573817
#> [15,] 0.42226525 0.56209333 8.75641016 0.7587990 1.66220667
#> [16,] 0.41172838 1.34011319 0.77193989 1.3456426 0.03972086
#> [17,] 0.07389561 0.27342752 4.33797623 1.5459361 0.29971181
#> [18,] 0.39798220 0.66284255 0.78725722 0.1934175 0.24243293
#> [19,] 0.29986267 0.59298921 1.67232998 1.4456993 0.64967047
#> [20,] 0.71000253 0.44869924 1.59906386 1.7142245 0.75320452
#> [21,] 1.56983078 1.28375325 0.16219949 0.3151651 0.40983853
#> [22,] 1.05421884 0.45740162 1.35163816 0.1963264 0.41892017
#> [23,] 0.64748823 2.10795879 0.39695548 0.4569626 1.51279067
#> [24,] 1.20232572 7.88639617 1.82371168 0.3385905 0.43286725
#> [25,] 0.74129734 3.79598023 1.98101116 0.3869401 0.36532360
#> [26,] 1.01680109 0.70565647 0.61094644 2.0223846 0.47120317
#> [27,] 0.49490524 1.23089353 0.78096321 3.1666603 0.81707950
#> [28,] 1.52462339 0.48893240 1.14640290 0.7062196 1.24399237
#> [29,] 0.52245283 6.41000414 0.46330554 0.3237940 1.23896506
#> [30,] 0.33402727 0.30682418 1.74957371 0.2246852 0.30006437