spLM {spBayes} | R Documentation |
The function spLM
fits Gaussian univariate stationary Bayesian
spatial regression models. Given a set of knots, spLM
fits a
predictive process model (see references below).
spLM(formula, data = parent.frame(), coords, knots, starting, sp.tuning, priors, cov.model, modified.pp = TRUE, n.samples, verbose=TRUE, n.report=100, ...)
formula |
a symbolic description of the regression model to be fit. 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 spLM 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 , sigma.sq ,
tau.sq , phi , and nu . The value portion of each
of each tag is the parameter's starting value. |
sp.tuning |
a list with each tag corresponding to a
parameter name. Valid list tags are sigma.sq ,
tau.sq , phi , and nu . The value portion of each
of each tag defines the variance of the Metropolis normal proposal distribution. |
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 sigma.sq.ig ,
tau.sq.ig , phi.unif , and nu.unif (Beta priors are
assumed flat). Variance parameters, simga.sq and
tau.sq , are assumed to follow an
inverse-Gamma distribution, whereas the spatial range phi
and smoothness nu parameters are assumed to follow Uniform distributions. The
hyperparameters of the inverse-Gamma are
passed as a vector of length two, with the first and second elements corresponding
to the shape and scale, respectively. The hyperparameters
of the Uniform are also passed as a vector of length two with the first
and second elements corresponding to the lower and upper support,
respectively. |
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. |
An object of class spLM
, 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.
Andrew O. Finley finleya@msu.edu,
Sudipto Banerjee baner009@umn.edu
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.
## Not run: data(rf.n200.dat) Y <- rf.n200.dat$Y coords <- as.matrix(rf.n200.dat[,c("x.coords","y.coords")]) w <- rf.n200.dat$w ############################## ##Simple spatial regression ############################## m.1 <- spLM(Y~1, coords=coords, starting=list("phi"=0.6,"sigma.sq"=1, "tau.sq"=1), sp.tuning=list("phi"=0.01, "sigma.sq"=0.05, "tau.sq"=0.05), priors=list("phi.Unif"=c(0.3, 3), "sigma.sq.IG"=c(2, 1), "tau.sq.IG"=c(2, 1)), cov.model="exponential", n.samples=1000, verbose=TRUE, n.report=100) print(summary(m.1$p.samples)) plot(m.1$p.samples) ##Requires MBA package to ##make surfaces library(MBA) par(mfrow=c(1,2)) obs.surf <- mba.surf(cbind(coords, Y), no.X=100, no.Y=100, extend=TRUE)$xyz.est image(obs.surf, xaxs = "r", yaxs = "r", main="Observed response") points(coords) contour(obs.surf, add=T) w.hat <- rowMeans(m.1$sp.effects) w.surf <- mba.surf(cbind(coords, w.hat), no.X=100, no.Y=100, extend=TRUE)$xyz.est image(w.surf, xaxs = "r", yaxs = "r", main="Estimated random effects") points(coords) points(m.1$knot.coords, pch=19, cex=1) contour(w.surf, add=T) ############################## ##Predictive process ############################## ##Use some more observations data(rf.n500.dat) Y <- rf.n500.dat$Y coords <- as.matrix(rf.n500.dat[,c("x.coords","y.coords")]) w <- rf.n500.dat$w m.2 <- spLM(Y~1, coords=coords, knots=c(6,6,0), starting=list("phi"=0.6,"sigma.sq"=1, "tau.sq"=1), sp.tuning=list("phi"=0.01, "sigma.sq"=0.01, "tau.sq"=0.01), priors=list("phi.Unif"=c(0.3, 3), "sigma.sq.IG"=c(2, 1), "tau.sq.IG"=c(2, 1)), cov.model="exponential", modified.pp=FALSE, n.samples=2000, verbose=TRUE, n.report=100) print(summary(m.2$p.samples)) plot(m.2$p.samples) ##Requires MBA package to ##make surfaces library(MBA) par(mfrow=c(1,2)) obs.surf <- mba.surf(cbind(coords, w), no.X=100, no.Y=100, extend=TRUE)$xyz.est image(obs.surf, xaxs = "r", yaxs = "r", main="Observed response") points(coords) contour(obs.surf, add=T) w.hat <- rowMeans(m.2$sp.effects) w.surf <- mba.surf(cbind(coords, w.hat), no.X=100, no.Y=100, extend=TRUE)$xyz.est image(w.surf, xaxs = "r", yaxs = "r", main="Estimated random effects") contour(w.surf, add=T) points(coords, pch=1, cex=1) points(m.2$knot.coords, pch=19, cex=1) legend(1.5,2.5, legend=c("Obs.", "Knots"), pch=c(1,19), bg="white") ############################## ##Modified predictive process ############################## m.3 <- spLM(Y~1, coords=coords, knots=c(6,6,0), starting=list("phi"=0.6,"sigma.sq"=1, "tau.sq"=1), sp.tuning=list("phi"=0.01, "sigma.sq"=0.01, "tau.sq"=0.01), priors=list("phi.Unif"=c(0.3, 3), "sigma.sq.IG"=c(2, 1), "tau.sq.IG"=c(2, 1)), cov.model="exponential", n.samples=2000, verbose=TRUE, n.report=100) print(summary(m.3$p.samples)) plot(m.3$p.samples) ##Requires MBA package to ##make surfaces library(MBA) par(mfrow=c(1,2)) obs.surf <- mba.surf(cbind(coords, w), no.X=100, no.Y=100, extend=TRUE)$xyz.est image(obs.surf, xaxs = "r", yaxs = "r", main="Observed response") points(coords) contour(obs.surf, add=T) w.hat <- rowMeans(m.3$sp.effects) w.surf <- mba.surf(cbind(coords, w.hat), no.X=100, no.Y=100, extend=TRUE)$xyz.est image(w.surf, xaxs = "r", yaxs = "r", main="Estimated random effects") contour(w.surf, add=T) points(coords, pch=1, cex=1) points(m.3$knot.coords, pch=19, cex=1) legend(1.5,2.5, legend=c("Obs.", "Knots"), pch=c(1,19), bg="white") ## End(Not run)