Learn R Programming

SpatioTemporal (version 1.1.2)

plot.STdata: Different Plots for STdata/STmodel object

Description

plot method for class STdata or STmodel. Provides several different plots of the data. When calles for STmodel, STmodel$locations acts as STdata$covars.

Usage

## S3 method for class 'STdata':
plot(x, y = "obs", ID = x$covars$ID[1],
    type = x$covars$type, col = NULL, pch = 19, cex = 0.1,
    legend.loc = "topleft", legend.names = NULL,
    add = FALSE, ...)

## S3 method for class 'STmodel': plot(x, y = "obs", ID = x$locations$ID[1], type = x$locations$type, ...)

Arguments

x
STdata/STmodel object to plot.
y
Type of plot, options are "obs", "res", "acf", "pacf", "loc", or "loc.obs", see details below.
ID
The location for which we want to plot observations. Either a string matching the names in x$covars$ID or an integer; if an integer the functions will plot data from ID=x$covars$ID[ID].
type
Factorial of length(x$covars$ID), used by "loc" and for "loc.obs" to determine how many groups should be plotted and colour/type coded.
col,pch
Colour and size of points for "loc" and "loc.obs", either one constant or a vector or length(levels(type)).
cex
Size of points for "loc" and "loc.obs".
legend.loc
The location of the legend, for "loc" and "loc.obs". See legend.
legend.names
A vector of character strings to be used in the legend, for "loc" and for "loc.obs"
add
Add to existing plot, only relevant if y is "obs", "res", "loc", or "loc.obs".
...
Additional parameters passed to plot, acf, or pacf,

Value

  • Nothing

Details

Performs a variety of different plots determined by y: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

For y=c("loc","loc.obs") a legend is added if legend.loc!=NULL. The vector legend.names should have length equal to the number of unique location types. The default legend names are levels(type). The function uses col=1:length(levels(type)) if col=NULL.

See Also

Other STdata methods: createSTdata, print.STdata, print.summary.STdata, summary.STdata

Other STmodel methods: createSTmodel, c.STmodel, estimateCV.STmodel, estimate.STmodel, MCMC.STmodel, predictCV.STmodel, predict.STmodel, print.STmodel, print.summary.STmodel, simulate.STmodel, summary.STmodel

Examples

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

##default plot
plot(mesa.data)

##plot monitor locations
plot(mesa.data, "loc")

##different names/colours/etc
plot(mesa.data, "loc", main="A nice plot", col=c("green","blue"),
    legend.names=c("Sites of one type", "..and of the other"),
    legend.loc="bottomleft")

##composite time-trend
plot(mesa.data, "loc.obs", legend.loc="bottomleft", cex=.5, pch=c(3,4))

##plot tim-series for the first site,
par(mfrow=c(4,1),mar=c(2.5,2.5,3,1))
plot(mesa.data, "obs", ID=1)
##residuals from the temporal trends,
plot(mesa.data, "res", ID=1)
##afc 
plot(mesa.data, "acf", ID=1)
##... and pafc for the residuals
plot(mesa.data, "pacf", ID=1)

##Same as above but calling the 2nd site by name
par(mfrow=c(4,1),mar=c(2.5,2.5,3,1))
plot(mesa.data, "obs", ID="60370016")
plot(mesa.data, "res", ID="60370016")
plot(mesa.data, "acf", ID="60370016")
plot(mesa.data, "pacf", ID="60370016")

##same, but with no temporal trend, first replace the trend with a constant
mesa.data <- updateSTdataTrend(mesa.data, n.basis=0)

par(mfrow=c(4,1),mar=c(2.5,2.5,3,1))
plot(mesa.data, "obs", ID="60370016")
plot(mesa.data, "res", ID="60370016")
plot(mesa.data, "acf", ID="60370016")
plot(mesa.data, "pacf", ID="60370016")

Run the code above in your browser using DataLab