Skip to content
Prev 18698 / 20628 Next

var(ranef(Random Effect)) not the same as the variance component

Simon

Here is an example to show what my notation implies with respect to your question:

fm1 <- lmer(Reaction ~ 1 + (1|Subject), sleepstudy)

sqrt(var(ranef(fm1)$Subject) + mean(sapply(attr(ranef(fm1, condVar=TRUE)[[1]], "postVar"),function(x) x)))

From: Simon Harmel <sim.harmel at gmail.com>
Sent: Wednesday, September 9, 2020 11:53 AM
To: D. Rizopoulos <d.rizopoulos at erasmusmc.nl>
Cc: r-sig-mixed-models <r-sig-mixed-models at r-project.org>; Harold Doran <harold.doran at cambiumassessment.com>; Ben Bolker <bbolker at gmail.com>
Subject: Re: [R-sig-ME] var(ranef(Random Effect)) not the same as the variance component

First of all, thank you all for your valuable input.

Dimitris,

Thank you I upvoted your answer on CV as well. But please help me understand a few things.

1- By D matrix, you mean the G matrix shown in: https://bookdown.org/marklhc/notes/simulating-multilevel-data.html#linear-growth-model

2- When you say variance components in the output are prior values, can you tell me how these prior values are obtained? I guess from the data itself, but how exactly (do we run individual models first to see how much intercepts and slopes vary & co-vary and take those as prior)?

3- Harold above noted that: "The conditional means of the random effects are E(Y|X) and hence their variance is only one portion of the total variance [i.e., var(y)]." I'm not sure how this directly relates to my question in this thread?

Thank you,
Simon
On Tue, Sep 8, 2020 at 3:47 PM Harold Doran <harold.doran at cambiumassessment.com<mailto:harold.doran at cambiumassessment.com>> wrote:
To add a little notation to this, we can use law of total variance, var(y) = E(var(Y|X)) + var(E(Y|X)). The conditional means of the random effects are E(Y|X) and hence their variance is only one portion of the total variance.

-----Original Message-----
From: R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org<mailto:r-sig-mixed-models-bounces at r-project.org>> On Behalf Of D. Rizopoulos
Sent: Monday, September 7, 2020 11:02 PM
To: Simon Harmel <sim.harmel at gmail.com<mailto:sim.harmel at gmail.com>>; r-sig-mixed-models <r-sig-mixed-models at r-project.org<mailto:r-sig-mixed-models at r-project.org>>
Subject: Re: [R-sig-ME] var(ranef(Random Effect)) not the same as the variance component

External email alert: Be wary of links & attachments.


Yes, you do not expect these two be the same. The variance components are the prior variances of the random effects, whereas var(ranef(model)) is the variance of the posterior means/modes of the random effects.

Best,
Dimitris


Dimitris Rizopoulos
Professor of Biostatistics
Erasmus University Medical Center
The Netherlands