Thank you for your reply and sorry for my ambiguity.
I computed:
summary(anova1 <- aov(math ~ as.factor(schoolid), data=nels88))
ICC1(anova1)
ICC1 comes from the multilevel package. I have found an article where it
is pointed out that with this formula:
> 34.011/(34.011+72.256)
[1] 0.3200523
I should get practically an identical result than using ICC1. I have
used the database of that article and I have got an identical result.
But with the dataset I am using (schools) it doesn't work.
This is the example of the article mentioned above:
library(multilevel)
base(bh1996)
summary(lmer(WBEING ~ 1 + (1|GRP), data=bh1996))
0.035801/(0.035801+0.789497)
summary(test <- aov(WBEING~as.factor(GRP),data=bh1996))
ICC1(test)
I have attached the small database where this "equality" doesn't exist.
Thank you in advance.
On 2/5/2011 11:07 PM, Paul Johnson wrote:
2011/2/5 Sebastián Daza<sebastian.d...@gmail.com>:
Hi everyone,
I need to get a between-component variance (e.g. random effects Anova), but
using lmer I don't get the same results (variance component) than using
random effects Anova. I am using a database of students, clustered on
schools (there is not the same number of students by school).
According to the ICC1 command, the interclass correlation is .44
ICC1(anova1)
[1] 0.4414491
If you don't tell us exactly what model you are calculating in
"anova1", how would we guess if there is something wrong?
Similarly, I get this
ICC1
Error: object 'ICC1' not found
so it must mean you've loaded a package or written a function, which
you've not shown us.
I googled my way to a package called "multilevel" that has ICC1, and
its code for ICC1 shows a formula that does not match the one you used
to calculate ICC from lmer.
function (object)
{
MOD<- summary(object)
MSB<- MOD[[1]][1, 3]
MSW<- MOD[[1]][2, 3]
GSIZE<- (MOD[[1]][2, 1] + (MOD[[1]][1, 1] + 1))/(MOD[[1]][1,
1] + 1)
OUT<- (MSB - MSW)/(MSB + ((GSIZE - 1) * MSW))
return(OUT)
}
I'm not saying that's right or wrong, just not obviously identical to
the formula you proposed.
However, I cannot get the same ICC from the lmer output:
anova2<- lmer(math ~ 1 + (1|schoolid), data=nels88)
summary(anova2<- lmer(math ~ 1 + (1|schoolid), data=nels88))
Instead, do this (same thing, fits model only once):
anova2<- lmer(math ~ 1 + (1|schoolid), data=nels88)
summary(anova2)
Note that lmer is going to estimate a normally distributed random
effect for each school, as well as an individual observation random
effect (usual error term) that is assumed independent of the
school-level effect. What is "anova1" estimating?
--
Sebastián Daza
sebastian.d...@gmail.com
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.