Description Usage Arguments Details Value Author(s) References See Also Examples
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  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,
pch=trellis.par.get()$superpose.symbol$pch)
panel.ancova(x, y, subscripts, groups,
transpose = FALSE, ...,
coef, contrasts, classes,
ignore.groups, blocks, blocks.pch, blocks.cex, pch)
## 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, ...)

formula 
A formula specifying the model. 
data.in 
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 
x 
Covariate in 
groups 
Factor. Needed for plotting when the formula does not
include 
transpose 
SPlus: 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. 
display.plot.command 
The default setting is usually what the user
wants. The alternate value 
superpose.level.name 
Name used in strip label for superposed panel. 
ignore.groups 
When 
ignore.groups.name 
Name used in strip label for

pch 
Plotting character for groups. 
blocks 
Additional factor used to label points in the panels. 
blocks.pch 
Alternate set of labels used when a 
blocks.cex 
Alternate set of 
layout 
The layout of multiple panels. The default is a single row. See details. 
between 
Space between the panels for the individual group levels and the superpose panel including all groups. 
main 
Character with a main header title to be done on the top of each page. 
y,subscripts 
In 
object 
An 
object. The functions using this argument are methods for the similarly named generic functions.
coef, contrasts, classes 
Internal variables used to communicate between

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.
Richard M. Heiberger <rmh@temple.edu>
Heiberger, Richard M. and Holland, Burt (2015). Statistical Analysis and Data Display: An Intermediate Course with Examples in R. Second Edition. SpringerVerlag, New York. https://www.springer.com/us/book/9781493921218
ancovaclass
aov
xyplot
.
See ancovaplot
for a newer set of functions that keep the
graph and the aov
object separate.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  data(hotdog)
## 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
data(apple)
ancova(yield ~ treat + pre, data=apple, blocks=block)
## Please see
## demo("ancova")
## for a composite graph illustrating the four models listed above.

Loading required package: lattice
Loading required package: grid
Loading required package: latticeExtra
Loading required package: RColorBrewer
Loading required package: multcomp
Loading required package: mvtnorm
Loading required package: survival
Loading required package: TH.data
Loading required package: MASS
Attaching package: 'TH.data'
The following object is masked from 'package:MASS':
geyser
Loading required package: gridExtra
Analysis of Variance Table
Response: Sodium
Df Sum Sq Mean Sq F value Pr(>F)
Calories 1 106270 106270 14.515 0.0003693 ***
Residuals 52 380718 7321

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table
Response: Sodium
Df Sum Sq Mean Sq F value Pr(>F)
Type 2 31739 15869.4 1.7778 0.1793
Residuals 51 455249 8926.4
Analysis of Variance Table
Response: Sodium
Df Sum Sq Mean Sq F value Pr(>F)
Calories 1 106270 106270 34.654 3.281e07 ***
Type 2 227386 113693 37.074 1.336e10 ***
Residuals 50 153331 3067

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table
Response: Sodium
Df Sum Sq Mean Sq F value Pr(>F)
Type 2 31739 15869 5.1749 0.009065 **
Calories 1 301917 301917 98.4526 2.089e13 ***
Residuals 50 153331 3067

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table
Response: Sodium
Df Sum Sq Mean Sq F value Pr(>F)
Calories 1 106270 106270 35.6885 2.747e07 ***
Type 2 227386 113693 38.1815 1.195e10 ***
Calories:Type 2 10402 5201 1.7466 0.1853
Residuals 48 142930 2978

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table
Response: Sodium
Df Sum Sq Mean Sq F value Pr(>F)
Type 2 31739 15869 5.3294 0.008124 **
Calories 1 301917 301917 101.3927 2.019e13 ***
Type:Calories 2 10402 5201 1.7466 0.185267
Residuals 48 142930 2978

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Variance Table
Response: yield
Df Sum Sq Mean Sq F value Pr(>F)
treat 5 750 150 0.1486 0.9777
pre 1 54142 54142 53.6893 1.181e06 ***
Residuals 17 17143 1008

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.