| mcsglmm | R Documentation |
Draw MCMC samples from the Spatial GLMM with known link function
mcsglmm(
formula,
family = "gaussian",
data,
weights,
subset,
offset,
atsample,
corrfcn = "matern",
linkp,
phi,
omg,
kappa,
Nout,
Nthin = 1,
Nbi = 0,
betm0,
betQ0,
ssqdf,
ssqsc,
corrpriors,
corrtuning,
dispersion = 1,
longlat = FALSE,
test = FALSE
)
formula |
A representation of the model in the form
|
family |
The distribution of the data. The
|
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 vector specifying a subset of observations to be used in the fitting process. |
offset |
See |
atsample |
A formula in the form |
corrfcn |
Spatial correlation function. See
|
linkp |
Parameter of the link function. A scalar value. |
phi |
Optional starting value for the MCMC for the
spatial range parameter |
omg |
Optional starting value for the MCMC for the
relative nugget parameter |
kappa |
Optional starting value for the MCMC for the
spatial correlation parameter |
Nout |
Number of MCMC samples to return. This can be a vector for running independent chains. 0 elements are dropped. |
Nthin |
The thinning of the MCMC algorithm. |
Nbi |
The burn-in of the MCMC algorithm. |
betm0 |
Prior mean for beta (a vector or scalar). |
betQ0 |
Prior standardised precision (inverse variance) matrix. Can be a scalar, vector or matrix. The first two imply a diagonal with those elements. Set this to 0 to indicate a flat improper prior. |
ssqdf |
Degrees of freedom for the scaled inverse chi-square prior for the partial sill parameter. |
ssqsc |
Scale for the scaled inverse chi-square prior for the partial sill parameter. |
corrpriors |
A list with the components |
corrtuning |
A vector or list with the components |
dispersion |
The fixed dispersion parameter. |
longlat |
How to compute the distance between locations. If
|
test |
Whether this is a trial run to monitor the acceptance
ratio of the random walk for |
The four-parameter prior for phi is defined by
\propto (\phi - \theta_4)^{\theta_2 -1} \exp\{-(\frac{\phi -
\theta_4}{\theta_1})^{\theta_3}\}
for \phi >
\theta_4. The prior for omg is similar.
The prior parameters correspond to scale, shape, exponent, and
location. See arXiv:1005.3274 for details of this
distribution.
The GEV (Generalised Extreme Value) link is defined by
\mu =
1 - \exp\{-\max(0, 1 + \nu x)^{\frac{1}{\nu}}\}
for any real \nu. At
\nu = 0 it reduces to the complementary log-log
link.
A list containing the objects MODEL, DATA,
FIXED, MCMC and call. The MCMC samples are
stored in the object MCMC as follows:
z A matrix containing the MCMC samples for the
spatial random field. Each column is one sample.
mu A matrix containing the MCMC samples for the
mean response (a transformation of z). Each column is one sample.
beta A matrix containing the MCMC samples for the
regressor coefficients. Each column is one sample.
ssq A vector with the MCMC samples for the partial
phi A vector with the MCMC samples for the spatial
range parameter, if sampled.
omg A vector with the MCMC samples for the relative
nugget parameter, if sampled.
logLik A vector containing the value of the
log-likelihood evaluated at each sample.
acc_ratio The acceptance ratio for the joint update
of the parameters phi and omg, if sampled.
sys_time The total computing time for the MCMC sampling.
Nout, Nbi, Nthin As in input. Used
internally in other functions.
The other objects contain input variables. The object call
contains the function call.
## Not run:
data(rhizoctonia)
### Create prediction grid
predgrid <- mkpredgrid2d(rhizoctonia[c("Xcoord", "Ycoord")],
par.x = 100, chull = TRUE, exf = 1.2)
### Combine observed and prediction locations
rhizdata <- stackdata(rhizoctonia, predgrid$grid)
##'
### Define the model
corrf <- "spherical"
family <- "binomial.probit"
kappa <- 0
ssqdf <- 1
ssqsc <- 1
betm0 <- 0
betQ0 <- .01
phiprior <- c(100, 1, 1000, 100) # U(100, 200)
phisc <- 3
omgprior <- c(2, 1, 1, 0) # Exp(mean = 2)
omgsc <- .1
##'
### MCMC sizes
Nout <- 100
Nthin <- 1
Nbi <- 0
### Trial run
emt <- mcsglmm(Infected ~ 1, family, rhizdata, weights = Total,
atsample = ~ Xcoord + Ycoord,
Nout = Nout, Nthin = Nthin, Nbi = Nbi,
betm0 = betm0, betQ0 = betQ0, ssqdf = ssqdf, ssqsc = ssqsc,
corrpriors = list(phi = phiprior, omg = omgprior),
corrfcn = corrf, kappa = kappa,
corrtuning = list(phi = phisc, omg = omgsc, kappa = 0),
dispersion = 1, test = 10)
### Full run
emc <- update(emt, test = FALSE)
emcmc <- mcmcmake(emc)
summary(emcmc[, c("phi", "omg", "beta", "ssq")])
plot(emcmc[, c("phi", "omg", "beta", "ssq")])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.