Learn R Programming

SpatioTemporal (version 1.1.2)

plot.predCVSTmodel: Plots for predictSTmodel and predCVSTmodel Objects

Description

plot method for classes predictSTmodel and predCVSTmodel. Provides several different plots of the data.

Usage

## S3 method for class 'predCVSTmodel':
plot(x, y = "time",
    ID = colnames(x$pred.all$EX)[1],
    col = c("black", "red", "grey"), pch = c(NA, NA),
    cex = c(1, 1), lty = c(1, 1), lwd = c(1, 1), p = 0.95,
    pred.type = "EX", pred.var = TRUE, add = FALSE, ...)

## S3 method for class 'predictSTmodel': plot(x, y = "time", STmodel = NULL, ID = x$I$ID[1], col = c("black", "red", "grey"), pch = c(NA, NA), cex = c(1, 1), lty = c(1, 1), lwd = c(1, 1), p = 0.95, pred.type = "EX", pred.var = FALSE, add = FALSE, ...)

Arguments

x
predictSTmodel or predCVSTmodel object to plot.
y
Plot predictions as a function of either "time" or "obs"ervations.
STmodel
STdata/STmodel object containing observations with which to compare the predictions (not used for plot.predCVSTmodel).
ID
The location for which we want to plot predictions. A string matching names in colnames(x$EX) (or x$I$ID, number(s) which are used as ID = colnames(x$EX)[ID], or "all" in which case all predictio
col
A vector of three colours: The first is the colour of the predictions, second for the observations and third for the polygon illustrating the confidence bands.
pch,cex,lty,lwd
Vectors with two elements giving the point type, size, line type and line width to use when plotting the predictions and observations respectively. Setting a value to NA will give no points/lines for the predictions/observations. Whe
p
Width of the plotted confidence bands (as coverage percentage, used to find appropriate two-sided normal quantiles).
pred.type
Which type of prediction to plot, one of "EX", "EX.mu", or "EX.mu.beta", see the output from predict.STmodel
pred.var
Should we plot confidence bands based on prediction (TRUE) or confidence intrevalls (FALSE), see predict.STmodel. Only relevant if pred.type="EX". NOTE: The
add
Add to existing plot?
...
Ignored additional arguments.

Value

  • Nothing

See Also

Other predCVSTmodel methods: estimateCV.STmodel, predictCV.STmodel, print.predCVSTmodel, print.summary.predCVSTmodel, summary.predCVSTmodel

Other predictSTmodel methods: predict.STmodel, print.predictSTmodel

Examples

Run this code
##load data
data(mesa.model)
##load predictions
data(pred.mesa.model)
##load CV-predictions
data(CV.mesa.model)

#######################################
## plot predictions for a given site ##
#######################################
par(mfrow=c(2,1))
plot(pred.mesa.model)
##different site with data and prediction variances
plot(pred.mesa.model, STmodel=mesa.model, ID="L001",
     pred.var=TRUE)

##compare the different contributions to the predictions
plot(pred.mesa.model)
plot(pred.mesa.model, pred.type="EX.mu", col="red", add=TRUE)
plot(pred.mesa.model, pred.type="EX.mu.beta", col="green", add=TRUE)
##compare the two confidence and prediction intervalls
plot(pred.mesa.model, ID=3, pred.var=TRUE, col=c(0,0,"darkgrey"))
plot(pred.mesa.model, ID=3, STmodel=mesa.model,
     col=c("black","red","lightgrey"), add=TRUE)

##plot predictions as function of observations
par(mfrow=c(2,2))
plot(pred.mesa.model.obs, y="obs", STmodel=mesa.model, pred.var=TRUE)
##all data
plot(pred.mesa.model.obs, y="obs", STmodel=mesa.model, ID="all",
     pred.var=TRUE)
##prehaps using points
plot(pred.mesa.model.obs, y="obs", STmodel=mesa.model, ID="all",
     lty=c(NA,1), pch=c(19,NA), cex=.25, pred.var=TRUE)
##compare prediction methods
plot(pred.mesa.model.obs, y="obs", STmodel=mesa.model, ID="all",
     lty=c(NA,1), pch=c(19,NA), cex=.25, pred.var=TRUE)
plot(pred.mesa.model.obs, y="obs", STmodel=mesa.model, ID="all",
     col="red", lty=NA, pch=c(19,NA), cex=.25, pred.type="EX.mu",
     add=TRUE)
plot(pred.mesa.model.obs, y="obs", STmodel=mesa.model, ID="all",
     col="green", lty=NA, pch=c(19,NA), cex=.25, pred.type="EX.mu.beta",
     add=TRUE)

####################################
## plot CV-pred. for a given site ##
####################################
par(mfcol=c(3,1),mar=c(2.5,2.5,2,.5))
plot(pred.cv.mesa, ID=1)
plot(pred.cv.mesa, ID=1, pred.type="EX.mu", col="green", add=TRUE)
plot(pred.cv.mesa, ID=1, pred.type="EX.mu.beta", col="blue", add=TRUE)
##different colours
plot(pred.cv.mesa, ID=10, col=c("blue","magenta","light blue"))
##points and lines for the observations
plot(pred.cv.mesa, ID=17, lty=c(1,NA), pch=c(NA,19), cex=.5)

##plot predictions as function of observations
par(mfrow=c(2,2))
plot(pred.cv.mesa, y="obs")
##all data
plot(pred.cv.mesa, y="obs", ID="all")
##prehaps using points
plot(pred.cv.mesa, y="obs", ID="all", lty=c(NA,1), pch=c(19,NA), cex=.25)
##compare prediction methods
plot(pred.cv.mesa, y="obs", ID="all", lty=c(NA,1), pch=c(19,NA), cex=.25)
plot(pred.cv.mesa, y="obs", ID="all", col="red", lty=NA, pch=c(19,NA),
     cex=.25, pred.type="EX.mu", add=TRUE)
plot(pred.cv.mesa, y="obs", ID="all", col="green", lty=NA, pch=c(19,NA),
     cex=.25, pred.type="EX.mu.beta", add=TRUE)

Run the code above in your browser using DataLab