[R] Doubt about nested aov output
Spencer Graves
spencer.graves at pdf.com
Mon Sep 5 17:51:24 CEST 2005
That's great. In your example, the aov fit is following by a warning:
> res2 <- aov(y ~ fix + Error(fix/R1/R2), data = dat)
Warning message:
Error() model is singular in: aov(y ~ fix + Error(fix/R1/R2), data = dat)
Moreover, to test whether your change was statistically significant,
library(nlme) supports "anova" with two nested models. In this case, it
produced the following:
> anova(reslme, reslme2)
Model df AIC BIC logLik Test L.Ratio p-value
reslme 1 6 864.4973 881.0704 -426.2487
reslme2 2 7 866.4973 885.8325 -426.2487 1 vs 2 1.818989e-12 1
>
I don't know if this relates to Ronaldo Reis' question, but it
certainly seems plausible.
spencer graves
Christoph Buser wrote:
> Hi
>
> I think the problem is related to specifying "Tratamento" both
> as a fixed factor and in the error term. I attached a script
> with a reproducible example that shows a similar output.
> I do not know the details of the original data and the questions
> of interest, but maybe a model including "Tratamento" is more
> what you wanted to implement.
>
> Regards,
>
> Christoph
>
> ## R-Script
>
> library(nlme)
>
> ## Generating the data
> set.seed(1)
> ziel <- rep(c(-6,8,20), each = 40) + rep(rnorm(15, 0, 20), each = 4) +
> rep(rnorm(60, 0, 10), each = 2) + rnorm(120, 0, 3)
> dat <- data.frame(y = ziel,
> fix = factor(rep(1:3, each = 40)),
> R1 = factor(rep(1:15, each = 8)),
> R2 = factor(rep(1:60, each = 2)))
>
> ## Model including "fix" as fixed and random effect.
> res2 <- aov(y ~ fix + Error(fix/R1/R2), data = dat)
> summary(res2)
>
> reslme2 <- lme(y ~ fix , data = dat, random = ~ 1|fix/R1/R2)
> summary(reslme2)
> anova(reslme2)
>
> ## Model including "fix" as fixed factor.
> res1 <- aov(y ~ fix + Error(R1/R2), data = dat)
> summary(res1)
>
> reslme <- lme(y ~ fix , data = dat, random = ~ 1|R1/R2)
> summary(reslme)
> anova(reslme)
>
> --------------------------------------------------------------
> Christoph Buser <buser at stat.math.ethz.ch>
> Seminar fuer Statistik, LEO C13
> ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
> phone: x-41-44-632-4673 fax: 632-1228
> http://stat.ethz.ch/~buser/
> --------------------------------------------------------------
>
>
>
> Spencer Graves writes:
> > Others may know the answer to your question, but I don't. However,
> > since I have not seen a reply, I will offer a few comments:
> >
> > 1. What version of R are you using? I just tried superficially
> > similar things with the examples in ?aov in R 2.1.1 patched and
> > consistently got F and p values.
> >
> > 2. My preference for this kind of thing is to use lme in
> > library(nlme) or lmer in library(lme4). Also, I highly recommend
> > Pinheiro and Bates (2000) Mixed-Effects Models in S and S-Plus (Springer).
> >
> > 3. If still want to use aov and are getting this problem in R 2.1.1,
> > could you please provide this list with a small, self contained example
> > that displays the symptoms that concern you? And PLEASE do read the
> > posting guide! "http://www.R-project.org/posting-guide.html". It might
> > increase the speed and utility of replies.
> >
> > spencer graves
> >
> > Ronaldo Reis-Jr. wrote:
> >
> > > Hi,
> > >
> > > I have two doubts about the nested aov output.
> > >
> > > 1) I have this:
> > >
> > >>anova.ratos <- aov(Glicogenio~Tratamento+Error(Tratamento/Rato/Figado))
> > >>summary(anova.ratos)
> > >
> > >
> > > Error: Tratamento
> > > Df Sum Sq Mean Sq
> > > Tratamento 2 1557.56 778.78
> > >
> > > Error: Tratamento:Rato
> > > Df Sum Sq Mean Sq F value Pr(>F)
> > > Residuals 3 797.67 265.89
> > >
> > > Error: Tratamento:Rato:Figado
> > > Df Sum Sq Mean Sq F value Pr(>F)
> > > Residuals 12 594.0 49.5
> > >
> > > Error: Within
> > > Df Sum Sq Mean Sq F value Pr(>F)
> > > Residuals 18 381.00 21.17
> > >
> > > R dont make the F and P automatically, it is possible?
> > >
> > > I Like an output like this:
> > >
> > > Error: Tratamento
> > > Df Sum Sq Mean Sq F value Pr(>F)
> > > Tratamento 2 1557.56 778.78 2.929 0.197
> > >
> > > Error: Tratamento:Rato
> > > Df Sum Sq Mean Sq F value Pr(>F)
> > > Residuals 3 797.67 265.89 5.372 0.0141
> > >
> > > Error: Tratamento:Rato:Figado
> > > Df Sum Sq Mean Sq F value Pr(>F)
> > > Residuals 12 594.0 49.5 2.339 0.0503
> > >
> > > Error: Within
> > > Df Sum Sq Mean Sq F value Pr(>F)
> > > Residuals 18 381.00 21.17
> > >
> > > Why it not make automatic calculations? It is possible?
> > >
> > >
> > > 2) I can say that Error: Tratamento:Rato means an interaction between
> > > Tratamento and Rato? Normally the : represents an interaction, but in this
> > > output I think that it dont mean the interaction.
> > >
> > > Any explanation are welcome.
> > >
> > > Thanks
> > > Ronaldo
> >
> > --
> > Spencer Graves, PhD
> > Senior Development Engineer
> > PDF Solutions, Inc.
> > 333 West San Carlos Street Suite 700
> > San Jose, CA 95110, USA
> >
> > spencer.graves at pdf.com
> > www.pdf.com <http://www.pdf.com>
> > Tel: 408-938-4420
> > Fax: 408-280-7915
> >
> > ______________________________________________
> > 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
> >
> >
> > !DSPAM:431b8510220677348368323!
--
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA
spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel: 408-938-4420
Fax: 408-280-7915
More information about the R-help
mailing list