x=c(0.4,0.2,1.14,1.08, 1.11,1.04,1.11,1.34, 1.16,0.57,1.32,1.73, 0.88,0.8,1.38,1.55) infant = factor(rep(c(1:4),4)) week = factor(c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))) tmt = factor(c(2,3,1,4,3,4,2,1,4,1,3,2,1,2,4,3)) options(contrasts=c("contr.treatment","contr.poly")) lm.fit=lm(x~infant+week+tmt) x1=c(0.4,0.2,1.14,1.08, 1.11,1.04,1.11,1.34, 1.16,0.57,1.32,1.73, 0.88,0.8,1.38,1.55) x2 =c(1.55, 0.11, 0.22, 0.53, 0.89, 1.05, 0.96, 1.25, 0.16, 0.68, 1.45, 0.61, 0.55, 0.98, 0.82, 1.91) x3 =c(0.27, 0.50, 0.32, 0.09, 1.16, 0.70, 1.63, 0.30, 0.59, 0.93, 0.55, 1.34, 0.45, 0.96, 0.79, 1.09) x4 =c(0.73, 0.64, -0.03, 1.05, 1.21, 1.38, 1.04, 1.11, 1.21, 0.82, 0.57, 1.00, 0.77, 0.79, 0.55, 0.50) infant1 = rep(c(1:4),4) infant2 = rep(c(5:8),4) infant3 = rep(c(9:12),4) infant4 = rep(c(13:16),4) week = factor(c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))) tmt = factor(c(2,3,1,4,3,4,2,1,4,1,3,2,1,2,4,3)) x = c(x1, x2, x3, x4) week = factor(rep(week,4)) tmt = factor(rep(tmt,4)) square = factor(c(rep(1,16), rep(2,16), rep(3,16),rep(4,16))) options(contrasts=c("contr.treatment","contr.poly")) lm.fit=lm(x~square+week+tmt+square*tmt + square*week) anova(lm.fit) TTSS = 0.8616+2.4259+0.7251+1.1504+0.7546+5.9095 SSS = 0.8616 CSS = 2.4259 TSS = 0.7251 STSS = 1.1504 SCSS = 0.7546 week = factor(c(rep(1,4),rep(2,4),rep(3,4),rep(4,4))) tmt = factor(c(2,3,1,4,3,4,2,1,4,1,3,2,1,2,4,3)) infant = factor(infant1) fit =lm(x1~infant+week+tmt) anova(fit) infant = factor(infant2) fit =lm(x2~infant+week+tmt) anova(fit) infant = factor(infant3) fit =lm(x3~infant+week+tmt) anova(fit) infant = factor(infant4) fit =lm(x4~infant+week+tmt) anova(fit) RowSS = 1.44077+0.30195+0.09457+0.49673 RSS = TTSS -(RowSS+CSS+TSS+SSS+STSS+SCSS)