spMvLM {spBayes}R Documentation

Function for fitting multivariate Bayesian spatial regression models

Description

The function spMvLM fits Gaussian multivariate stationary Bayesian spatial regression models. Given a set of knots, spMvLM fits a predictive process model (see references below).

Usage

spMvLM(formula, data = parent.frame(), coords, knots,
      starting, sp.tuning, priors, cov.model,
      modified.pp = TRUE, n.samples,
      verbose=TRUE, n.report=100, ...)

Arguments

formula for a multivariate model with q response variables, this is a list of univariate formulas. See example below.
data an optional data frame containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which spMvLM is called.
coords an n x 2 matrix of the observation coordinates in R^2 (e.g., easting and northing).
knots either a m x 2 matrix of the predictive process knot coordinates in R^2 (e.g., easting and northing) or a vector of length two or three with the first and second elements recording the number of columns and rows in the desired knot grid. The third, optional, element sets the offset of the outermost knots from the extent of the coords extent.
starting a list with each tag corresponding to a parameter name. Valid list tags are beta, A, L, phi, and nu. The value portion of each tag is a vector of parameter's starting value. For A and L the vectors are of length q(q-q)/2+q and phi and nu are of length q. Here, A and L hold the the lower-triangle elements in column major ordering of the Cholesky square root of the spatial and non-spatial cross-covariance matrices, respectively.
sp.tuning a list with each tag corresponding to a parameter name. Valid list tags are A, L, phi, and nu. The value portion of each of each tag defines the step size of the proposal used in the Metropolis sampling. For A and L the vectors are of length q(q-q)/2+q and phi and nu are of length q.
modified.pp a logical value indicating if the modified predictive process should be used (see references below for details). Note, if a predictive process model is not used (i.e., knots is not specified) then this argument is ignored.
priors a list with each tag corresponding to a parameter name. Valid list tags are K.IW, Psi.IW, phi.unif, and nu.unif (Beta priors are assumed flat). Variance parameters, K and Psi, are assumed to follow an inverse-Wishart distribution, whereas the spatial range phi and smoothness nu parameters are assumed to follow Uniform distributions. The hyperparameters of the inverse-Wishart are passed as a list of length two, with the first and second elements corresponding to the df and qxq scale matrix, respectively. The hyperparameters of the Uniform are also passed as a vector of length 2xq with consecutive elements representing the first and second elements corresponding to the lower and upper support in the order of the univariate models given in formula.
cov.model a quoted key word that specifies the covariance function used to model the spatial dependence structure among the observations. Supported covariance model key words are: "exponential", "matern", "spherical", and "gaussian". See below for details.
n.samples the number of MCMC iterations.
verbose if TRUE, model specification and progress of the sampler is printed to the screen. Otherwise, nothing is printed to the screen.
n.report the interval to report Metropolis acceptance and MCMC progress.
... currently no additional arguments.

Value

An object of class spMvLM, which is a list with the following tags:

coords the n x 2 matrix specified by coords.
knot.coords the m x 2 matrix as specified by knots.
p.samples a coda object of posterior samples for the defined parameters.
acceptance the Metropolis sampling acceptance rate.
sp.effects a matrix that holds samples from the posterior distribution of the spatial random effects. The rows of this matrix correspond to the n point observations and the columns are the posterior samples.

The return object might include additional data used for subsequent prediction and/or model fit evaluation.

Author(s)

Andrew O. Finley finleya@msu.edu,
Sudipto Banerjee baner009@umn.edu

References

Banerjee, S., A.E. Gelfand, A.O. Finley, and H. Sang. (2008) Gaussian Predictive Process Models for Large Spatial Datasets. Journal of the Royal Statistical Society Series B, 70:825–848.

Finley, A.O., S. Banerjee, P. Waldmann, and T. Ericsson. (2008). Hierarchical spatial modeling of additive and dominance genetic variance for large spatial trial datasets. Biometrics. DOI: 10.1111/j.1541-0420.2008.01115.x

