Compute and plot oneway analysis of covariance

models, hplot, regression, dplot
ancova(formula, = sys.parent(), ...,
       x, groups, transpose = FALSE,
       display.plot.command = FALSE, = "superpose",
       ignore.groups = FALSE, = "ignore.groups",
       blocks, blocks.pch = letters[seq(levels(blocks))],
       layout, between, main)

panel.ancova(x, y, subscripts, groups,
 transpose = FALSE, ...,
 coef, contrasts, classes,
 ignore.groups, blocks, blocks.pch, blocks.cex)

## The following are ancova methods for generic functions.
anova.ancova(object, ...)

predict.ancova(object, ...)

print.ancova(x, ...)

model.frame.ancova(formula, ...)

summary.ancova(object, ...)

plot.ancova(x, ...)

coef.ancova(object, ...)

coefficients.ancova(object, ...)
A formula specifying the model.
A data frame in which the variables specified in the formula will be found. If missing, the variables are searched for in the standard way.
Arguments to be passed to aov, such as subset or na.action.
Covariate in ancova, needed for plotting when the formula does not include x. "aov" object in print.ancova, to match the argument of the print generic function. Variable to plo
Factor. Needed for plotting when the formula does not include groups after the conditioning bar "|".
S-Plus: The axes in each panel of the plot are transposed. The analysis is identical, just the axes displaying it have been interchanged. R: no effect.
The default setting is usually what the user wants. The alternate value TRUE prints on the console the command that draws the graph. This is strictly for debugging the ancova command.
Name used in strip label for superposed panel.
When TRUE, an additional panel showing all groups together with a common regression line is displayed.
Name used in strip label for ignore.groups panel.
Additional factor used to label points in the panels.
Alternate set of labels used when a blocks factor is specified.
Alternate set of cex used when a blocks factor is specified.
The layout of multiple panels. The default is a single row. See details.
Space between the panels for the individual group levels and the superpose panel including all groups.
Character with a main header title to be done on the top of each page.
In "panel.ancova", see panel.xyplot in R and both xyplot and trellis.args in S-Pl
An "aov"
coef, contrasts, classes
Internal variables used to communicate between ancova and panel.ancova. They keep track of the constant or different slopes and intercepts in each panel of the plot.

The ancova function does two things. It passes its arguments directly to the aov function and returns the entire aov object. It also rearranges the data and formula in its argument and passes that to the xyplot function. The trellis attribute is a trellis object consisting of a series of plots of y ~ x. The left set of panels is conditioned on the levels of the factor groups. The right panel is a superpose of all the groups.


  • The result object is an ancova object which consists of an ordinary aov object with an additional trellis attribute. The default print method is to print both the anova of the object and the trellis attribute.


Heiberger, Richard~M. and Holland, Burt (2004b). Statistical Analysis and Data Display: An Intermediate Course with Examples in S-Plus, R, and SAS. Springer Texts in Statistics. Springer. ISBN 0-387-40270-5.

See Also

aov xyplot

  • ancova
  • analysis of covariance
  • covariance
  • anova.ancova
  • predict.ancova
  • print.ancova
  • model.frame.ancova
  • summary.ancova
  • plot.ancova
  • coef.ancova
  • coefficients.ancova
  • panel.ancova
hotdog <- read.table(hh("datasets/hotdog.dat"), header=TRUE)

## y ~ x                     ## constant line across all groups
ancova(Sodium ~ Calories,     data=hotdog, groups=Type)

## y ~ a                     ## different horizontal line in each group
ancova(Sodium ~            Type, data=hotdog, x=Calories)

## This is the usual usage
## y ~ x + a  or  y ~ a + x  ## constant slope, different intercepts
ancova(Sodium ~ Calories + Type, data=hotdog)
ancova(Sodium ~ Type + Calories, data=hotdog)

## y ~ x * a  or  y ~ a * x  ## different slopes, and different intercepts
ancova(Sodium ~ Calories * Type, data=hotdog)
ancova(Sodium ~ Type * Calories, data=hotdog)

## label points in the panels by the value of the block factor
apple <- read.table(hh("datasets/apple.dat"), header=TRUE)
apple$treat <- factor(apple$treat)
contrasts(apple$treat) <- contr.treatment(6)
apple$block <- factor(apple$block)
ancova(yield ~ treat + pre, data=apple, blocks=apple$block)
Documentation reproduced from package HH, version 1.8, License: GPL version 2 or newer

Community examples

Looks like there are no examples yet.