Description Usage Arguments Value Author(s) See Also Examples
This help page documents several functions for simulate samples from different CAR models.
1 2 3 4 5 | CAR.simTorus(n1, n2, rho, prec)
CAR.simWmat(rho, prec, W)
CAR.simLM(pars, data)
CAR.simGLM(method = c("binom", "poisson"), W, n = NULL, pars, Xs = NULL,
n.trial = 1)
|
n1, n2, n |
n = c(n1, n2), the size of the torus |
rho |
the spatial coefficient in the CAR precision matrix (inverse of the covariance matrix) |
prec |
the precision in the CAR precision matrix |
W |
the spatial weight matrix |
pars |
parameter values of the direct CAR model |
data |
a |
method |
a character equal to either "binom" or "poisson" that indicate the distribution of the sample to be simulated. |
Xs |
the covariates to be used in the glm |
n.trial |
the number of trials in each unit of the binomial samples |
|
returns a list containing the spatial
weight matrix |
|
returns an array of the simulated CAR samples; |
|
returns a list containing:
|
Zhe Sha zhesha1006@gmail.com
mcl.glm
, mcl.dCAR
,
mcl.prep.dCAR
, mcl.prep.glm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Simulate CAR data on a torus
set.seed(33)
n.torus <- 10
rho <- 0.2
sigma <- 1.5
prec <- 1/sigma
beta <- c(1, 1)
XX <- cbind(rep(1, n.torus^2), sample(log(1:n.torus^2)/5))
mydata1 <- CAR.simTorus(n1 = n.torus, n2 = n.torus, rho = rho, prec = prec)
## Simulate CAR data for a given spatial weight matrix
Wmat <- mydata1$W
mydata2 <- CAR.simWmat(rho = rho, prec = prec, W = Wmat)
## Simualte data from a linear model with CAR error
y <- XX %*% beta + mydata1$X
mydata1$data.vec <- data.frame(y=y, XX[,-1])
mydata3 <- CAR.simLM(pars = c(0.1, 1, 2, 0.5), data = mydata1)
## Simulate Binomial data with CAR latent variables
mydata4 <- CAR.simGLM(method="binom", n=c(10,10), pars = c(rho, sigma,
beta), Xs=XX, n.trial = 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.