[R] lme and aov
Gang Chen
gangchen at mail.nih.gov
Fri Aug 3 23:10:42 CEST 2007
> This looks odd. It is a standard split-plot layout, right? 3
> groups of 13 subjects, each measured with two kinds of Rsp = 3x13x2
> = 78 observations.
Yes, that is right.
>
> In that case you shouldn't see the same effect allocated to
> multiple error strata. I suspect you forgot to declare Subj as factor.
This is exactly the problem I had: Model$Subj was not a factor! Now
they converge. A lesson well learned.
Thanks a lot for the help,
Gang
On Aug 3, 2007, at 4:53 PM, Peter Dalgaard wrote:
> Gang Chen wrote:
>> Thanks a lot for clarification! I just started to learn
>> programming in R for a week, and wanted to try a simple mixed
>> design of balanced ANOVA with a between-subject factor
>> (Grp) and a within-subject factor (Rsp), but I'm not sure whether
>> I'm modeling the data correctly with either of the command lines.
>>
>> Here is the result. Any help would be highly appreciated.
>>
>> > fit.lme <- lme(Beta ~ Grp*Rsp, random = ~1|Subj, Model);
>> > summary(fit.lme)
>> Linear mixed-effects model fit by REML
>> Data: Model
>> AIC BIC logLik
>> 233.732 251.9454 -108.8660
>>
>> Random effects:
>> Formula: ~1 | Subj
>> (Intercept) Residual
>> StdDev: 1.800246 0.3779612
>>
>> Fixed effects: Beta ~ Grp * Rsp
>> Value Std.Error DF t-value p-value
>> (Intercept) 1.1551502 0.5101839 36 2.2641837 0.0297
>> GrpB -1.1561248 0.7215090 36 -1.6023706 0.1178
>> GrpC -1.2345321 0.7215090 36 -1.7110417 0.0957
>> RspB -0.0563077 0.1482486 36 -0.3798196 0.7063
>> GrpB:RspB -0.3739339 0.2096551 36 -1.7835665 0.0829
>> GrpC:RspB 0.3452539 0.2096551 36 1.6467705 0.1083
>> Correlation:
>> (Intr) GrpB GrpC RspB GrB:RB
>> GrpB -0.707
>> GrpC -0.707 0.500
>> RspB -0.145 0.103 0.103
>> GrpB:RspB 0.103 -0.145 -0.073 -0.707
>> GrpC:RspB 0.103 -0.073 -0.145 -0.707 0.500
>>
>> Standardized Within-Group Residuals:
>> Min Q1 Med Q3 Max
>> -1.72266114 -0.41242552 0.02994094 0.41348767 1.72323563
>>
>> Number of Observations: 78
>> Number of Groups: 39
>>
>> > fit.aov <- aov(Beta ~ Rsp*Grp+Error(Subj/Rsp)+Grp, Model);
>> > fit.aov
>>
>> Call:
>> aov(formula = Beta ~ Rsp * Grp + Error(Subj/Rsp) + Grp, data = Model)
>>
>> Grand Mean: 0.3253307
>>
>> Stratum 1: Subj
>>
>> Terms:
>> Grp
>> Sum of Squares 5.191404
>> Deg. of Freedom 1
>>
>> 1 out of 2 effects not estimable
>> Estimated effects are balanced
>>
>> Stratum 2: Subj:Rsp
>>
>> Terms:
>> Rsp
>> Sum of Squares 7.060585e-05
>> Deg. of Freedom 1
>>
>> 2 out of 3 effects not estimable
>> Estimated effects are balanced
>>
>> Stratum 3: Within
>>
>> Terms:
>> Rsp Grp Rsp:Grp Residuals
>> Sum of Squares 0.33428 36.96518 1.50105 227.49594
>> Deg. of Freedom 1 2 2 70
>>
>> Residual standard error: 1.802760
>> Estimated effects may be unbalanced
More information about the R-help
mailing list