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.5972237577 0.5717516298 0.7067034289 0.9793263485 0.0689665833
#> [6] 0.4020768734 0.2126082741 0.6778406046 0.5558414094 0.2828495136
#> [11] 0.9624706441 0.0001464704 0.0054936606 0.9913812960 0.9874624211
#> [16] 0.1708645487 0.9964911107 0.9915069499 0.9525202050 0.6572286741
#> [21] 0.3561587782 0.9953839698 0.4114760013 0.9270936390 0.9934742047
#> [26] 0.9632895323 0.7300334498 0.2492351766 0.1143444967 0.0165279088
sprbeta(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.3363276540 0.5380292421 0.037850824 0.0547193107 0.6094845968
#> [2,] 0.1715807437 0.0014409101 0.178567148 0.0123605325 0.8773820792
#> [3,] 0.1818415098 0.2522258513 0.355964796 0.7590015453 0.0001000000
#> [4,] 0.5311454006 0.0005587743 0.999900000 0.0807249900 0.9990223641
#> [5,] 0.6988736224 0.6827314518 0.046019126 0.3162246081 0.7669795129
#> [6,] 0.4682493674 0.5642536979 0.356504125 0.3892144361 0.6889722029
#> [7,] 0.9912680200 0.7769964678 0.718107524 0.3727885204 0.9982085386
#> [8,] 0.9998574878 0.4673249233 0.160469587 0.9386312950 0.1542036442
#> [9,] 0.0006328515 0.8735652690 0.643334810 0.0209971615 0.5204702966
#> [10,] 0.8076310911 0.0492485636 0.807376002 0.3284441807 0.3245619094
#> [11,] 0.1586730039 0.8530423194 0.246800038 0.0022606464 0.0301199179
#> [12,] 0.4003536613 0.2980127136 0.212687661 0.1600159298 0.3093429737
#> [13,] 0.7886667621 0.3978248529 0.992619957 0.0491375917 0.9961873489
#> [14,] 0.1186137908 0.4338621888 0.414085085 0.0798639831 0.0736114995
#> [15,] 0.2832589799 0.9630869632 0.092071749 0.8403800313 0.8131399717
#> [16,] 0.5197159280 0.8462936554 0.956655959 0.6576361648 0.5896654427
#> [17,] 0.9133863817 0.0366981451 0.998806868 0.0005094947 0.2609905716
#> [18,] 0.3177259293 0.3182056683 0.302079280 0.6570948389 0.0008498096
#> [19,] 0.2955569837 0.5484349420 0.863110806 0.2011212815 0.8336454346
#> [20,] 0.9971052900 0.9997829896 0.323608327 0.9995401080 0.8367890165
#> [21,] 0.1242075177 0.7745882667 0.480711163 0.8876750661 0.9774668657
#> [22,] 0.0056729243 0.0579844487 0.880229565 0.9972021742 0.9999000000
#> [23,] 0.0106071347 0.3205836336 0.735818296 0.9997783389 0.0737569580
#> [24,] 0.3835294136 0.0002973145 0.264102592 0.9505038473 0.5572475131
#> [25,] 0.0568942651 0.8600161759 0.927886789 0.9761314107 0.3047613726
#> [26,] 0.6760913567 0.6825291305 0.074145320 0.9943589174 0.9309072394
#> [27,] 0.7842018793 0.2925869545 0.867168463 0.7721184574 0.6213363481
#> [28,] 0.0003692215 0.0237966008 0.592239699 0.9993273898 0.4254402045
#> [29,] 0.0262090766 0.3998933449 0.223527134 0.1938133637 0.8791600009
#> [30,] 0.9779810837 0.6118784691 0.002783679 0.2749838660 0.0001000000