Learn R Programming

SpatioTemporal (version 0.9.2)

plotCV: Illustrates Predictions and Cross-validated Predictions

Description

Plots the result of (cross-validated) predictions. Given output from cond.expectation or predictCV this will plot the predicted values for one site along with approximate confidence intervalls, and observed data.

Usage

plotCV(pred.cv, ID, mesa.data = NA, add = FALSE, p = 0.95,
       col = c("black", "red", "grey"), lty=c(1,1), pch=c(NA,NA),
       cex=c(1,1))

plotPrediction(cond.exp, ID, mesa.data = NA, add = FALSE, p = 0.95, col = c("black", "red", "grey"), lty=c(1,1), pch=c(NA,NA), cex=c(1,1))

Arguments

pred.cv
Result of a cross-validation. Should be the output from predictCV.
cond.exp
Result of conditional expectations (predictions). Should be the output from cond.expectation, with only.obs=FALSE.
ID
The location for which we want plots. Either a string matching the names in mesa.data$location$ID or an integer; if an integer the functions will plot data from ID=mesa.data.model$location$ID[ID].
mesa.data
A data structure containing the observations, either mesa.data or mesa.data.model. This is only needed if the location in I
add
Add to an existing plot, or start a new plot.
p
Approximate coverage of the plotted confidence bands.
col
A vector of three colours to use when plotting the cross-validated predictions. The first is the colour of the predictions, second for the observations and third for the polygon illustrating the confidence bands.
lty, pch
Line and/or point type to use when plotting the predictions and observations. The first value is for the predictions, the second for the observations. If any value is given as NA this implies no lines and/or points. Thus the defau
cex
Size of the points to use if pch!=NA, see points and par.

Value

  • Does not return anything.

encoding

latin1

See Also

See createCV and estimateCV for cross-validation set-up and estimation.

For prediction, see fit.mesa.model and cond.expectation.

For computing CV statistics, see also predictNaive and compute.ltaCV; for further illustration see CVresiduals.qqnorm and summaryStatsCV.

Examples

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

##############
##  plotCV  ##
##############
##Extract pre-computed cross-validated predictions
pred.cv <- mesa.data.res$pred.cv

##Plot observations with CV-predictions and 
##95\% prediction intervals
par(mfcol=c(4,1),mar=c(2.5,2.5,2,.5))
plotCV(pred.cv,  1, mesa.data.model)
##different colours
plotCV(pred.cv, 10, mesa.data.model,
    col=c("blue","magenta","light blue"))
##points and lines for the observations
plotCV(pred.cv, 17, mesa.data.model, lty=1, pch=c(NA,19), cex=.5)
##location by name
plotCV(pred.cv, "L002", mesa.data.model)

######################
##  plotPrediction  ##
######################
##Extract pre-computed conditional expectations
EX <- mesa.data.res$EX

##plot predictions and observations for 4 locations
par(mfrow=c(4,1),mar=c(2.5,2.5,2,.5))
plotPrediction(EX,  1, mesa.data.model)
##different colours
plotPrediction(EX, 10, mesa.data.model,
    col=c("blue","black","light blue"))
##points for the observations
plotPrediction(EX, 17, mesa.data.model, lty=c(1,NA),
               pch=c(NA,19), cex=.5)
##location by name
plotPrediction(EX, "L002", mesa.data.model)

Run the code above in your browser using DataLab