SpatioTemporal (version 1.1.9.1)

scatterPlot.predCVSTmodel: scatterPlot for STdata/STmodel/predCVSTmodel objects

Description

Does a scatterPlot of observations/residuals against covariates (either geographic or temporal trends), adding a spline fit (similar to scatter.smooth.

Usage

# S3 method for predCVSTmodel
scatterPlot(x, covar = NULL, trend = NULL,
  pch = 1, col = 1, cex = 1, lty = 1, subset = NULL, group = NULL,
  add = FALSE, smooth.args = NULL, STdata, type = c("obs", "res",
  "res.norm"), org.scale = TRUE, ...)

# S3 method for STdata scatterPlot(x, covar = NULL, trend = NULL, pch = 1, col = 1, cex = 1, lty = 1, subset = NULL, group = NULL, add = FALSE, smooth.args = NULL, ...)

# S3 method for STmodel scatterPlot(x, covar = NULL, trend = NULL, pch = 1, col = 1, cex = 1, lty = 1, subset = NULL, group = NULL, add = FALSE, smooth.args = NULL, ...)

Arguments

x

STdata/STmodel/predCVSTmodel object to plot.

covar, trend

Plot observations as a function of? Only one of these should be not NULL. covar uses location covariates, and trend uses temporal trend (or dates); trend=0 uses a temporal intercept (i.e. a constant).

pch, cex

Point and point size for the plot, a single value or nlevels(group)

col, lty

Color of points and smooth lines. A single value or nlevels(group)+1 values; the last value is used for fitting a line to all data. Use lty=NA to supress smooth lines.

subset

A subset of locations for which to plot observations as a function of covariates.

group

A vector of factors of the same length as the number of observations (typically length(x$obs$obs), or length(x$pred.obs$obs)) used to group data and fit different smooths to each group.

add

Add to existing plot

smooth.args

List of arguments for loess.smooth.

STdata

STdata or STmodel containing covariates and trend against which to plot.

type

What to use in the scatter plot, valid options are "obs" for observations, "res" residuals, and "res.norm" for normalised residuals.

org.scale

TRUE/FALSE scatter plots on the original untransformed scale, or using exp(y). Only relevant if x was computed using transform in predictCV.STmodel (as pass through argument to predict.STmodel)

...

Additional parameters passed to plot.

Value

Nothing

See Also

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

Other STdata methods: createSTdata, plot.STdata, print.STdata, print.summary.STdata, qqnorm.predCVSTmodel, summary.STdata

Other STmodel methods: MCMC.STmodel, c.STmodel, createSTmodel, estimate.STmodel, estimateCV.STmodel, plot.STdata, predict.STmodel, print.STmodel, print.summary.STmodel, qqnorm.predCVSTmodel, simulate.STmodel, summary.STmodel

Examples

Run this code
# NOT RUN {
################################
## Example for STdata/STmodel ##
################################
##load data
data(mesa.model)

par(mfrow=c(2,2))
##plot observations as a function of longitude for an STmodel object
scatterPlot(mesa.model, covar="long")

##as a function of the first temporal trend, subset to only AQS sites
##and fit for each location
scatterPlot(mesa.model, trend=1, col=c(1:25,1), pch=19, cex=.1,
            group=mesa.model$obs$ID, lty=c(rep(2,25),1),
            subset=with(mesa.model$locations, ID[type=="AQS"]))

##if plotting against the distance to coast, we might have to change the
##smooting.
suppressWarnings( scatterPlot(mesa.model, covar="km.to.coast") )
##better
scatterPlot(mesa.model, covar="km.to.coast", col=c(NA,2), add=TRUE,
            smooth.args=list(span=4/5,degree=2))

##Lets group data by season
##First create a vector dividing data into four seasons
I.season <- as.factor(as.POSIXlt(mesa.model$obs$date)$mon+1)
levels(I.season) <- c(rep("Winter",2), rep("Spring",3), 
                      rep("Summer",3), rep("Fall",3), "Winter") 
scatterPlot(mesa.model, covar="log10.m.to.a1", col=c(2:5,1),
            group=I.season)
legend("bottomleft", c(levels(I.season),"All"), col=c(2:5,1), pch=1)


###############################
## Example for predCVSTmodel ##
###############################
##load data
data(pred.cv.mesa)

##simple case of residuals against temporal trends
par(mfrow=c(2,1))
scatterPlot(pred.cv.mesa, trend=1, STdata=mesa.model, type="res")

##colour coded by season
I.season <- as.factor(as.POSIXlt(pred.cv.mesa$pred.obs$date)$mon+1)
levels(I.season) <- c(rep("Winter",2), rep("Spring",3), 
                      rep("Summer",3), rep("Fall",3), "Winter") 

scatterPlot(pred.cv.mesa, trend=1, STdata=mesa.model, type="res",
            group=I.season, col=c(2:5,1), lty=c(1,1,1,1,2),
            smooth.args=list(span=.1,degree=2))
            
##or as function of covariates
par(mfcol=c(2,2))
scatterPlot(pred.cv.mesa, , type="res", covar="log10.m.to.a1",
            STdata=mesa.model, group=I.season, col=c(2:5,1))
scatterPlot(pred.cv.mesa, type="res", covar="km.to.coast",
            STdata=mesa.model, group=I.season, col=c(2:5,1),
            smooth.args=list(span=4/5,degree=1))

##let's compare to the original observations
scatterPlot(pred.cv.mesa, covar="log10.m.to.a1", STdata=mesa.model,
            group=I.season, col=c(2:5,1), type="obs")
scatterPlot(pred.cv.mesa, covar="km.to.coast", STdata=mesa.model,
            group=I.season, col=c(2:5,1), type="obs",
            smooth.args=list(span=4/5,degree=1))
# }

Run the code above in your browser using DataCamp Workspace