SpatioTemporal (version 1.1.9.1)

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 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 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.

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 predictions are used. If several locations are given (or "all") then y must be "obs".

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. For y="obs" the colours are 1) colour of the points, 2) colour of the 1-1 line, and 3) colour of the polygon. If ID="all", picking col[1]="ID" will colour code the observations-prediction points by site ID.

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. When plotting predictions as a function of observations lty[2] is used for the addition of abline(0,1, lty=lty[2], col=col[2], lwd=lwd[2]); pch[2] and cex[2] are ignored.

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", "EX.mu.beta", or "EX.pred"; 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" or pred.type="EX.pred". NOTE: The default differs for plot.predictSTmodel and plot.predCVSTmodel!

add

Add to existing plot?

...

Additional parameters passed to plot.

STmodel

STdata/STmodel object containing observations with which to compare the predictions (not used for plot.predCVSTmodel).

Value

Nothing

See Also

Other predCVSTmodel methods: estimateCV.STmodel, print.predCVSTmodel, print.summary.predCVSTmodel, qqnorm.predCVSTmodel, scatterPlot.predCVSTmodel, summary.predCVSTmodel

Other predictSTmodel methods: predict.STmodel, print.predictSTmodel

Examples

Run this code
# NOT RUN {
#######################################
## plot predictions for a given site ##
#######################################
##load data
data(mesa.model)
##load predictions
data(pred.mesa.model)

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, y="obs", STmodel=mesa.model, pred.var=TRUE)

##all data, using points and colour coded by site
plot(pred.mesa.model, y="obs", STmodel=mesa.model, ID="all",
     lty=c(NA,1), pch=c(19,NA), col=c("ID", "red", "grey"),
     cex=.25, pred.var=TRUE)

##compare prediction methods, for one site only
plot(pred.mesa.model, y="obs", STmodel=mesa.model,
     lty=c(NA,1), pch=c(19,NA), cex=.25, pred.var=TRUE)
plot(pred.mesa.model, y="obs", STmodel=mesa.model, col="red",
     lty=NA, pch=c(19,NA), cex=.25, pred.type="EX.mu",
     add=TRUE)
plot(pred.mesa.model, y="obs", STmodel=mesa.model, col="green",
     lty=NA, pch=c(19,NA), cex=.25, pred.type="EX.mu.beta",
     add=TRUE)

####################################
## plot CV-pred. for a given site ##
####################################
##load CV-predictions
data(pred.cv.mesa)

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, using points and colour coded by site
plot(pred.cv.mesa, y="obs", ID="all", lty=c(NA,1),
     pch=c(19,NA), cex=.25, col=c("ID", "red", "grey"))

##compare prediction methods, for one site only
plot(pred.cv.mesa, y="obs", lty=c(NA,1), pch=c(19,NA), cex=.25)
plot(pred.cv.mesa, y="obs", col="red", lty=NA, pch=c(19,NA),
     cex=.25, pred.type="EX.mu", add=TRUE)
plot(pred.cv.mesa, y="obs", 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 DataCamp Workspace