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.63466955 1.86819505 0.37965730 1.93715093 0.50735984 0.71366615
#> [7] 1.50202124 0.17154250 0.11289267 0.17205271 0.48885566 0.55088781
#> [13] 0.02415598 3.11673298 0.10540601 3.34271829 0.00322566 3.51906538
#> [19] 1.33066757 1.31550604 5.99832194 0.12572999 0.07663319 0.77636779
#> [25] 0.10508181 1.07868656 2.93843123 0.18006874 2.07784038 0.28466737
sprgamma(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.45119382 0.326796548 2.955510491 0.01452339 0.827488703
#> [2,] 0.03979491 2.988184069 0.498211582 1.93780462 0.529258200
#> [3,] 0.33937962 0.538896554 0.705123031 1.18778134 0.980533419
#> [4,] 0.15046826 0.047089019 0.802435164 0.68353792 1.182174131
#> [5,] 0.19693599 0.006286109 0.060441951 0.54752584 0.157208587
#> [6,] 0.17107672 1.897085571 0.293160303 0.27022947 0.690448624
#> [7,] 0.80548071 0.259123038 0.186491804 0.51157872 0.409779984
#> [8,] 0.47559681 0.608765381 0.166360267 0.20360649 0.426814144
#> [9,] 3.25529337 0.275095898 0.527558233 0.95141136 0.291018500
#> [10,] 0.09210644 2.641012733 1.623455387 0.11084317 0.553233636
#> [11,] 1.20458402 2.897816788 1.859242536 2.32426040 0.279656249
#> [12,] 0.67586985 1.854910430 0.368657274 0.40803699 0.819622373
#> [13,] 0.43533199 0.064860362 0.003268068 0.66902773 0.898342989
#> [14,] 1.89612364 5.342964058 0.536924571 0.36212590 0.979216774
#> [15,] 0.63855403 0.866850387 0.666390171 1.62544167 0.258203967
#> [16,] 0.51984011 0.794301882 0.278538154 0.34514574 0.189613211
#> [17,] 0.51532279 3.141673067 0.732211426 0.20930137 0.295906211
#> [18,] 0.91307464 1.033784675 3.361028652 1.33489375 0.945414093
#> [19,] 0.27400309 0.065144135 0.166331228 0.20069451 0.004054188
#> [20,] 0.48797675 0.740326487 0.207445972 0.13845155 0.023162774
#> [21,] 0.49138277 0.766700938 0.719974077 2.27741305 0.190794398
#> [22,] 0.56795169 0.414781132 0.252459648 0.22744282 1.102866653
#> [23,] 1.76123487 0.629708575 2.458550491 0.19340488 1.245067412
#> [24,] 0.38776722 0.282901391 0.171852184 3.60331404 0.440751984
#> [25,] 0.51206121 0.210990853 0.339636535 0.10598679 0.221909771
#> [26,] 1.82155413 0.012208279 2.110066083 1.06472815 5.245208641
#> [27,] 4.30676691 2.365992214 0.061909849 0.32620547 1.673411125
#> [28,] 1.44669133 0.621506993 0.601437760 0.98799273 3.390611649
#> [29,] 1.11749189 1.920011768 0.373686495 1.44654899 0.037929643
#> [30,] 0.67833197 1.085107960 4.482832806 0.38939355 1.003534892