Simulate a spatial beta random variable with a specific mean and covariance structure.
Usage
sprbeta(
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 beta random variable.
Examples
spcov_params_val <- spcov_params("exponential", de = 0.2, ie = 0.1, range = 1)
sprbeta(spcov_params_val, data = caribou, xcoord = x, ycoord = y)
#> [1] 0.05978670 0.95126057 0.07057026 0.36632930 0.90359435 0.13881493
#> [7] 0.34909613 0.02995588 0.23990902 0.58547407 0.03147747 0.94308815
#> [13] 0.58846837 0.01175391 0.12576057 0.99993991 0.64791853 0.78341448
#> [19] 0.24783729 0.01160805 0.69107090 0.30751840 0.24645671 0.47340799
#> [25] 0.24134403 0.79293742 0.46548023 0.98837206 0.57042907 0.93855070
sprbeta(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.093176209 0.007523947 0.8609063701 0.4427733018 0.0001980756
#> [2,] 0.974532680 0.091895925 0.2134198774 0.0447781776 0.1575990786
#> [3,] 0.931337743 0.399287758 0.9017696088 0.0009843637 0.8626576087
#> [4,] 0.022169398 0.459171809 0.9991964431 0.1967562732 0.9989868371
#> [5,] 0.719558813 0.662574171 0.9224842679 0.0849879397 0.4741002841
#> [6,] 0.037888063 0.984969789 0.7668424547 0.2413206722 0.0052402675
#> [7,] 0.765330440 0.915672592 0.9999000000 0.6089034126 0.1211268728
#> [8,] 0.010271835 0.948251696 0.9264256601 0.2549196205 0.4638325422
#> [9,] 0.871180077 0.340503845 0.5882159000 0.5209320840 0.5171820295
#> [10,] 0.994171048 0.855536838 0.0336828745 0.1806492642 0.3916788909
#> [11,] 0.814941756 0.769755743 0.0166521089 0.3190989048 0.7931871223
#> [12,] 0.999900000 0.908138605 0.9918873887 0.0256620880 0.0001000000
#> [13,] 0.002727135 0.008665640 0.5515522339 0.6149095603 0.2276884013
#> [14,] 0.575293119 0.764235030 0.8800792219 0.7479022219 0.0389900774
#> [15,] 0.619202775 0.655958326 0.2555876280 0.3866657423 0.5300097429
#> [16,] 0.018051909 0.853745054 0.5804006829 0.1997137448 0.1391051625
#> [17,] 0.990478080 0.001183336 0.9074015149 0.9894557858 0.5633435298
#> [18,] 0.014209015 0.971435436 0.0092389894 0.4583434236 0.2862562676
#> [19,] 0.087403727 0.425863006 0.2433159072 0.5843460346 0.4055156784
#> [20,] 0.398247354 0.205361507 0.8109834743 0.7714763753 0.0005205123
#> [21,] 0.833176887 0.250520264 0.0659641970 0.0163931212 0.4343727457
#> [22,] 0.214054992 0.973184428 0.0011127723 0.8272135918 0.3512310945
#> [23,] 0.576089810 0.529687783 0.3147302953 0.3185523297 0.0927090430
#> [24,] 0.589656278 0.690046256 0.9729940595 0.2539433347 0.7872442269
#> [25,] 0.894747369 0.046846449 0.0010901081 0.0056100588 0.9189562762
#> [26,] 0.299064552 0.157101387 0.0003867956 0.1983074808 0.7829296560
#> [27,] 0.013442258 0.013232949 0.6141590750 0.7353648995 0.8511758470
#> [28,] 0.493913069 0.915715392 0.0024869390 0.4498898497 0.9224820044
#> [29,] 0.117590608 0.967016423 0.1862031942 0.9240646469 0.0343413478
#> [30,] 0.415301197 0.937249459 0.9371240746 0.1828049750 0.5910659189