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.758797621 0.993424843 0.698451322 0.767154858 0.438785360 0.721832663
#> [7] 0.030527792 0.224446419 0.082182399 0.181147648 0.126086091 0.121949866
#> [13] 0.152347025 0.966373884 0.403763846 0.020978992 0.363867836 0.009692026
#> [19] 0.004200434 0.104236578 0.655255410 0.040216254 0.907114880 0.521074251
#> [25] 0.224248214 0.760111512 0.019972892 0.266854396 0.929845389 0.999713125
sprbeta(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.195846818 0.192776892 0.9997177857 0.0003666339 0.3356371793
#> [2,] 0.002217567 0.936483377 0.9980025385 0.9912781900 0.9688014304
#> [3,] 0.929488138 0.745147604 0.9513543433 0.3405199633 0.6523727195
#> [4,] 0.715314364 0.639679629 0.1308842944 0.0197343171 0.0031515637
#> [5,] 0.548083794 0.578754394 0.2230712236 0.2478585544 0.6826623848
#> [6,] 0.486498952 0.859284157 0.4197773592 0.9912792376 0.0183185055
#> [7,] 0.218078832 0.894230904 0.2563754703 0.3398601938 0.8080089956
#> [8,] 0.005419475 0.518994864 0.6182991733 0.9998455778 0.0930909399
#> [9,] 0.757668907 0.093225471 0.0001000000 0.4479709307 0.5213115418
#> [10,] 0.218276207 0.035137031 0.0001000000 0.0005260712 0.9999000000
#> [11,] 0.199904663 0.970856094 0.2507188500 0.7225909826 0.4978517659
#> [12,] 0.244775776 0.338234427 0.8106383189 0.9996449587 0.2198664860
#> [13,] 0.435839681 0.710183181 0.9726756272 0.5331619614 0.9287904683
#> [14,] 0.479573511 0.464156386 0.9820516417 0.0165364940 0.3473499503
#> [15,] 0.832296046 0.143299918 0.9998364432 0.5743590351 0.2610602781
#> [16,] 0.936418331 0.795209739 0.1341161475 0.7817743058 0.0001000000
#> [17,] 0.837595973 0.998902104 0.0001000000 0.1977310070 0.0707102661
#> [18,] 0.477074103 0.999900000 0.3508284966 0.2886917668 0.7180591013
#> [19,] 0.238235453 0.414117340 0.0002023248 0.5520203108 0.8320383803
#> [20,] 0.995506938 0.018598554 0.9875554456 0.4565783124 0.9999000000
#> [21,] 0.958168640 0.700471758 0.2209450423 0.4813394221 0.0351015828
#> [22,] 0.575859833 0.849706432 0.2659181115 0.9684352946 0.4548494477
#> [23,] 0.902615150 0.409677282 0.1483567169 0.3166778358 0.9049552552
#> [24,] 0.009493219 0.009086659 0.0015964106 0.9995569284 0.7455422674
#> [25,] 0.634100109 0.617519090 0.7041734785 0.7793812136 0.5461653859
#> [26,] 0.451163058 0.944993844 0.0102672318 0.0001000000 0.8589742799
#> [27,] 0.006346870 0.999900000 0.9431642401 0.3799500721 0.0002660449
#> [28,] 0.027098149 0.580407525 0.0024640432 0.8231765094 0.1208313321
#> [29,] 0.253447904 0.032860819 0.2000412113 0.2498957706 0.6536222942
#> [30,] 0.902827195 0.619644190 0.9952782954 0.9034793881 0.9799311259