Learn R Programming

alr3 (version 1.1.12)

mmps: Marginal model plot

Description

For a regression object, plots the response on the vertical axis versus a linear combination $u$ of terms in the mean function on the horizontal axis. Added to the plot are a loess smooth for the graph, along with a loess smooth from the plot of the fitted values on $u$.

Usage

mmps(object,vars=~.,fitted=TRUE,layout=NULL,ask,...)

## S3 method for class 'lm':
mmp(object, u , mean = TRUE, sd = FALSE, 
   xlab = deparse(substitute(u)), degree = 1, span = 2/3,key="topleft", 
   lineColors = c("blue", "red"), ...)
   
## S3 method for class 'glm':
mmp(object, u, mean = TRUE, sd = FALSE, 
   xlab = deparse(substitute(u)), degree = 1, span = 2/3,key="topleft", 
   lineColors = c("blue", "red"), ...)

Arguments

object
A regression object, of type either lm or glm, for which there is a predict method defined.
vars
A one-sided formula. A marginal model plot will be drawn for each variable on the right-side of this formula that is not a factor. The default is ~., which specifies that all the terms in formula(object will be used.
fitted
If the default TRUE, then a marginal model plot in the direction of the fitted values or linear predictor of a generalized linear model will be drawn.
layout
A reasonable layout for the plots in the window is determined by the program. If you don't like the default you can set your own layout: c(2,3) means two rows and three columns.
ask
If TRUE, ask before clearing the graph window to draw more plots.
...
Additional arguments passed from mmps to mmp and then to plot. Users should generally use mmps.
u
The quantity to be plotted on the horizontal axis. The default is the predicted values predict(object). Can be any other vector of length equal to the number of observations in the object.
mean
If TRUE, compare mean smooths
sd
If TRUE, compare sd smooths
xlab
label for horizontal axis
degree
Degree of the local polynomial, passed to loess. The usual default for loess is 2, but the default here is 1.
span
Span, the smoothing parameter for loess.
key
If not NULL, this gives the location of the legend, chosen from the default "topleft", or "bottomleft","bottomright" or "topright".
lineColors
colors for data and model smooth, respectively

Value

  • Used for its side effect of producing plots.

Details

mmp draws one marginal model plot. mmps draws all marginal model plots, versus each of the terms in the model and versus fitted values. mmps should not be used if some of the terms in the model are factors or interactions.

References

S. Weisberg (2005), Applied Linear Regression, third edition, Wiley, Chapter 8

See Also

loess, plot

Examples

Run this code
data(ufcwc)
c1 <- lm(Height ~ Dbh, ufcwc)
mmp(c1, ufcwc$Dbh, xlab="Diameter, Dbh", lineColors=c("black", "black"))
mmps(c1)

Run the code above in your browser using DataLab