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.768782853 0.915354189 0.643316016 0.495920249 0.531946314 0.949134603
#> [7] 0.008787926 0.926323195 0.825737928 0.998687147 0.488137775 0.187989633
#> [13] 0.490641464 0.979244761 0.998786844 0.940262917 0.482199457 0.195367857
#> [19] 0.550573704 0.094013780 0.175080646 0.803952877 0.409502364 0.171865978
#> [25] 0.033540333 0.892997761 0.430974062 0.173828388 0.937854046 0.130673383
sprbeta(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 0.799069282 0.9935655744 0.963605626 0.208206166 0.809968233
#> [2,] 0.902270141 0.7397491277 0.990600692 0.463017479 0.599103066
#> [3,] 0.191188372 0.9453687097 0.194498107 0.413220896 0.397114158
#> [4,] 0.084236318 0.0010811206 0.872602062 0.000100000 0.993534710
#> [5,] 0.272863426 0.0357125968 0.314039806 0.197544566 0.052288117
#> [6,] 0.002817475 0.0091834754 0.628330566 0.058970242 0.797636871
#> [7,] 0.080700824 0.8730629336 0.535839424 0.383031448 0.725746335
#> [8,] 0.979716629 0.9730929883 0.969846613 0.054645991 0.373224658
#> [9,] 0.261872858 0.2510257369 0.854502769 0.419794192 0.147887119
#> [10,] 0.719886528 0.0990438453 0.002291665 0.005901676 0.917416063
#> [11,] 0.959807555 0.8628186999 0.953323408 0.157957993 0.350987080
#> [12,] 0.000100000 0.2539916539 0.873590449 0.420964855 0.997146142
#> [13,] 0.042513447 0.0886404404 0.892619095 0.207875999 0.005821058
#> [14,] 0.487974759 0.9153501142 0.966353147 0.990768687 0.973624775
#> [15,] 0.144704886 0.8770171845 0.047634061 0.972876975 0.015527025
#> [16,] 0.342393385 0.9968755641 0.201426604 0.135602953 0.979600788
#> [17,] 0.300944290 0.1874457465 0.304199142 0.804285540 0.118891357
#> [18,] 0.004108458 0.2117850815 0.076208713 0.022493283 0.809703357
#> [19,] 0.191261012 0.3889502559 0.530826867 0.000100000 0.968888524
#> [20,] 0.164200001 0.6887668562 0.054514331 0.042203644 0.285879008
#> [21,] 0.696741778 0.0169622043 0.215972512 0.825983649 0.999900000
#> [22,] 0.075232230 0.0009583495 0.999900000 0.284797808 0.762601599
#> [23,] 0.061159304 0.0011153011 0.001296666 0.125557902 0.763955955
#> [24,] 0.007187760 0.0086006528 0.909021551 0.000173877 0.888330353
#> [25,] 0.388299706 0.7268216872 0.054789941 0.119583130 0.256267960
#> [26,] 0.000100000 0.4023802331 0.333929172 0.996191697 0.994159313
#> [27,] 0.906205428 0.1340897432 0.011115700 0.098977796 0.656104299
#> [28,] 0.347673971 0.2928170775 0.899624721 0.117148644 0.746637616
#> [29,] 0.291159376 0.0065403348 0.114834465 0.935665741 0.164555891
#> [30,] 0.750595278 0.0037432140 0.708397813 0.647281819 0.410745290