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] 0.4207435 0.8533214 0.2859779 0.4762297 6.1262449 1.4156841 1.5051686
#> [8] 0.9538068 0.5496691 0.3410388 0.6410030 0.7567253 0.2934669 0.4878489
#> [15] 0.4767287 0.7955248 0.1501103 0.6613469 0.3620646 0.2191450 3.4435467
#> [22] 0.5456843 0.6722380 1.8707435 1.0112860 2.1591179 0.5705515 0.2617513
#> [29] 1.3891783 0.6637879
sprinvgauss(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 1.02164082 0.46185343 0.5177241 0.47405950 0.38859891
#> [2,] 0.22509503 0.26596970 1.0482205 0.93094120 1.30648447
#> [3,] 2.35333576 1.66543827 0.9960295 1.31082719 0.59935277
#> [4,] 0.46391983 0.47710394 0.9633077 0.14816358 2.69377508
#> [5,] 0.66484101 1.73918691 2.4197094 0.56825644 1.08115149
#> [6,] 2.02631159 0.17666438 0.1154068 1.31921870 0.08195667
#> [7,] 0.51274572 0.36076097 0.1694624 0.52927104 0.93111125
#> [8,] 0.16337708 0.45890371 0.1082550 1.32012981 0.26970876
#> [9,] 0.07022525 0.29488480 0.2021009 0.47947007 0.32462432
#> [10,] 2.70209908 0.46591263 0.8245193 1.99131820 0.85424977
#> [11,] 1.41828734 0.32531231 0.4662664 1.14174915 0.95468985
#> [12,] 0.54184093 0.49779877 0.2535843 0.74313414 4.90361218
#> [13,] 0.58923101 0.91157507 0.6083902 0.56585513 0.82942163
#> [14,] 0.15173213 0.59048767 1.7858689 0.54187278 0.45678555
#> [15,] 0.79442915 2.10123680 3.4430502 0.12497483 5.21225599
#> [16,] 1.04161613 0.09216654 0.2192895 0.03698559 1.28022580
#> [17,] 0.35974793 1.43836282 1.7691188 0.95983191 0.09501384
#> [18,] 1.88974547 1.73348644 0.2045394 1.04606319 0.08497635
#> [19,] 2.68831592 4.48624737 5.8301683 1.30859231 1.24602352
#> [20,] 0.75223010 0.12086001 0.1054593 2.94774646 4.62973287
#> [21,] 1.35559249 0.64711521 1.1134819 0.14054328 2.94434887
#> [22,] 6.32251726 0.33522364 0.3867091 0.59312641 0.68806043
#> [23,] 1.80334976 4.23317214 0.4169324 1.70665552 0.87775995
#> [24,] 4.93760331 1.15711376 2.4383709 1.17532570 0.50935727
#> [25,] 1.67446498 1.62959924 1.1228281 0.40638667 1.85100110
#> [26,] 0.45987012 3.16002484 0.7502684 0.46765100 2.08569246
#> [27,] 8.88002815 1.42993479 1.1511051 0.35652112 1.64211362
#> [28,] 1.03782194 0.18958868 6.0510341 0.79521281 2.74707094
#> [29,] 2.68793352 1.87884132 0.8625188 0.78497848 0.68545575
#> [30,] 0.88555909 0.27488441 0.2018894 1.72069945 1.55611643