Simulate a spatial Poisson random variable with a specific mean and covariance structure.
Arguments
- spcov_params
An
spcov_params()
object.- 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 Poisson random variable.
Examples
spcov_params_val <- spcov_params("exponential", de = 0.2, ie = 0.1, range = 1)
sprpois(spcov_params_val, data = caribou, xcoord = x, ycoord = y)
#> [1] 2 1 3 2 1 2 1 1 1 0 1 3 1 1 0 0 1 2 4 0 2 1 4 2 0 3 0 1 0 0
sprpois(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 2 0 5 0 1
#> [2,] 3 0 0 1 2
#> [3,] 0 1 3 2 1
#> [4,] 5 0 1 1 4
#> [5,] 2 0 0 0 1
#> [6,] 1 1 1 2 0
#> [7,] 1 0 0 0 0
#> [8,] 2 1 0 2 1
#> [9,] 0 0 0 2 0
#> [10,] 0 1 0 1 3
#> [11,] 1 0 3 0 1
#> [12,] 2 2 1 0 1
#> [13,] 1 0 1 2 0
#> [14,] 3 3 1 0 2
#> [15,] 0 0 0 0 2
#> [16,] 0 0 0 2 0
#> [17,] 3 0 5 2 4
#> [18,] 1 0 3 2 2
#> [19,] 1 1 0 0 1
#> [20,] 1 2 1 2 0
#> [21,] 1 0 2 2 2
#> [22,] 0 2 0 1 3
#> [23,] 2 1 2 3 0
#> [24,] 2 0 2 1 0
#> [25,] 0 0 1 0 1
#> [26,] 0 6 3 1 0
#> [27,] 4 0 2 3 2
#> [28,] 0 1 0 1 2
#> [29,] 2 2 3 1 2
#> [30,] 1 2 2 2 0