Learn R Programming

CARBayesST (version 1.1)

ST.ARCARadaptive: Fit the space-time Poisson log-linear model proposed by Rushworth et al. (2014a) with an adaptive autoregressive spatio-temporal correlation stucture.

Description

The function fits the Bayesian spatio-temporal model proposed by Rushworth et al. (2014a) to Poisson count data. The natural log of the linear predictor is made up of a covariate component and a set of random effects that follow an autoregressive CAR model, the latter of which is similar to that proposed by Rushworth et al. (2014b). The non-zero elements of the adjacency matrix W associated with each pair of geographically adjacent regions are treated as random variables, which allows step changes to be identified in the random effects surface between geogrphically adjacent regions. These random variables are assumed to be independent in space with a common variance. Inference is based on Markov chain Monte Carlo (McMC) simulation, using a combination of Gibbs sampling and Metropolis steps.

Usage

ST.ARCARadaptive(formula, data=NULL, W, burnin=0, n.sample=1000, thin=1,  
prior.mean.beta=NULL, prior.var.beta=NULL, prior.tau2=NULL, 
prior.sigma2 = NULL, verbose=TRUE)

Arguments

formula
A formula for the covariate part of the model, using the same notation as for the lm() function. The offsets should also be included here using the offset() function. The response and each covariate should be vectors of length (KN)*1, where K is the numbe
data
A data.frame containing the variables in the formula.
W
A binary K by K neighbourhood matrix (where K is the number of spatial units). The jkth element equals one if areas (j, k) are spatially close (e.g. share a common border) and is zero otherwise.
burnin
The number of MCMC samples to discard as the burnin period. Defaults to 0.
n.sample
The number of MCMC samples to generate. Defaults to 1,000.
thin
The level of thinning to apply to the MCMC samples to reduce their temporal autocorrelation. Defaults to 1.
prior.mean.beta
A vector of prior means for the regression parameters beta (Gaussian priors are assumed). Defaults to a vector of zeros.
prior.var.beta
A vector of prior variances for the regression parameters beta (Gaussian priors are assumed). Defaults to a vector with values 1000.
prior.tau2
The prior shape and scale in the form of c(shape, scale) for an Inverse-Gamma(shape, scale) prior for the random effect variance term sigma2. Defaults to c(0.001, 0.001).
prior.sigma2
The prior shape and scale in the form of c(shape, scale) for an Inverse-Gamma(shape, scale) prior for the second level adjacency random effect variance term sigma2. Defaults to c(0.001, 0.001).
verbose
Logical, should the function update the user on its progress.

Value

  • formulaThe formula for the covariate and offset part of the model.
  • samplesA list containing the MCMC samples from the model.
  • fitted.valuesA vector containing the fitted value for each area and time point. The vector is ordered so that all spatial units for time period one come first and then time period two and so on.
  • residualsA vector containing the residuals for each area and time point. The vector is ordered so that all spatial units for time period one come first and then time period two and so on.
  • stepchangeA list with 2 K*K matrices, Wmn and W99 summarising the estimated adjacency relationships. Wmn contains the posterior median for each w_ij element estimated in the model for adjacent areal units, while W99 contains Prob(w_ij < 0.5|data). For both matrices, elements corresponding to non-adjacent pairs of areas have NA values.
  • modelfitModel fit criteria including the Deviance Information Criterion (DIC), the effective number of parameters in the model (p.d), and the log Marginal Predictive Likelihood (LMPL).
  • summary.resultsA table summarising some of the parameters in the model.
  • modelA text string describing the model.
  • acceptThe acceptance probabilities for the parameters.

Details

For further details about how to apply the function see the examples below.

References

Rushworth, A., Lee, D., and Sarran, C. An adaptive spatio-temporal smoothing model for estimating trends and step changes in disease risk (2014a) arXiv:1411.0924

Rushworth, A., D. Lee, and R. Mitchell (2014b). A spatio-temporal model for estimating the long-term effects of air pollution on respiratory hospital admissions in Greater London. Spatial and Spatio-temporal Epidemiology 10, 29-38.

Examples

Run this code
#### Artificial data generated on a square

#### Set up a square lattice region
x.easting <- 1:10
x.northing <- 1:10
Grid <- expand.grid(x.easting, x.northing)
n <- nrow(Grid)
t <- 10


#### set up distance and neighbourhood (W, based on sharing a common border) matrices
distance <-array(0, c(n,n))
W <-array(0, c(n,n))
     for(i in 1:n)
     {
     	for(j in 1:n)
		{
		temp <- (Grid[i,1] - Grid[j,1])^2 + (Grid[i,2] - Grid[j,2])^2
		distance[i,j] <- sqrt(temp)
			if(temp==1)  W[i,j] <- 1 
		}	
	}
	
	
#### Generate data
n.all <- n * t
E <- rep(100, n.all)
log.risk <- log(rep(c(rep(1, 70), rep(2, 30)),t))
x <- rnorm(n.all)
risk <- exp(log.risk + 0.1 * x)
mean <- E * risk
Y <- rpois(n=n.all, lambda=mean)
formula <- Y~ offset(log(E)) + x
     

#### Run the model     
model1 <- ST.ARCARadaptive(formula, data=NULL, W=W, burnin=5000, n.sample=10000)

Run the code above in your browser using DataLab