Yesterday I posted the following question to the help list.  Thanks to John
Fox (copied below) who pointed out the solution.

 

Original question:

 

I have come across a result that I cannot explain, and am hopingthat someone
else can provide an answer.  A student fitted a mixed model  usingthe lme
function: out<- lme(fixed=Y~A+B+A:B, random=~1|Site).  Y is a continuous
variable while A and B are factors.  The data set is balanced with the same
number of observations in each combination of A and B.  There are two
hierarchical levels: Site and plots nested in site. 

He tried two different ways of getting theANOVA table: anova(out) and
anova(out, type="marginal"). Since the data were balanced, these two ways
should (I think) give the same output since they correspond to Type I and
III sums of squares in the SAS terminology.  At least, this is the case with
normal (i.e. not mixed) linear models.  However, he finds very different
results of these two types of ANOVA tables.  Why?

 

Response of John Fox:

 

Dear Bill,

 

I expect that the problem is in the contrasts that your student used for A
and B, though I haven't thought specifically about the context of a mixed
model. If he or she used the default contr.treatment(), then the contrasts
for different factors (and the interaction) are not orthogonal in the row
basis of the model matrix and hence are not orthogonal, even for balanced
data. Using, e.g., contr.sum() should provide A, B, and A:B contrasts that
are orthogonal to each other.

 

Indeed, changing to an appropriate type of contrast did solve the problem!
My problem was in forgetting that R uses treatment contrasts by default
while SPLUS uses Helmert contrasts by default (which would have worked as
well as sum contrasts).


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to