| predictPlot {NCStats} | R Documentation |
Shows the predicted value and interval on a fitted line plot. This function is used to illustrate predictions with SLR or IVR models and to show distinctions between confidence and prediction intervals.
predictPlot(...)
predictionPlot(mdl, newdata, interval = "prediction",
conf.level = 0.95, lty = 1, lwd = 3, ...)
mdl |
an |
newdata |
A data frame in which to look for
variables with which to predict. This cannot be omitted
as it is with |
interval |
a string indicating whether to plot
confidence ( |
conf.level |
a decimal numeric indicating the level
of confidence to use for confidence and prediction
intervals. Default is |
lty |
a numeric indicating the type of line used for
representing the intervals. See |
lwd |
a numeric indicating the width of line used
for representing the intervals. See |
... |
Other arguments to the |
This function produces a fitted line plot with both
confidence and prediction bands shown. It then
constructs vertical bars representing the predicted
values with the corresponding interval (chosen with
interval) for all observations found in
newdata.
This function is only appropriate for SLR and IVR with a single quantitative covariate and two or fewer factors.
The predictPlot() is just a pass-through to
predictionPlot().
A data frame is returned that contains the number of the
new observation (for comparison to the graphic that is
produced), the values of the variables in newdata,
and the predicted values at those observed values.
predict specifically predict.lm and
fitPlot from FSA.
require(FSAdata) # for Mirex data
data(Mirex)
Mirex$year <- factor(Mirex$year)
lm2a <- lm(mirex~weight*species,data=Mirex)
lm3a <- lm(mirex~weight+species,data=Mirex)
lm4 <- lm(mirex~weight,data=Mirex)
op <- par(mfrow=c(2,2),mar=c(3,3,2,1),mgp=c(2,0.7,0))
newdf <- data.frame(weight=c(2,10),species=c("chinook","coho"),year=c("1977","1992"))
predictionPlot(lm2a,newdf,legend=c(0,0.47))
predictionPlot(lm3a,newdf,legend=c(0,0.47))
predictionPlot(lm4,newdf)
predictionPlot(lm4,newdf,interval="c")
par(op)