sprnorm {spmodel} | R Documentation |
Simulate a spatial normal (Gaussian) random variable
Description
Simulate a spatial normal (Gaussian) random variable with a specific mean and covariance structure.
Usage
sprnorm(
spcov_params,
mean = 0,
samples = 1,
data,
randcov_params,
partition_factor,
...
)
## S3 method for class 'exponential'
sprnorm(
spcov_params,
mean = 0,
samples = 1,
data,
randcov_params,
partition_factor,
xcoord,
ycoord,
...
)
## S3 method for class 'none'
sprnorm(
spcov_params,
mean = 0,
samples = 1,
data,
randcov_params,
partition_factor,
...
)
## S3 method for class 'car'
sprnorm(
spcov_params,
mean = 0,
samples = 1,
data,
randcov_params,
partition_factor,
W,
row_st = TRUE,
M,
...
)
Arguments
spcov_params |
An |
mean |
A numeric vector representing the mean. |
samples |
The number of independent samples to generate. The default
is |
data |
A data frame or |
randcov_params |
A |
partition_factor |
A formula indicating the partition factor. |
... |
Other arguments. Not used (needed for generic consistency). |
xcoord |
Name of the column in |
ycoord |
Name of the column in |
W |
Weight matrix specifying the neighboring structure used for car and
sar models. Not required if |
row_st |
A logical indicating whether row standardization be performed on
|
M |
M matrix satisfying the car symmetry condition. The car
symmetry condition states that |
Details
Random variables are simulated via the product of the covariance matrix's
square (Cholesky) root and independent standard normal random variables
with mean 0 and variance 1. Computing the square root is a significant
computational burden and likely unfeasible for sample sizes much past 10,000.
Because this square root only needs to be computed once, however, it is
nearly the sample computational cost to call sprnorm()
for any value
of samples
.
Only methods for the exponential
, none
, and car
covariance functions are documented here,
but methods exist for all other spatial covariance functions defined in
spcov_initial()
. Syntax for the exponential
method is the same
as syntax for spherical
, gaussian
, triangular
,
circular
, cubic
, pentaspherical
, cosine
, wave
,
jbessel
, gravity
, rquad
, magnetic
, matern
,
cauchy
, and pexponential
methods. Syntax for
the car
method is the same as syntax for the sar
method. The
extra
parameter for car and sar models is ignored when all observations have
neighbors.
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.
Examples
spcov_params_val <- spcov_params("exponential", de = 1, ie = 1, range = 1)
sprnorm(spcov_params_val, data = caribou, xcoord = x, ycoord = y)
sprnorm(spcov_params_val, mean = 1:30, samples = 5, data = caribou, xcoord = x, ycoord = y)