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.6098832935 0.2319233028 0.8446487959 0.2012419052 0.3407456061
#> [6] 0.0094299570 0.0008819568 0.3024664519 0.8774116192 0.5841066136
#> [11] 0.0013810238 0.8621489637 0.5619070044 0.7548612767 0.8599529845
#> [16] 0.9962531387 0.9465050300 0.9730672056 0.7315465635 0.7528213814
#> [21] 0.2520560963 0.9808160956 0.9511781516 0.2528352297 0.9917248031
#> [26] 0.6272087699 0.1195794664 0.9613689635 0.5663484562 0.7807947007
sprbeta(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.5117176635 0.787902058 0.023432073 0.981816759 0.0266706062
#> [2,] 0.3256514955 0.750120960 0.411833145 0.497844656 0.1462673681
#> [3,] 0.9999000000 0.747272236 0.254029508 0.998755297 0.3702175439
#> [4,] 0.6695256202 0.020259511 0.534504235 0.200765178 0.6643469457
#> [5,] 0.6149208016 0.561566809 0.086000853 0.904582176 0.8159108941
#> [6,] 0.6931828281 0.009504268 0.329327189 0.957080097 0.9984695627
#> [7,] 0.0655657938 0.161902432 0.252403476 0.943403170 0.9410168605
#> [8,] 0.8027046078 0.014002757 0.824114297 0.118323168 0.1177266368
#> [9,] 0.4950471202 0.018126064 0.937929896 0.388043211 0.8978584205
#> [10,] 0.8388372536 0.956540672 0.212286340 0.594143619 0.1913192969
#> [11,] 0.0046983733 0.958671889 0.433719710 0.003939458 0.4435101545
#> [12,] 0.0009361869 0.018554959 0.975134864 0.487622717 0.0310474314
#> [13,] 0.2599949300 0.999347197 0.818774041 0.204384484 0.9968644260
#> [14,] 0.2551429491 0.280489799 0.893220596 0.322253705 0.5578092879
#> [15,] 0.9997726980 0.012226510 0.542149465 0.009802293 0.7237848152
#> [16,] 0.9815546760 0.213399354 0.088057997 0.653000409 0.0272070729
#> [17,] 0.7901747934 0.796012775 0.024339935 0.999896120 0.0036207903
#> [18,] 0.0021626659 0.997075628 0.367192022 0.513450826 0.2136623039
#> [19,] 0.1800284853 0.460892251 0.799878159 0.985290083 0.7244576436
#> [20,] 0.5770749772 0.178255331 0.565573901 0.503341750 0.0869657073
#> [21,] 0.7011395859 0.994346303 0.003386809 0.747755053 0.9987036887
#> [22,] 0.4491753834 0.986145448 0.916944296 0.929287663 0.0106194556
#> [23,] 0.6950388947 0.999900000 0.398781669 0.540894135 0.9947896497
#> [24,] 0.0043001770 0.296222375 0.789444261 0.027058701 0.9939292594
#> [25,] 0.4711133678 0.846616101 0.077311150 0.010937060 0.0134204025
#> [26,] 0.0365144917 0.140404269 0.338172307 0.999900000 0.8246745193
#> [27,] 0.4278834814 0.137730281 0.001074721 0.019576377 0.0868735466
#> [28,] 0.1267242244 0.657190001 0.481731242 0.028780725 0.0005389538
#> [29,] 0.0102639925 0.055584210 0.854495962 0.814888249 0.6332044776
#> [30,] 0.0525474696 0.979851581 0.438924600 0.102356180 0.9791378959