WeightLoss {heplots} | R Documentation |
Contrived data on weight loss and self esteem over three months, for three groups of individuals: Control, Diet and Diet + Exercise. The data constitute a double-multivariate design.
data(WeightLoss)
A data frame with 34 observations on the following 7 variables.
group
Control
Diet
DietEx
.wl1
wl2
wl3
se1
se2
se3
Helmert contrasts are assigned to group
, comparing Control
vs. (Diet
DietEx
)
and Diet
vs. DietEx
.
Originally taken from http://www.csun.edu/~ata20315/psy524/main.htm, but modified slightly
data(WeightLoss) str(WeightLoss) table(WeightLoss$group) contrasts(WeightLoss$group) <- matrix(c(-2,1,1, 0, -1, 1),ncol=2) (wl.mod<-lm(cbind(wl1,wl2,wl3,se1,se2,se3)~group, data=WeightLoss)) heplot(wl.mod, hypotheses=c("group1", "group2")) pairs(wl.mod, variables=1:3) pairs(wl.mod, variables=4:6) # within-S variables within <- data.frame(measure=rep(c("Weight loss", "Self esteem"),each=3), month=rep(ordered(1:3),2)) # not-quite-right doubly multivariate Anova Anova(wl.mod, idata=within, idesign=~measure*month) # do the correct analysis 'manually' unit <- function(n, prefix="") { J <-matrix(rep(1, n), ncol=1) rownames(J) <- paste(prefix, 1:n, sep="") J } measure <- kronecker(diag(2), unit(3, 'M')/3, make.dimnames=TRUE) colnames(measure)<- c('WL', 'SE') between <- as.matrix(WeightLoss[,-1]) between.mod <- lm(between ~ group, data=WeightLoss) Anova(between.mod) heplot(between.mod, hypotheses=c("group1", "group2"), xlab="Weight Loss", ylab="Self Esteem", col=c("red", "blue", "brown"), main="Weight Loss & Self Esteem: Group Effect") month <- kronecker(diag(2), poly(1:3), make.dimnames=TRUE) colnames(month)<- c('WL', 'SE') trends <- as.matrix(WeightLoss[,-1]) within.mod <- lm(trends ~ group, data=WeightLoss) Anova(within.mod) heplot(within.mod) heplot(within.mod, hypotheses=c("group1", "group2"), xlab="Weight Loss", ylab="Self Esteem", type="III", remove.intercept=FALSE, term.labels=c("month", "group:month"), main="Weight Loss & Self Esteem: Within-S Effects") mark.H0()