#read in just first sixteen rows cards=read.table("cards.txt",header=T,nrows=16) #re-code the throwers to be numeric cards$thr=-1*(cards$thrower=="Valerie")+1*(cards$thrower=="Thy") attach(cards) #plot main effects par(mfrow=c(2,2)) boxplot(dis~angle,ylab="distance",xlab="angle") boxplot(dis~vel,ylab="distance",xlab="velocity") boxplot(dis~grip,ylab="distance",xlab="grip") boxplot(dis~thr,ylab="distance",xlab="thrower") par(mfrow=c(1,1)) #find effects 2*coef(lm(dis~angle*vel*grip*thr)) #how can we tell which are significant? #first try assuming all third and higher order intractions are zero # (these are elements 12-16 of the coefficient vector) cards.se=sqrt(mean((2*coef(lm(dis~angle*vel*grip*thr))[12:16])^2)) cards.se cards.se*qt(.975,5) #another possible assumption is that most of the effects are zero qqnorm(2*coef(lm(dis~angle*vel*grip*thr))[2:16]) qqline(2*coef(lm(dis~angle*vel*grip*thr))[2:16]) sort(2*coef(lm(dis~angle*vel*grip*thr))[2:16]) #fitted model is dis = 84.7 + 27.8*angle + 37.1*thr + 27.7*angle*thr #fitted value for Thy throwing at a high angle: 84.7+27.8+37.1+27.7=177.3 #fitted value for Valerie throwing at high angle: 84.7+27.8-37.1-27.7=47.7 #all fitted values fitted(lm(dis~angle*thr)) #basically we can't see a significant difference in how Valerie throws cards, # but Thy throws them much better at a higher angle