rsglmm {geoBayes} | R Documentation |
Simulation from a spatial model
Description
Simulate from a variety of spatial models.
Usage
rsglmm(
n,
formula,
family = "gaussian",
data,
weights,
subset,
offset,
atsample,
beta,
linkp,
phi,
omg,
kappa,
ssq,
corrfcn = "matern",
longlat = FALSE,
dispersion = 1,
returnGRF = FALSE,
warndisp = TRUE
)
rstrga(
n,
formula,
data,
weights,
subset,
offset,
atsample,
beta,
linkp,
phi,
omg,
kappa,
ssq,
corrfcn = "matern",
longlat = FALSE,
dispersion = 1,
returnGRF = FALSE
)
rsgrf(
n,
formula,
data,
subset,
offset,
atsample,
beta,
phi,
omg,
kappa,
ssq,
corrfcn = "matern",
longlat = FALSE
)
Arguments
n |
The number of instances to simulate |
formula |
A representation of the model in the form
|
family |
The distribution of the data to simulate from. |
data |
An optional data frame containing the variables in the model. |
weights |
An optional vector of weights. Number of replicated samples for Gaussian and gamma, number of trials for binomial, time length for Poisson. |
subset |
An optional set of indices. Simulations will be provided for those locations only. |
offset |
See |
atsample |
A formula of the form |
beta |
A vector of the regressor coefficents to use. |
linkp |
The link function parameter. |
phi |
The spatial range parameter. |
omg |
The relative nugget parameter. |
kappa |
The spatial smoothness parameter. |
ssq |
The partial sill parameter. |
corrfcn |
The correlation function to use. |
longlat |
How to compute the distance between locations. If
|
dispersion |
The fixed dispersion parameter. When this is not 1 and the sample is from a binomial or a Poisson distribution, no such distribution exists so an approximate sample is returned. Use with caution. |
returnGRF |
Whether to return the simulate Gaussian random field as well. |
warndisp |
Whether to warn when sampling from a quasi distribution. This is the case for binomial and Poisson when the dispersion is not one. |
Details
The spatial Gaussian random field is simulated using the Cholesky decomposition of the covariance matrix.
The sample from a quasi distribution uses a hack which matches the mean and the variance of the distribution. See the source code for details.
Value
A data frame containing the predictors, sampling locations, optional weights, and samples.
Examples
## Not run:
n <- 100
beta <- c(-2, 1)
phi <- .2
omg <- .3
linkp <- 0
ssq <- 1
l <- rep(10, n)
corrf <- "matern"
kappa <- .5
family <- "poisson"
Xcoord <- runif(n)
Ycoord <- runif(n)
f <- Xcoord + Ycoord
formula <- y|z ~ f
mydata <- rsglmm(1, formula, family, weights = l,
atsample = ~ Xcoord + Ycoord, beta = beta, linkp = linkp,
phi = phi, omg = omg, kappa = kappa, ssq = ssq,
corrfcn = corrf, returnGRF = TRUE)
## End(Not run)