Simulate a spatial Poisson random variable with a specific mean and covariance structure.
sprpois(
spcov_params,
mean = 0,
samples = 1,
data,
randcov_params,
partition_factor,
...
)
An spcov_params()
object.
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 in data
. The default is 0
.
The number of independent samples to generate. The default
is 1
.
A data frame or sf
object containing spatial information.
A randcov_params()
object.
A formula indicating the partition factor.
Additional arguments passed to sprnorm()
.
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.
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.
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 0 5 1 3 0 3 4 1 1 0 0 3 3 0 0 1 0 0 3 1 3 1 1 1 4 2 0 1 0
sprpois(spcov_params_val, samples = 5, data = caribou, xcoord = x, ycoord = y)
#> 1 2 3 4 5
#> [1,] 3 1 1 0 0
#> [2,] 0 0 0 1 0
#> [3,] 0 1 1 1 2
#> [4,] 2 0 1 1 2
#> [5,] 2 0 3 0 2
#> [6,] 1 0 0 3 0
#> [7,] 1 1 1 1 3
#> [8,] 2 1 3 0 1
#> [9,] 0 2 3 0 0
#> [10,] 0 2 0 1 2
#> [11,] 0 2 1 3 1
#> [12,] 1 1 0 1 2
#> [13,] 0 1 0 1 0
#> [14,] 3 4 2 0 0
#> [15,] 3 0 3 2 7
#> [16,] 2 1 0 2 1
#> [17,] 0 2 0 0 3
#> [18,] 1 1 0 2 1
#> [19,] 2 1 1 5 2
#> [20,] 0 3 1 1 3
#> [21,] 1 4 1 0 1
#> [22,] 1 0 0 2 3
#> [23,] 1 0 1 1 0
#> [24,] 0 1 4 1 1
#> [25,] 2 4 3 0 1
#> [26,] 0 1 2 3 3
#> [27,] 1 2 1 2 0
#> [28,] 2 2 1 1 0
#> [29,] 1 2 3 1 1
#> [30,] 2 1 1 0 5