Finley, A.O,. H. Sang, S. Banerjee, and A.E. Gelfand. (2008). Improving the performance of predictive process modeling for large datasets. Computational Statistics and Data Analysis, DOI: 10.1016/j.csda.2008.09.008

Banerjee, S., Carlin, B.P., and Gelfand, A.E. (2004). Hierarchical modeling and analysis for spatial data. Chapman and Hall/CRC Press, Boca Raton, Fla.

See Also

spMvLM,spGGT

Examples

## Not run: 
###################################
##Multivariate spatial regression
###################################

##Generate some data
n <- 50 ##observed
q <- 3   
nltr <- q*(q-1)/2+q

coords <- cbind(runif(n),runif(n))
theta <- rep(3/0.5,q)

A <- matrix(0,q,q)
A[lower.tri(A,TRUE)] <- rnorm(nltr, 5, 1)
K <- A%*%t(A)

Psi <- diag(1,q)

c1 <- mvCovInvLogDet(coords=coords, knots=coords,
                     cov.model="exponential",
                     V=K, Psi=Psi, theta=theta,
                     modified.pp=FALSE, SWM=FALSE)

w <- mvrnorm(1,rep(0,nrow(c1$C)),c1$C)

w.1 <- w[seq(1,length(w),q)]
w.2 <- w[seq(2,length(w),q)]
w.3 <- w[seq(3,length(w),q)]

##Specify starting values and collect samples
K.starting <- diag(1,q)[lower.tri(diag(1,q), TRUE)]
Psi.starting <- diag(1,q)[lower.tri(diag(1,q), TRUE)]

n.samples <- 5000

m.1 <- spMvLM(list(w.1~1,w.2~1,w.3~1), coords=coords,
              starting=list("beta"=rep(1,q), "phi"=rep(3/0.5,q),
                "A"=K.starting), 
              sp.tuning=list("phi"=rep(0.1,q),
                "A"=rep(0.1,nltr)),
              priors=list("phi.Unif"=rep(c(3/1,3/0.1),q),
                "K.IW"=list(q+1, diag(1,q))),
              modified.pp=TRUE, cov.model="exponential",
              n.samples=n.samples, verbose=TRUE, n.report=100)

m.1$p.samples[,paste("phi_",1:q,sep="")] <-
  3/m.1$p.samples[,paste("phi_",1:q,sep="")]

burn.in <- 0.50*n.samples

print(summary(mcmc(m.1$p.samples[burn.in:n.samples,])))

w.hat <- rowMeans(m.1$sp.effects[,burn.in:ncol(m.1$sp.effects)])
w.hat.1 <- w.hat[seq(1,length(w.hat),q)]
w.hat.2 <- w.hat[seq(2,length(w.hat),q)]
w.hat.3 <- w.hat[seq(3,length(w.hat),q)]

##Take a look
par(mfrow=c(3,2))
surf <- mba.surf(cbind(coords,w.1),
                 no.X=100, no.Y=100, extend=T)$xyz.est
image(surf); contour(surf, add=TRUE)

surf <- mba.surf(cbind(coords,w.hat.1),
                 no.X=100, no.Y=100, extend=T)$xyz.est
image(surf); contour(surf, add=TRUE)
points(m.1$knot.coords, pch=19, cex=1)

surf <- mba.surf(cbind(coords,w.2),
                 no.X=100, no.Y=100, extend=T)$xyz.est
image(surf); contour(surf, add=TRUE)

surf <- mba.surf(cbind(coords,w.hat.2),
                 no.X=100, no.Y=100, extend=T)$xyz.est
image(surf); contour(surf, add=TRUE)
points(m.1$knot.coords, pch=19, cex=1)

surf <- mba.surf(cbind(coords,w.3),
                 no.X=100, no.Y=100, extend=T)$xyz.est
image(surf); contour(surf, add=TRUE)

surf <- mba.surf(cbind(coords,w.hat.3),
                 no.X=100, no.Y=100, extend=T)$xyz.est
image(surf); contour(surf, add=TRUE)
points(m.1$knot.coords, pch=19, cex=1)

## End(Not run)

[Package spBayes version 0.1-2 Index]