##load data
data(mesa.data.model)
data(mesa.data.res)
##Extract pre-computed cross-validated predictions
pred.cv <- mesa.data.res$pred.cv
##Naive predictions based on AQS sites only
pred.N <- predictNaive(mesa.data.model, type="AQS")
##compute summary statistics
stat.CV <- summaryStatsCV(pred.cv, pred.naive=pred.N,
lta=TRUE, by.date=TRUE)
##study the summary statistics (for observations and long term average)
stat.CV$Stats[1:2,]
##adjusted R2 values, these are slightly strange since we
##(in this case) are basing the naive predictions on
##things left out of the cross-validation.
stat.CV$Stats[(dim(stat.CV$Stats)[1]-3):dim(stat.CV$Stats)[1],]
##plot the RMSE for each date as a function of date
plot(as.Date(rownames(stat.CV$Stats[3:(dim(stat.CV$Stats)[1]-4),])),
stat.CV$Stats[3:(dim(stat.CV$Stats)[1]-4),"RMSE"],
xlab="Date",ylab="RMSE")
##add over all RMSE as reference
abline(h=stat.CV$Stats["obs","RMSE"])
##Some plots for the residuals
par(mfrow=c(2,2), mar=c(4.5,4.5,3,.5))
## residuals against observations
plot(mesa.data.model$obs$obs, stat.CV$res,
ylab="Residuals", xlab="Observations")
## Norm-plot for the residuals
CVresiduals.qqnorm(stat.CV$res)
## Norm-plot and normalised residuals, these should be N(0,1).
CVresiduals.qqnorm(stat.CV$res.norm, norm=TRUE)
## normalised residuals against the first temporal trend
CVresiduals.scatter(stat.CV$res.norm, mesa.data.model$F[,2],
xlab="First temporal trend")
Run the code above in your browser using DataLab