Learn R Programming

spBayes (version 0.2-4)

spDiag: Model fit diagnostics DIC and GP

Description

The function spDiag calculates DIC, GP, and associated statistics given a bayesLMRef, bayesLMConjugate, spGGT, spLM, spMvLM, bayesGeostatExact, spGLM, or mvLM object.

Usage

spDiag(sp.obj, start=1, end, thin=1, n.report=100, verbose=TRUE, ...)

Arguments

sp.obj
an object returned by bayesLMRef, bayesLMConjugate, spGGT,
start
specifies the first sample included in the calculation. This is useful for those who choose to acknowledge chain burn-in.
end
specifies the last sample included in the prediction calculation. The default is to use all posterior samples in sp.obj.
thin
a sample thinning factor. The default of 1 considers all samples between start and end. For example, if thin = 10 then 1 in 10 samples are considered between start and end.
verbose
if TRUE calculation progress is printed to the screen; otherwise, nothing is printed to the screen.
n.report
the interval to report progress.
...
currently no additional arguments.

Value

  • A list with some of the following tags:
  • DICa matrix holding DIC and associated statistics, see Banerjee et al. (2004) for details.
  • GPa matrix holding GP and associated statistics, see Gelfand and Ghosh (1998) for details. This is only available for bayesLMRef, bayesLMConjugate,spLM, spMvLM, bayesGeostatExact, and mvLM objects
  • sp.effectsif sp.obj specifies a spatial model without pre-calculated spatial effects then spDiag calculates the spatial effects.

References

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. Gelfand A.E. and Ghosh, S.K. (1998). Model choice: a minimum posterior predictive loss approach. Biometrika. 85:1-11.

See Also

bayesLMRef, bayesLMConjugate, spGGT, bayesGeostatExact, spLM, spGLM, spMvLM, mvLM

Examples

Run this code
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

n.samples <- 1000

##non-spatial regression
m.1 <- bayesLMRef(lm(Y~1), n.samples=n.samples)


##spatial regression
m.2 <- 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=n.samples, verbose=TRUE, n.report=100)

##compare
print(spDiag(m.1))
print(spDiag(m.2, start=500, thin=2))

Run the code above in your browser using DataLab