A function for adding vertical lines onto residual plots to show
95% confidence intervals of means or
95% confidence intervals for individual observations
in the classes of the
variable on the x-axis. Plot of the first type is useful for analyzing the fit of the assumed fixed part and plots of
type b can be used to analyze the homogeneity of residuals.
The variable on the x-axis. Usually one of the predictors or the predicted value.
y
The variable on the y-axis. Usually model residual.
nclass
The maximum number of classes to be used.
limits
The class limits. Alternative to nclass.
add
logical. Whether a new graphic window is opened or the lines will be added into an exosting plot.
se
Logical. Use standard errors of means (se=TRUE, option (a) above) or class-specific standard deviations
(se=FALSE, option (b) above).
main, xlab, ylab, ylim, lwd
Graphical parameters of the plot. ignored if add=TRUE.
highlight
The color for lines that do not cross the y-axis.
Details
The function first classifies the data in nclass classes of variable x.
Then the class mean and deviation s is computed for each class, where s is either
the standard error of the mean (if se=TRUE)
or standard deviation (if se=FALSE).
A vertical line is plotted at the middle of each class showing the class mean by a dot and
lines of length 3.92*s. If the line does not cross the x- axis, then the highlight color is used in the line.
With small number of observations (or lot of ties), the number of classes is decreased until
each class includes the minimum of 2 observations.
Value
The function is usually used for its side effects (i.e., the plot). However, the values used in producing
the plot are returned in a list of elements
x: the class middlepoint x values.
m: class-specific means of y.
s: class-specific standard deviations or standard errors of y (see details).
lb: lower ends of the class-specific lines.
ub: upper ends of the lines.
Author(s)
Lauri Mehtatalo
References
Mehtatalo, L. 2010. Forest biometrics with R. Lecture notes.