# Random data
dat <- data.frame(A = factor(rep(c(1,2),32)),
B = factor(rep(c(1,1,2,2),16)),
C = factor(rep(c(1,1,1,1,2,2,2,2),8)),
Ind = factor(rep(c(1,1,1,1,2,2,2,2),8)),
D = factor(rep(c(rep(1,8),rep(2,8)),4)),
E = factor(rep(c(rep(1,16),rep(2,16)),2)))
dat$y = rnorm(64)
# Linear model with interactions and nested factors
mod <- lm(y~A*B*C + D + E%in%D, data=dat)
(an <- Anova(mod, type="II"))
H <- hasseMod(mod)
if (FALSE) # Requires installation of Rgraphviz
library(Rgraphviz)
hasse(H$hasse, parameters=list(cluster = FALSE, arrows = "none", edgeColor = "darkred"))
# Linear model with repeated measures where Ind is nested in A
modv <- lm(y~A*r(B) + r(Ind), data=dat)
(anv <- Anova(mod, type="II"))
Hv <- hasseMod(modv, manualTerms=c("Ind"), manualParents=list(c("A")))
if (FALSE) # Requires installation og Rgraphviz
hasse(Hv$hasse, parameters=list(cluster = FALSE, arrows = "none", edgeColor = "darkred"))
Run the code above in your browser using DataLab