Learn R Programming

heplots (version 0.8-1)

heplot: Two-Dimensional HE Plots

Description

This function plots ellipses representing the hypothesis and error sums-of-squares-and-products matrices for terms and linear hypotheses in a multivariate linear model.

Usage

heplot(mod, ...)

## S3 method for class 'mlm':
heplot(mod, terms, hypotheses, term.labels = TRUE,
    hyp.labels = TRUE, variables = 1:2, error.ellipse = !add, 
    factor.means = !add, grand.mean = !add, remove.intercept = TRUE,
    type = c("II", "III", "2", "3"), manova, size = c("evidence", "effect.size"),
    level = 0.68, alpha = 0.05, segments = 40, center.pch = "+", col = palette()[-1], 
    lty = 2:1, lwd = 1:2, xlab, ylab, main = "", xlim, ylim, offset.axes, 
    add = FALSE, verbose = FALSE, warn.rank = FALSE, ...)

Arguments

mod
a model object of class "mlm".
terms
a logical value or character vector of terms in the model for which to plot hypothesis matrices; if missing or TRUE, defaults to all terms; if FALSE, no terms are plotted.
hypotheses
optional list of linear hypotheses for which to plot hypothesis matrices; hypotheses are specified as for the linear.hypothesis function in the car package; the list
term.labels
logical value or character vector of names for the terms to be plotted. If TRUE (the default) the names of the terms are used; if FALSE, term labels are not plotted.
hyp.labels
logical value or character vector of names for the hypotheses to be plotted. If TRUE (the default) the names of components of the list of hypotheses are used; if FALSE, hypothesis labels are not plotted.
variables
indices or names of the two response variables to be plotted; defaults to 1:2.
error.ellipse
if TRUE, plot the error ellipse; defaults to TRUE, if the argument add is FALSE (see below).
factor.means
logical value or character vector of names of factors for which the means are to be plotted, or TRUE or FALSE; defaults to TRUE, if the argument add is FALSE (see below).
grand.mean
if TRUE, plot the centroid for all of the data; defaults to TRUE, if the argument add is FALSE (see below).
remove.intercept
if TRUE (the default), do not plot the ellipse for the intercept even if it is in the MANOVA table.
type
``type'' of sum-of-squares-and-products matrices to compute; one of "II", "III", "2", or "3", where "II" is the default (and "2" is a synomym).
manova
optional Anova.mlm object for the model; if absent a MANOVA is computed. Specifying the argument can therefore save computation in repeated calls.
size
how to scale the hypothesis ellipse relative to the error ellipse; if "evidence", the default, the scaling is done so that a ``significant'' hypothesis ellipse extends outside of the error ellipse; if "effect.size"
level
equivalent coverage of ellipse for normally-distributed errors, defaults to 0.68.
alpha
signficance level for Roy's greatest-root test statistic; if size="evidence", then the hypothesis ellipse is scaled so that it just touches the error ellipse at the specified alpha level; a larger hypothesis elllipse therefore
segments
number of line segments composing each ellipse; defaults to 40.
center.pch
character to use in plotting the centroid of the data; defaults to "+".
col
a colour or vector of colours to use in plotting ellipses; the first colour is used for the error ellipse; the remaining colours --- recycled as necessary --- are used for the hypothesis ellipses; a single colour can be given, in which cas
lty
vector of line types to use for plotting the ellipses; the first is used for the error ellipse, the rest --- possibly recycled --- for the hypothesis ellipses; a single line type can be given. Defaults to 2:1.
lwd
vector of line widths to use for plotting the ellipses; the first is used for the error ellipse, the rest --- possibly recycled --- for the hypothesis ellipses; a single line width can be given. Defaults to 1:2.
xlab
x-axis label; defaults to name of the x variable.
ylab
y-axis label; defaults to name of the y variable.
main
main plot label; defaults to "".
xlim
x-axis limits; if absent, will be computed from the data.
ylim
y-axis limits; if absent, will be computed from the data.
offset.axes
proportion to extend the axes in each direction if computed from the data; optional.
add
if TRUE, add to the current plot; the default is FALSE. If TRUE, the error ellipse is not plotted.
verbose
if TRUE, print the MANOVA table and details of hypothesis tests; the default is FALSE.
warn.rank
if TRUE, do not suppress warnings about the rank of the hypothesis matrix when the ellipse collapses to a line; the default is FALSE.
...
arguments to pass down to plot, text, and points.

Value

  • The function invisibly returns an object of class "heplot", with coordinates for the various hypothesis ellipses and the error ellipse, and the limits of the horizontal and vertical axes. (No methods for manipulating these objects are currently available.)

Details

The heplot function plots a representation of the covariance ellipses for hypothesized model terms and linear hypotheses (H) and the corresponding error (E) matrices for two response variables in a multivariate linear model (mlm). The plot helps to visualize the nature and dimensionality response variation on the two variables jointly in relation to error variation that is summarized in the various multivariate test statistics (Wilks' Lambda, Pillai trace, Hotelling-Lawley trace, Roy maximum root). Roy's maximum root test has a particularly simple visual interpretation, exploited in the size="evidence" version of the plot. See the description of argument alpha. For a 1 df hypothesis term (a quantitative regressor, a single contrast or parameter test), the H matrix has rank 1 (one non-zero latent root of $H E^{-1}$) and the H ellipse collapses to a line. Typically, you fit a mlm with mymlm <- lm(cbind(y1, y2, y3, ...) ~ modelterms), and plot some or all of the modelterms with heplot(mymlm, ...).

References

Friendly, M. (2006). Data Ellipses, HE Plots and Reduced-Rank Displays for Multivariate Linear Models: SAS Software and Examples Journal of Statistical Software, 17(6), 1-42. http://www.jstatsoft.org/v17/i06/ Friendly, M. (2007). HE plots for Multivariate General Linear Models. Journal of Computational and Graphical Statistics, 16, in press. http://www.math.yorku.ca/SCS/Papers/heplots.pdf

See Also

Anova, linear.hypothesis, heplot3d, pairs.mlm.

Examples

Run this code
## iris data
iris.mod <- lm(cbind(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) ~
Species, data=iris)

heplot(iris.mod)
heplot(iris.mod, variables=c(1,3))
pairs(iris.mod)

## Pottery data, from cars package
data(Pottery)
pottery.mod <- lm(cbind(Al, Fe, Mg, Ca, Na) ~ Site, data=Pottery)
heplot(pottery.mod)
heplot(pottery.mod, terms=FALSE, add=TRUE, col="blue", 
  hypotheses=list(c("SiteCaldicot = 0", "SiteIsleThorns=0")),
  hyp.labels="Sites Caldicot and Isle Thorns")

## Rohwer data, multivariate multiple regression/ANCOVA
#-- ANCOVA, assuming equal slopes
rohwer.mod <- lm(cbind(SAT, PPVT, Raven) ~ SES + n + s + ns + na + ss, data=Rohwer)
Anova(rohwer.mod)
heplot(rohwer.mod)
# Add ellipse to test all 5 regressors
heplot(rohwer.mod, hypotheses=list("Regr" = c("n", "s", "ns", "na", "ss")))
# View all pairs
pairs(rohwer.mod, hypotheses=list("Regr" = c("n", "s", "ns", "na", "ss")))
# or 3D plot
 heplot3d(rohwer.mod, hypotheses=list("Regr" = c("n", "s", "ns", "na", "ss")))

Run the code above in your browser using DataLab