Learn R Programming

ramps (version 0.5-2)

georamps: Bayesian Geostatistical Model Fitting with RAMPS

Description

General function for fitting Bayesian geostatistical models using the reparameterized and marginalized posterior sampling (RAMPS) algorithm of Yan et al. (2007).

Usage

georamps(fixed, random, correlation, data, subset, weights,
            variance = list(fixed = ~ 1, random = ~ 1, spatial = ~ 1),
            aggregate = list(grid = NULL, blockid = ""),
            control = ramps.control(...), contrasts = NULL, ...)

Arguments

fixed
two-sided linear "formula" object describing the main effects in the mean structure of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right.
random
optional one-sided formula of the form ~ 1 | g, specifying random intercepts for groups defined by the factor g. Several grouping variables may be simultaneously specified, separated by the * operator, as in ~
correlation
'corSpatial' object describing the spatial correlation structure. See the corClasses documentation for a listing of the available structures.
data
optional data frame containing the variables named in fixed, random, correlation, weights, variance, and subset.
subset
optional expression indicating the subset of row in data that should be used in the fit. This can be a logical vector, or a numerical vector indicating which observation numbers are to be included, or a character vector of the row names to be
weights
optional numerical vector of weights to be used in the fitting process. Defaults to a value of 1 for point-source measurements and the number of grid points for areal measurements (see the aggregate argument below).
variance
optional list of one-sided formulas, each of the form ~ g where g defines a grouping factor for the following elements: fixed for measurement error variances; random for random effects error variances; a
aggregate
optional list of elements: grid a data frame of coordinates to use for Monte Carlo integration over geographic blocks at which areal measurements are available; and blockid a character string specifying the column by which to mer
control
list of parameters for controlling the fitting process. See the ramps.control documentation for details.
contrasts
optional list. See the contrasts.arg of model.matrix.
...
further arguments passed to or from other methods.

Value

  • An object of class 'ramps' containing the following elements:
  • params'mcmc'"} object of monitored model parameters with variable labels in the column names and MCMC iteration numbers in the row names.} item{z}{code{'mcmc'} object of monitored latent spatial parameters with variable labels in the column names and MCMC iteration numbers in the row names.} item{loglik}{data log-likelihood at each MCMC iteration.} item{evals}{total number of evaluations of the slice sampling routine.} item{call}{the matched function call to code{georamps}.} item{y}{response vector.} item{xmat}{design matrix for the main effects.} item{terms}{the code{'terms'} object for code{xmat}.} item{xlevels}{list of the factor levels for code{xmat}.} item{etype}{grouping factor for the measurement error variances.} item{weights}{weights used in the fitting process.} item{kmat}{matrix for mapping the spatial parameters to the observed data.} item{correlation}{specified code{'corSpatial'} object for the spatial correlation structure.} item{coords}{matrix of unique coordinates for the measurement and grid sites.} item{ztype}{grouping factor for the spatial variances.} item{wmat}{matrix for mapping the random effects to the observed data.} item{retype}{grouping factor for the random effects variances.} item{control}{a list of control parameters used in the fitting process.} } references{ Yan, J., Cowles, M.K., Wang, S., and Armstrong, M. (2007) dQuote{Parallelizing MCMC for Bayesian Spatiotemporal Geostatistical Models}, Statistics and Computing, in press. } author{ Brian Smith email{brian-j-smith@uiowa.edu}, Jun Yan email{jun.yan@uconn.edu}, and Kate Cowles email{kate-cowles@uiowa.edu}} seealso{ code{corClasses}, code{ramps.control}, code{mcmc}, code{DIC.ramps}, code{plot.ramps}, code{predict.ramps}, code{summary.ramps}, code{window.ramps} } examples{ ## Load the included uranium datasets for use in this example data(NURE) ## Geostatistical analysis of areal measurements NURE.ctrl1 <- ramps.control( iter = 25, beta = param(0, "flat"), sigma2.e = param(1, "invgamma", shape = 2.0, scale = 0.1, tuning = 0.75), phi = param(10, "uniform", min = 0, max = 35, tuning = 0.50), sigma2.z = param(1, "invgamma", shape = 2.0, scale = 0.1) ) NURE.fit1 <- georamps(log(ppm) ~ 1, correlation = corRExp(form = ~ lon + lat, metric = "haversine"), weights = area, data = NURE, subset = (measurement == 1), aggregate = list(grid = NURE.grid, blockid = "id"), control = NURE.ctrl1 ) print(NURE.fit1) summary(NURE.fit1) ## Analysis of point-source measurements NURE.ctrl2 <- ramps.control( iter = 25, beta = param(0, "flat"), sigma2.e = param(1, "invgamma", shape = 2.0, scale = 0.1, tuning = 0.75), phi = param(10, "uniform", min = 0, max = 35, tuning = 0.5), sigma2.z = param(1, "invgamma", shape = 2.0, scale = 0.1) ) NURE.fit2 <- georamps(log(ppm) ~ 1, correlation = corRExp(form = ~ lon + lat, metric = "haversine"), data = NURE, subset = (measurement == 2), control = NURE.ctrl2 ) print(NURE.fit2) summary(NURE.fit2) ## Joint analysis of areal and point-source measurements with ## prediction only at grid sites NURE.ctrl <- ramps.control( iter = 25, beta = param(rep(0, 2), "flat"), sigma2.e = param(rep(1, 2), "invgamma", shape = 2.0, scale = 0.1, tuning = 0.75), phi = param(10, "uniform", min = 0, max = 35, tuning = 0.5), sigma2.z = param(1, "invgamma", shape = 2.0, scale = 0.1), z.monitor = NURE.grid ) NURE.fit <- georamps(log(ppm) ~ factor(measurement) - 1, correlation = corRExp(form = ~ lon + lat, metric = "haversine"), variance = list(fixed = ~ measurement), weights = area * (measurement == 1) + (measurement == 2), data = NURE, aggregate = list(grid = NURE.grid, blockid = "id"), control = NURE.ctrl ) print(NURE.fit) summary(NURE.fit) } keyword{models}