[R] Regarding aov Error()
Spencer Graves
spencer.graves at pdf.com
Sun Mar 19 19:04:41 CET 2006
Dear Prof. Vokey:
I can't answer your question regarding aov, because I never use it.
Instead, I use lme in library(nlme), which should be able to handle your
specific question and many more that aov can NOT handle. I could get
your error message, but I don't know how to fix it using aov.
However, the following lme call looks like it might answer the
question you are asking:
> library(nlme)
> testNest <- lme(dv~Q,
+ random=list(s=~1, P=~1), data=testnest)
> testNest
Linear mixed-effects model fit by REML
Data: testnest
Log-restricted-likelihood: -47.54548
Fixed: dv ~ Q
(Intercept) Qq2
2.125 0.125
Random effects:
Formula: ~1 | s
(Intercept)
StdDev: 4.726742e-05
Formula: ~1 | P %in% s
(Intercept) Residual
StdDev: 1.076244 0.005591059
Number of Observations: 32
Number of Groups:
s P %in% s
8 32
For me, the essential reference for lme is Pinheiro and Bates (2000)
Mixed-Effects Models in S and S-Plus (Springer). Bates is perhaps the
leading contributor in this area, and I believe you will be amply
rewarded for appropriate study of this book.
hope this helps,
spencer graves
John Vokey wrote:
> The following dummy data frame has factor Q (with 2 levels) nesting
> factor P (with levels p1 and p2 nested under q1, and p3 and p4 nested
> under q2), but both crossing the random variate s, which has 8
> levels. The dependent measure is dv.
> > # The data frame:
> > testnest
> dv s P Q
> 1 1 s1 p1 q1
> 2 2 s2 p1 q1
> 3 1 s3 p1 q1
> 4 2 s4 p1 q1
> 5 1 s5 p1 q1
> 6 3 s6 p1 q1
> 7 3 s7 p1 q1
> 8 4 s8 p1 q1
> 9 2 s1 p2 q1
> 10 3 s2 p2 q1
> 11 3 s3 p2 q1
> 12 1 s4 p2 q1
> 13 1 s5 p2 q1
> 14 2 s6 p2 q1
> 15 2 s7 p2 q1
> 16 3 s8 p2 q1
> 17 3 s1 p3 q2
> 18 3 s2 p3 q2
> 19 4 s3 p3 q2
> 20 1 s4 p3 q2
> 21 1 s5 p3 q2
> 22 1 s6 p3 q2
> 23 2 s7 p3 q2
> 24 2 s8 p3 q2
> 25 4 s1 p4 q2
> 26 3 s2 p4 q2
> 27 1 s3 p4 q2
> 28 2 s4 p4 q2
> 29 4 s5 p4 q2
> 30 1 s6 p4 q2
> 31 3 s7 p4 q2
> 32 1 s8 p4 q2
>
> # The following aov() call is structurally correct with respect
> # to the design, and appropriate error-terms, but, as can be seen,
> # returns an error:
>
> > testnest.aov=aov(dv~Q+P%in%Q+Error(s+s:Q+s:P:Q),data=testnest)
> Warning message:
> Error() model is singular in: aov(dv ~ Q + P %in% Q + Error(s + s:Q +
> s:P:Q), data = testnest)
>
> # However, applying the summary() method to the aov output, produces
> the correct analysis:
>
> > summary(testnest.aov)
>
> Error: s
> Df Sum Sq Mean Sq F value Pr(>F)
> Residuals 7 5.8750 0.8393
>
> Error: s:Q
> Df Sum Sq Mean Sq F value Pr(>F)
> Q 1 0.1250 0.1250 0.068 0.8018
> Residuals 7 12.8750 1.8393
>
> Error: s:Q:P
> Df Sum Sq Mean Sq F value Pr(>F)
> Q:P 2 0.250 0.125 0.1111 0.8956
> Residuals 14 15.750 1.125
>
> I have tried many different ways of denoting the Error()
> partitioning, but can't find one that produces both the correct
> analysis *AND* no singularity error on the aov() call. Any suggestions?
>
> --
> Please avoid sending me Word or PowerPoint attachments.
> See <http://www.gnu.org/philosophy/no-word-attachments.html>
>
> -Dr. John R. Vokey
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list