| aov.sufficient {HH} | R Documentation |
Analysis of variance from sufficient statistics for groups.
For each group, we need the factor level, the response mean, the
within-group standard deviation, and the sample size.
The correct ANOVA table is produced. The residuals are fake.
The generic vcov and summary.lm don't work for the
variance of the regression coefficients in this case.
Use vcov.sufficient.
aov.sufficient(formula, data = NULL,
projections = FALSE, qr = TRUE, contrasts = NULL,
weights = data$n, sd = data$s,
...)
vcov.sufficient(object, ...)
formula, data, projections, qr, contrasts, ... |
See
aov in R, aov in S-Plus. |
weights |
See lm in R, lm in S-Plus. |
sd |
vector of within-group standard deviations. |
object |
"aov" object constructed by
aov.sufficient. It also works with regular aov objects.
|
For aov.sufficient, an object of class c("aov", "lm").
For vcov.sufficient, a function that returns the covariance
matrix of the regression coefficients.
The residuals are fake. They are all identical and equal to the MLE
standard error (sqrt(SumSq.res/df.tot)). They give the right
ANOVA table. They may cause confusion or warnings in other programs.
The standard errors and t-tests of the coefficients are not calculated
by summary.lm.
Using the aov object from aov.sufficient in glht
requires the vcov. and df arguments.
Richard M. Heiberger <rmh@temple.edu>
MMC and aov in R,
aov in S-Plus.
## This example is from Hsu and Peruggia
## This is the R version
## See ?aov.sufficient for S-Plus
if.R(s={},
r={
pulmonary <- read.table(hh("datasets/pulmonary.dat"), header=TRUE,
row.names=NULL)
names(pulmonary)[3] <- "FVC"
names(pulmonary)[1] <- "smoker"
pulmonary$smoker <- factor(pulmonary$smoker, levels=pulmonary$smoker)
row.names(pulmonary) <- pulmonary$smoker
pulmonary
pulmonary.aov <- aov.sufficient(FVC ~ smoker,
data=pulmonary)
summary(pulmonary.aov)
pulmonary.mca <- glht(pulmonary.aov,
linfct=mcp(smoker="Tukey"),
df=pulmonary.aov$df.residual,
vcov.=vcov.sufficient)
plot(pulmonary.mca)
pulm.lmat <- cbind("npnl-mh"=c( 1, 1, 1, 1,-2,-2), ## not.much vs lots
"n-pnl" =c( 3,-1,-1,-1, 0, 0), ## none vs light
"p-nl" =c( 0, 2,-1,-1, 0, 0), ## {} arbitrary 2 df
"n-l" =c( 0, 0, 1,-1, 0, 0), ## {} for 3 types of light
"m-h" =c( 0, 0, 0, 0, 1,-1)) ## moderate vs heavy
dimnames(pulm.lmat)[[1]] <- row.names(pulmonary)
if.R(r=pulm.lmat <- rbind(Int=0, pulm.lmat[-1,]),
s={})
pulm.lmat
pulmonary.mmc <- glht.mmc(pulmonary.aov,
linfct=mcp(smoker="Tukey"),
df=pulmonary.aov$df.residual,
vcov.=vcov.sufficient,
lmat=pulm.lmat,
calpha=attr(confint(pulmonary.mca)$confint,"calpha"))
plot(pulmonary.mmc, print.mca=TRUE, print.lmat=FALSE)
## tiebreaker plot, with contrasts ordered to match MMC plot,
## with all contrasts forced positive and with names also reversed,
## and with matched x-scale.
plot(confint(as.glht(pulmonary.mmc$mca)),
xlim=par()$usr[1:2], xaxs="i",
main="", xlab="")
## orthogonal contrasts
plot(pulmonary.mmc, print.lmat=TRUE, col.lmat.signif='blue', col.iso='gray')
## pairwise and orthogonal contrasts on the same plot
plot(pulmonary.mmc, print.mca=TRUE, print.lmat=TRUE,
col.mca.signif='red', col.lmat.signif='blue', col.iso='gray',
lty.lmat.not.signif=2)
})