[R] Analyzing an unbalanced AB/BA cross-over design
jfox at mcmaster.ca
Wed Jan 29 13:53:05 CET 2003
As Peter Dalgaard has pointed out, the model you fit has redundant
parameters, as you can see from its summary (or from the coefficients):
. . .
Coefficients: (13 not defined because of singularities)
. . .
(Intercept) treatmentS period2
305.35714 -46.60714 15.89286
sequence2:subject2 sequence1:subject3 sequence2:subject3
222.50000 NA 200.00000
sequence1:subject5 sequence2:subject5 sequence1:subject6
NA 240.00000 45.00000
sequence2:subject7 sequence1:subject9 sequence2:subject9
NA NA 150.00000
sequence1:subject11 sequence2:subject11 sequence1:subject12
75.00000 NA NA
sequence2:subject13 sequence1:subject14 sequence2:subject14
NA 57.50000 NA
The computational procedure used by Anova (in the car package) assumes a
full-rank parametrization of the model. The difference between the Anova
methods for lm and glm is that the former uses the coefficient estimates
and their covariance matrix to compute sums of squares while the latter
refits the model. You got a result from SAS because it works with a
deficient-rank parametrization. Finally (and more generally), if you really
want "type-III" sums of squares in R, be careful with the kind of
contrast-coding that you use. The default "treatment" contrasts won't give
you what you want.
I'm sorry that you encountered this problem.
At 11:00 AM 1/29/2003 +0100, martin wolfsegger wrote:
>I am looking for help to analyze an unbalanced AB/BA cross-over design by
>requesting the type III SS !
># Example 3.1 from S. Senn (1993). Cross-over Trials in Clinical
>The recommended SAS code equals
>PROC GLM DATA=example;
>CLASS subject period treatment sequence;
>MODEL outcome = treatment sequence period subject(sequence);
>For PROC GLM, the random effects are treated in a post hoc fashion after the
>complete fixed effect model is fit. This distinction affects other features
>in the GLM procedure, such as the results of the LSMEANS and ESTIMATE
>statements. Looking only on treatment, period, sequence and subject
>random statement can be omitted.
>The R code for type I SS equals
> Df Sum Sq Mean Sq F value Pr(>F)
>treatment 1 13388 13388 17.8416 0.001427 **
>period 1 1632 1632 2.1749 0.168314
>sequence 1 335 335 0.4467 0.517697
>sequence:subject 11 114878 10443 13.9171 6.495e-05 ***
>Residuals 11 8254 750
>According to the unbalanced design, I requested the type III SS which
>resulted in an error statement
>Error in linear.hypothesis.lm(mod, hyp.matrix, summary.model = sumry, :
> One or more terms aliased in model.
>by using glm I got results with 0 df for the sequence effect !!!!
>Anova Table (Type III tests)
> SS Df F Pr(>F)
>treatment 14036 1 18.7044 0.001205 **
>period 1632 1 2.1749 0.168314
>sequence 0 0
>sequence:subject 114878 11 13.9171 6.495e-05 ***
>Residuals 8254 11
>The questions based on this output are
>1) Why was there an error statement requesting type III SS based on lm ?
>2) Why I got a result by using glm with 0 df for the period effect ?
>3) How can I get the estimate, the StdError for the constrast (-1,1) of the
>treatment effect ?
>R-help at stat.math.ethz.ch mailing list
Department of Sociology
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
More information about the R-help