HH (version 2.2-17)

ancova: Compute and plot oneway analysis of covariance

Description

Compute and plot oneway analysis of covariance. The result object is an ancova object which consists of an ordinary aov object with an additional trellis attribute. 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.

Usage

ancova(formula, data.in = NULL, ...,
       x, groups, transpose = FALSE,
       display.plot.command = FALSE,
       superpose.level.name = "superpose",
       ignore.groups = FALSE, ignore.groups.name = "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.
## S3 method for class 'ancova':
anova(object, ...)

## S3 method for class 'ancova':
predict(object, ...)

## S3 method for class 'ancova':
print(x, ...) ## prints the anova(x) and the trellis attribute

## S3 method for class 'ancova':
model.frame(formula, ...)

## S3 method for class 'ancova':
summary(object, ...)

## S3 method for class 'ancova':
plot(x, y, ...) ## standard lm plot.  y is always ignored.

## S3 method for class 'ancova':
coef(object, ...)

## S3 method for class 'ancova':
coefficients(object, ...)

Arguments

Value

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.

Details

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.

References

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

ancova-class aov xyplot

Examples

Run this code
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)

## y ~ a * x ## save the object and print the trellis graph
hotdog.ancova <- ancova(Sodium ~ Type * Calories, data=hotdog)
attr(hotdog.ancova, "trellis")

## 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=block)

Run the code above in your browser using DataCamp Workspace