[R] very basic HLM question

Paul Johnson pauljohn32 at gmail.com
Sun Feb 6 06:07:42 CET 2011


2011/2/5 Sebastián Daza <sebastian.daza at 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?


-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas



More information about the R-help mailing list