[R] Nestad ANOVA with random Factors
Pablo R
riulp at hotmail.com
Fri Aug 27 09:43:37 CEST 2010
Hi,
I need a help. I am new in R and I need to run a nested anova with fixed and
random factors (Mixed Model). I have a design with three factors: Day, Area
and Plot and the dependent variable is density. The factors Day and Area are
fixed while Plot is random, factor Area is nested in factor Day, and factor
Plot is nested in Area.
I can do it using aov by:
mod1<-aov(density~ day + day%in%area + day%in%area%in%plot)
symmary(mod1)
Getting this result:
Analysis of Variance Table
Response: total
Df Sum Sq Mean Sq F value Pr(>F)
day 2 1789.8 894.91 55.5576 < 2e-16 ***
day:area 15 4658.8 310.59 19.2818 < 2e-16 ***
day:area:plot 72 1715.7 23.83 1.4793 0.01145 *
Residuals 360 5798.8 16.11
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
But I'm afraind the factor plot is not beeing calculated as random.
The other way would be using the lme from nlme as below (if I had only
factors area and plot, once I don't know how to include day and keep plot as
random) just as an exemple I found in the list files:
> mod2 <- lme(density ~ area + plot, random = ~ 1 | area / plot, data =
> data)
> summary(mod2)
Linear mixed-effects model fit by REML
Data: data
AIC BIC logLik
1422.403 1475.532 -698.2017
Random effects:
Formula: ~1 | area
(Intercept)
StdDev: 0.347117
Formula: ~1 | plot %in% area
(Intercept) Residual
StdDev: 6.431067e-05 1.127295
Fixed effects: density~ area + plot
Value Std.Error DF t-value p-value
(Intercept) 2.6131608 0.3856554 420 6.775895 0.0000
areaarea10 -1.2073539 0.5242788 0 -2.302885 NaN
areaarea2 -0.3062031 0.5242788 0 -0.584046 NaN
areaarea4 -0.6109334 0.5242788 0 -1.165283 NaN
areaarea6 -0.9808034 0.5242788 0 -1.870767 NaN
areaarea8 -1.3437982 0.5242788 0 -2.563136 NaN
plotb -0.0899366 0.1680473 20 -0.535187 0.5984
plotc 0.0257024 0.1680473 20 0.152947 0.8800
plotd 0.0420734 0.1680473 20 0.250366 0.8049
plote -0.2375628 0.1680473 20 -1.413666 0.1728
Correlation:
(Intr) arer10 arear2 arear4 arear6 arear8 plotb plotc plotd
areaarea10 -0.680
areaarea2 -0.680 0.500
areaarea4 -0.680 0.500 0.500
areaarea6 -0.680 0.500 0.500 0.500
areaarea8 -0.680 0.500 0.500 0.500 0.500
plotb -0.218 0.000 0.000 0.000 0.000 0.000
plotc -0.218 0.000 0.000 0.000 0.000 0.000 0.500
plotd -0.218 0.000 0.000 0.000 0.000 0.000 0.500 0.500
plote -0.218 0.000 0.000 0.000 0.000 0.000 0.500 0.500 0.500
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.3554021 -0.8985867 0.1031298 0.8008967 2.6488795
Number of Observations: 450
Number of Groups:
area plot %in% area
6 30
Warning message:
In pt(q, df, lower.tail, log.p) : NaNs produzidos
But, in addition to the lack of the factor day, I am sure its not right
because of these "NaN" produced and because of the area beeing assigned as
Random in the output.
I would appreciate any help and thanks for your attention in advance,
Pablo
--
View this message in context: http://r.789695.n4.nabble.com/Nestad-ANOVA-with-random-Factors-tp2340725p2340725.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list