predictPlot {NCStats}R Documentation

Shows the predicted value and interval on a fitted line plot.

Description

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.

Usage

predictPlot(...)

predictionPlot(mdl, newdata, interval = "prediction", conf.level = 0.95,
  lty = 1, lwd = 3, legend = "topright", ...)

Arguments

...

Other arguments to the fitPlot function. For example, include legend=TRUE to include a legend on the fitted line plot for an IVR.

mdl

an lm or nls object (i.e., returned from fitting a model with either lm or nls)

newdata

A data frame in which to look for variables with which to predict. This cannot be omitted as it is with predict

interval

a string indicating whether to plot confidence (="confidence") or prediction (="prediction") intervals

conf.level

a decimal numeric indicating the level of confidence to use for confidence and prediction intervals (default is 0.95)

lty

a numeric indicating the type of line used for representing the intervals (see par)

lwd

a numeric indicating the width of line used for representing the intervals (see par)

legend

Controls use and placement of the legend (see details in fitPlot)

Details

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().

Value

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.

See Also

predict specifically predict.lm and fitPlot from FSA.

Examples

lm1 <- lm(Sepal.Length~Petal.Length*Species,data=iris)
lm2 <- lm(Sepal.Length~Petal.Length+Species,data=iris)
lm3 <- lm(Sepal.Length~Petal.Length,data=iris)
op <- par(mfrow=c(2,2),mar=c(3,3,2,1),mgp=c(2,0.7,0))
newdf <- data.frame(Petal.Length=c(2,4),Species=c("setosa","versicolor"))
predictionPlot(lm1,newdf,legend="topleft")
predictionPlot(lm2,newdf,legend="topleft")
predictionPlot(lm3,newdf)
predictionPlot(lm3,newdf,interval="confidence")
par(op)


[Package NCStats version 0.4.7 Index]