Learn R Programming

SpatioTemporal (version 1.1.2)

est.cv.mesa: Example of estCVSTmodel and predCVSTmodel Structures

Description

Example of 10-fold cross-validated for the model in mesa.model using estimateCV.STmodel and predictCV.STmodel.

Arguments

format

A list with elements, see the return description in estimateCV.STmodel and predictCV.STmodel.

source

Contains parametere estimates for the Spatio-Temporal model applied to monitoring data from the MESA Air project, see Cohen et.al. (2009) and mesa.data.raw for details.

References

M. A. Cohen, S. D. Adar, R. W. Allen, E. Avol, C. L. Curl, T. Gould, D. Hardie, A. Ho, P. Kinney, T. V. Larson, P. D. Sampson, L. Sheppard, K. D. Stukovsky, S. S. Swan, L. S. Liu, J. D. Kaufman. (2009) Approach to Estimating Participant Pollutant Exposures in the Multi-Ethnic Study of Atherosclerosis and Air Pollution (MESA Air). Environmental Science & Technology: 43(13), 4687-4693.

See Also

estimateCV.STmodel and predictCV.STmodel for cross-validation. createSTmodel for creation of the originating STmodel object.

Other example data: est.mesa.model, MCMC.mesa.model, mesa.data, mesa.data.raw, mesa.model, pred.mesa.model

Examples

Run this code
##load data
data(mesa.model)

##create the CV structure defining 10 different CV-groups
Ind.cv <- createCV(mesa.model, groups=10, min.dist=.1)

##create vector of initial values
dim <- loglikeSTdim(mesa.model)
x.init <- cbind(rep(2,dim$nparam.cov),c(rep(c(1,-3),dim$m+1),-3))

##estimate different parameters for each CV-group
  est.cv.mesa <- estimateCV(mesa.model, x.init, Ind.cv)
  ##Do cross-validated predictions using the just estimated parameters
  pred.cv.mesa <- predictCV(mesa.model, est.cv.mesa$par.cov, 
                            est.cv.mesa$Ind.cv)
##lets load precomputed results instead
data(CV.mesa.model)
##and results of estimation
data(est.mesa.model)

##examining the estimation results
print( est.cv.mesa )
names( est.cv.mesa )
 
##boxplot of the different estimates from the CV
par(mfrow=c(1,1), mar=c(12,2.5,2,.5), las=2)
boxplot( est.cv.mesa, plot.type="cov")
points( coef(est.mesa.model,"cov")$par, pch=19, col=2)
 
##examining the prediction
print( pred.cv.mesa )
names( pred.cv.mesa )
 
##Plot observations with CV-predictions and prediction intervals
##TODO TODO TODO
#par(mfcol=c(4,1),mar=c(2.5,2.5,2,.5))
#plotCV(mesa.data.res$pred.cv,  1, mesa.data.model)
#plotCV(mesa.data.res$pred.cv, 10, mesa.data.model)
#plotCV(mesa.data.res$pred.cv, 17, mesa.data.model)
#plotCV(mesa.data.res$pred.cv, 22, mesa.data.model)

Run the code above in your browser using DataLab