Learn R Programming

SpatioTemporal (version 1.1.7)

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

type

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

STdata

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

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)

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.

...

Additional parameters passed to plot.

Value

Nothing

See Also

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

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

Other STmodel methods: c.STmodel, createSTmodel, estimate, estimate.STmodel, estimateCV, estimateCV.STmodel, MCMC, MCMC.STmodel, plot.STdata, plot.STmodel, predict.STmodel, predictCV, predictCV.STmodel, print.STmodel, print.summary.STmodel, qqnorm.predCVSTmodel, qqnorm.STdata, qqnorm.STmodel, 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 DataLab