Simulate a spatial gamma random variable with a specific mean and covariance structure.
sprgamma(
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 gamma random variable.
spcov_params_val <- spcov_params("exponential", de = 0.2, ie = 0.1, range = 1)
sprgamma(spcov_params_val, data = caribou, xcoord = x, ycoord = y)
#> [1] 0.75280447 0.38594517 3.65978446 1.95807057 1.65274919 1.25209439
#> [7] 0.03943941 3.11983258 0.84666827 0.29061374 1.51102930 0.19039697
#> [13] 0.67176796 1.39945414 0.82289422 0.42245213 0.64567331 1.06746015
#> [19] 3.30860468 0.50481614 0.64595885 0.02451031 0.22405899 0.06002885
#> [25] 0.16554357 0.04184807 0.33747198 0.61130810 1.22320369 0.43600759
sprgamma(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 1.01160006 0.76768002 0.7146641 1.19692535 0.37906964
#> [2,] 1.16150090 0.02699926 0.8945328 0.16169799 0.78611375
#> [3,] 3.96866661 0.18970004 0.5400695 0.62948241 1.12062116
#> [4,] 1.35188653 9.37625082 0.1336606 0.29015804 0.22347443
#> [5,] 4.17563139 1.64834705 0.4339255 0.11702445 0.87745582
#> [6,] 0.23147224 1.16491348 0.5223104 0.39070655 0.73756924
#> [7,] 1.47769653 1.72124453 3.4877920 3.07198132 0.16274737
#> [8,] 3.97394865 0.11112337 5.8638050 0.29272855 0.89341586
#> [9,] 0.97679781 2.77875196 0.1657846 1.62061743 0.21738573
#> [10,] 1.09826786 0.91814099 0.2435776 1.23684664 0.94554324
#> [11,] 0.46880580 0.14036372 1.0937906 0.24638476 0.07953849
#> [12,] 0.94183728 0.63347394 2.3471394 0.28712331 0.02541582
#> [13,] 0.62512279 1.07764049 1.6698897 0.07345519 1.07166132
#> [14,] 1.09141752 0.63971546 0.4111601 1.48828898 0.14491959
#> [15,] 4.50736005 4.01070453 1.2277185 0.59501756 1.19238386
#> [16,] 0.32336355 0.10766847 1.9484982 0.49317266 0.61397317
#> [17,] 0.24005798 2.21499830 1.4055560 1.11490925 0.10558722
#> [18,] 0.36399426 1.17176556 2.4605372 0.76474288 2.82892057
#> [19,] 3.74301935 0.30036465 1.3835480 1.08032389 0.26777267
#> [20,] 0.43688672 2.15599572 1.2003288 0.17384957 2.25756906
#> [21,] 0.01092240 0.63291578 0.4788034 1.38771640 1.48309401
#> [22,] 0.31875788 1.07820428 1.0445484 0.94069500 1.56552447
#> [23,] 0.01156632 0.47951011 0.1752193 2.41377704 0.16262056
#> [24,] 0.34452728 0.36167865 1.2233904 0.16707112 3.16395959
#> [25,] 0.61885066 0.47271573 1.2862121 1.53926220 0.68826229
#> [26,] 5.58493023 0.96207878 0.3455525 0.60596376 6.06407935
#> [27,] 0.21694470 1.98896297 3.7823486 0.48705370 0.19653064
#> [28,] 0.17201868 1.52065932 1.1446676 0.05084512 2.77270149
#> [29,] 1.19292624 0.48022934 1.2521601 1.66135129 3.70636043
#> [30,] 2.40672184 0.35430804 0.8776703 2.10433002 0.69159080