# Illustration of one-way layout # (cf. slides 18-20 to chapter 1) # Bread were baked from flour that were fortified with a fixed amount # of vitamines and vitamin C content (mg/100 g) was measured for two loaves # immediately after baking (group 1), after one day of storage (goup 2), and # after three days of storage (group 3). From Moore & McCabe: # Introduction to the practice of statistics, 5th edition, 2006. # Read data: group=c(1,1, 2,2, 3,3) vitc=c(47.62,49.79, 40.45,43.46, 21.25,22.34) group=factor(group) # a) fit.a=lm(vitc~group-1) summary(fit.a) Xa=model.matrix(fit.a) Xa # b) fit.b=lm(vitc~group) summary(fit.b) Xb=model.matrix(fit.b) Xb # c) newgroup=relevel(group,ref="3") fit.c=lm(vitc~newgroup) summary(fit.c) Xc=model.matrix(fit.c) Xc # d) contrasts(group)=contr.sum fit.d=lm(vitc~group) summary(fit.d) Xd=model.matrix(fit.d) Xd # e) x1=as.numeric(group==1) x2=as.numeric(group==2) x3=as.numeric(group==3) fit.e=lm(vitc~x1+x2+x3) summary(fit.e) Xe=model.matrix(fit.e) Xe