Skip to content
Prev 307424 / 398506 Next

car::linearHypothesis Sum of Sqaures Error?

John,

Thank you for the reply.

The data are balanced; I double-checked. I believe the contrasts are orthogonal. Sum of squares in summary(aov) with the contrasts split out add to the main effect. I am still unsure of where the error is for the sum of squares calculation.

I have written some code with a parallel model structure that may help (see below).

Can linearHypothesis return type II tests? It seems to only return type III with no option to set 'type'.

Cheers,
John

y<-runif(36,0,100)
block<-factor(rep(c("A","B","C"),each=12))
a<-factor(rep(c("A","B"),times=3,each=6))
b<-factor(rep(c("A","B"),times=6,each=3))
c<-factor(rep(c("A","B","C"),times=12,each=1))
covar<-0.6*y+rnorm(36,10,25)
data<-data.frame(y,block,a,b,c,covar)

c_contrasts<-matrix(c(-1,2,-1,1,0,-1),3,2)
dimnames(c_contrasts)<-list(levels(data$c),c("B vs. A&C","A vs. C"))
contrasts(data$c)<-c_contrasts

model<-lm(y~block+a*b*c+covar,data=data)
summary.aov(model,split=list(c=list("B vs. A&C"=1,"A vs. C"=2)))
#Sum of squares add here, but factorial ANCOVA non-orthogonal in type I SS

Anova(model,type=2)
Anova(model,type=3)
linearHypothesis(model,c("cB vs. A&C","cA vs. C"))
	#Anova and linear hypothesis produce equal sum of squares for c main effect in type III
linearHypothesis(model,"cB vs. A&C")
linearHypothesis(model,"cA vs. C")
	#Sum of squares of the individual contrasts do not add to the main effect of c 


John J. Wiley, Jr.
PhD Candidate
State University of New York
College of Environmental Science and Forestry
Department of Environmental and Forest Biology
460 Illick Hall
Syracuse, NY 13210
315.470.4825 (office)
740.590.6121 (cell)