Re: [R] model simplification in repeated anova

From: Richard M. Heiberger <rmh_at_temple.edu>
Date: Mon 15 Jan 2007 - 17:39:09 GMT


## My previous response included only half the file.

## This is based on ?aov

## From Venables and Ripley (2002) p.165.
data(npk, package="MASS")

## as a test, not particularly sensible statistically
npk.aovE <- aov(yield ~ N*P*K + Error(block), npk)

np.k.aovE <- aov(yield ~ N*P+K + Error(block), npk)

anova(np.k.aovE, npk.aovE) ## doesn't work, as query noted

## Compare these two

summary(npk.aovE)
summary(np.k.aovE)
## The block stratum has the same total in both summaries.
## In this example, the two suppressed interactions are last and
## both are not significant.

## In order to use anova(model.1, model.2), it is necessary to
## rewrite the SAME models without the Error function.
## Use terms( , keep.order=TRUE) and the dummy variables that were
## generated in the multi-stratum model.

npk.proj <- proj(npk.aovE)
npk.x <- npk.proj$block[,"N:P:K"]

npk.aov <- aov(terms(yield ~ npk.x + block + N+P+K+N:P+N:K+P:K, keep.order=TRUE), npk)

np.k.aov <- aov(terms(yield ~ block + N+P+K+N:P, keep.order=TRUE), npk)

summary(npk.aov)
summary(np.k.aov)

anova(npk.aov, np.k.aov)



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue Jan 16 05:04:22 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 17 Jan 2007 - 15:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.