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] 0.31337100 0.35054569 0.45555846 0.18479627 1.01337100 1.26421259
#> [7] 0.13446259 0.19112957 1.15683673 1.44384399 1.21671157 0.39358481
#> [13] 1.15136107 0.55078795 0.66825042 0.49582730 4.67956916 1.54022141
#> [19] 0.86652727 5.20845634 0.27378645 0.70241617 2.64407135 1.01923042
#> [25] 0.43781280 2.64681892 0.08317767 3.31507330 0.91980916 0.30480869
sprinvgauss(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.2928724 1.62760922 1.7306824 0.7964395 0.10101838
#> [2,] 0.3814784 3.99253724 3.4823379 0.7895395 0.73326693
#> [3,] 0.2995096 0.23001560 3.3232419 0.1679869 0.35000956
#> [4,] 0.6864891 0.39817836 0.7198420 0.1382186 0.85766424
#> [5,] 0.2201954 0.08149575 0.5235901 1.1562626 0.60924447
#> [6,] 2.1458276 0.64906886 1.8142420 0.3079570 1.25166982
#> [7,] 0.2782308 0.47237147 0.6010998 0.3787816 0.31284773
#> [8,] 0.6820220 0.72337986 0.2635743 2.7913652 0.84451676
#> [9,] 2.2531626 0.39863201 0.3056949 0.1182387 0.75606602
#> [10,] 0.4996917 0.32458217 0.3301244 1.3563068 1.07352679
#> [11,] 0.9780925 0.13138173 0.4381009 0.0673376 0.20337705
#> [12,] 0.7432823 0.34887274 0.2048909 0.8338060 1.59807243
#> [13,] 0.1036056 0.22258653 0.2937321 0.2823789 0.29156621
#> [14,] 1.3568158 0.75713411 0.7857529 1.2721137 0.87099313
#> [15,] 2.0368291 0.45659654 0.3966132 0.3468156 0.39292478
#> [16,] 0.2528136 1.78315504 1.0677227 0.2900662 1.66665912
#> [17,] 0.2250491 2.72335396 0.4880108 0.3220477 0.25581274
#> [18,] 0.1295438 1.32238009 0.4510756 0.3661254 0.38197728
#> [19,] 1.2382916 1.02911059 0.3289995 1.1527523 0.42777467
#> [20,] 0.5253946 4.67349167 2.0551485 1.5529662 1.48065769
#> [21,] 0.5856168 0.11432242 0.8468649 0.1412205 0.26134859
#> [22,] 0.1540007 1.47946401 0.8121099 0.4254326 4.07140562
#> [23,] 0.8981684 0.33460729 0.3602134 0.6230396 2.38133491
#> [24,] 3.8199796 0.30239461 0.3890802 2.3687138 0.50082606
#> [25,] 2.3351310 1.59961748 1.0919097 0.6269160 0.22315414
#> [26,] 0.1928919 0.94224052 0.5721922 1.0429535 0.07237572
#> [27,] 0.9710496 0.71664368 0.6412171 0.8596243 0.23428481
#> [28,] 0.8500447 0.91854837 0.2416670 1.5305144 0.23250256
#> [29,] 2.0365330 0.53756358 1.0156360 0.3295350 0.10370211
#> [30,] 2.2741576 0.56273421 0.2869297 0.7377279 0.84535298