plot.glmssn.predict: Plot glmssn.predict Objects

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/plot.glmssn.predict.R

Description

plot.glmssn.predict is a generic plot function that has been adapted for objects of class glmssn.predict.

Usage

1
2
3
4
5
## S3 method for class 'glmssn.predict'
plot(x, VariableName = NULL, VarPlot = "Both",
color.palette = rainbow(nclasses, start = 0.66, end = 0.99), nclasses =
10, breaktype = "quantile", dec.dig = 2, SEcex.min = 0.5, SEcex.max = 2,
brks = NULL, add = FALSE, ...)

Arguments

x

an object of class glmssn.predict

VariableName

name of variable to be plotted

VarPlot

a character argument that must be one of "Both", "Predictions", or "Standard Errors". Default is "Both", which colors predictions by their values and makes their size inversely proportional to the prediction standard errors.

breaktype

the method for breaking the predictions (or standard errors) into classes for coloring while plotting. A character argument that must be one of "quantile" (default), "even", or "user".

brks

if breaktype = "user", the break values must be specified here as a vector or matrix using c(...) or cbind(...). The sorted unique values are used as break points (together with the min and max of the variable being plotted if required)

nclasses

the number of classes for coloring the predictions (or standard errors) according to their value. The default is 10. If brks = c(...) is specified, then nclasses is automatically set to the number of breaks + 1.

color.palette

a color palette for plotting points. The default is rainbow(nclasses, start = .66, end = .99). The number of colors should equal to the number of classes. See palette for many ways to create palettes.

SEcex.min

if VarPlot = "both", the minimum cex value when making point sizes is inversely proportional to the prediction standard errors. See par for more on cex. Also see details below. Default is 1.

SEcex.max

if VarPlot = "both", the maximum cex value when making point sizes inversely proportional to the prediction standard errors. See par for more on cex. Also see details below. Default is 3.

dec.dig

the number of decimal places to print in the legend. Default is 2.

add

Logical value indicating whether the predictions should be added to an existing plot, such as a plot of colored values for observed data. Default is FALSE.

...

Arguments to be passed to methods, such as graphical parameters (see par).

Details

The plot.glmssn.predict function creates a map showing color-coded predictions or prediction standard error values. When VarPlot = "Both", predictions values are colored according to breaks. The size of the points is inversely proportional to the prediction standard errors. If SE is the standard error for a prediction, then the size of the plotted point will be SEcex.max - (SEcex.max - SEcex.min)*(SE - min(SE))/(max(SE) - min(SE)), where mins and maxs are over all SEs in the prediction set. This is simply a linear interpolator between SEcex.max and SEcex.min, specified by the user, with larger points for smaller standard errors. So large points reflect the fact that you have more confidence in those values and small points reflect the fact that you have less confidence in the values. Two plot legends are included in this case - one based on size and one on colour.

If the predictions are added to an existing plot, the printing of a second legend is suppressed, but the minimum predicted value is added as text to the top of the legend area, and the maximum predicted value is added as text to the bottom of the legend area. This option only makes sense if the breaks are matched to those when plotting the observed values. See the example below.

Value

Maps of stream networks with prediction and prediction standard error values.

Author(s)

Jay Ver Hoef support@SpatialStreamNetworks.com

See Also

predict

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
library(SSN)
#for examples, copy MiddleFork04.ssn directory to R's temporary directory
copyLSN2temp()
# NOT RUN
# Create a SpatialStreamNetork object that also contains prediction sites
#mf04p <- importSSN(paste0(tempdir(),'/MiddleFork04.ssn'), 
#  predpts = "pred1km", o.write = TRUE)
#use mf04p SpatialStreamNetwork object, already created
data(mf04p)
#for examples only, make sure mf04p has the correct path
#if you use importSSN(), path will be correct
mf04p <- updatePath(mf04p, paste0(tempdir(),'/MiddleFork04.ssn'))

# get some model fits stored as data objects
data(modelFits)
#NOT RUN use this one
#fitSp <- glmssn(Summer_mn ~ ELEV_DEM + netID,
#    ssn.object = mf04p, EstMeth = "REML", family = "Gaussian",
#    CorModels = c("Exponential.tailup","Exponential.taildown",
#    "Exponential.Euclid"), addfunccol = "afvArea")
#for examples only, make sure fitSp has the correct path
#if you use importSSN(), path will be correct
fitSp$ssn.object <- updatePath(fitSp$ssn.object, 
	paste0(tempdir(),'/MiddleFork04.ssn'))

# NOT RUN
# make sure the distance matrix is there
# createDistMat(mf04p, predpts = "pred1km", o.write = TRUE)

## create predictions
ssnpred <- predict(fitSp, "pred1km")

##default graph
plot(ssnpred)

## max maximum size smaller
plot(ssnpred, SEcex.max = 1.5)

## predictions only
plot(ssnpred, VarPlot = "Predictions", breaktype = "quantile")

## change line width
plot(ssnpred, VarPlot = "Predictions", breaktype = "quantile", lwd = 2)

## change line type
plot(ssnpred, VarPlot = "Predictions", breaktype = "quantile", lwd = 2, lty = 2)

## standard errors only
plot(ssnpred, VarPlot = "Standard Errors", breaktype = "quantile")

## use even spacing for breaks
plot(ssnpred, VarPlot = "Standard Errors", breaktype = "even")

## use custom breaks and colors - specify four break points and four
## colours, but the actual range of standard errors requires a fifth break
## point and a fifth colour (see legend on RHS) chosen by default
plot(ssnpred, VarPlot = "Standard Errors", breaktype = "user",
 brks = seq(0,2.4,by=0.6), color.palette = c("darkblue", "purple",
   "green", "red"))

## add predictions to colored observations
brks <- as.matrix(plot(fitSp$ssn.object, "Summer_mn", cex = 2))
plot(ssnpred, add = TRUE, breaktype = "user", brks = brks, nclasses=length(brks),
    SEcex.max = 1)

SSN documentation built on March 13, 2020, 1:49 a.m.