Brian Willis
2010-Oct-30 15:33 UTC
[R] Confidence interval for response variable in mixed effects models
HI, I am using lmer() for a simple mixed effects model. The model is of the form logit(y)~ x + (1|z), where x is an indicator variable and z a multi-level factor. I would like an estimate of the response variable (either y or logit y) with an associated confidence interval for a given value of x. There does not appear to be a predict function written for lmer(). The output for the fixed effects gives a standard error for the intercept, the coefficient of x and the correlation. For n observations, I transform the std errors to variances, and with the correlation, I think I can use the formula Var(intercept + x) = Var(intercept) + Var(x) + 2Cov(x,intercept) to get the variance of the fixed effects component of the response variable. However, I would like to include the random effects component of the variance, so I may derive a standard error and confidence interval for the variance. Does anyone know how to do this? Is there a ready made function like predict() or does anyone know how to incorporate the variance of random effects term to derive the std error of the response variable? Regards, Brian [[alternative HTML version deleted]]
Ben Bolker
2010-Oct-30 18:11 UTC
[R] Confidence interval for response variable in mixed effects models
Brian Willis <brian.willis <at> manchester.ac.uk> writes:> I am using lmer() for a simple mixed effects model. The model is of the form > logit(y)~ x + (1|z), where x is an indicator variable and z a multi-level > factor. > > I would like an estimate of the response variable (either y or logit y) with > an associated confidence interval for a given value of x.[snippage: sorry to remove context, but I am posting via gmane, which will complain if I have too much quoted context ...]> Does anyone know how to do this? Is there a ready made function like > predict() or does anyone know how to incorporate the variance of random > effects term to derive the std error of the response variable?You should search the r-sig-mixed-models archive for answers, and post there if you don't find what you need. The problem is that it can actually be a bit tricky to define these things properly for mixed models, decide which random effects to include (or not) in the prediction of the mean and include (or not) in the definition of the variance. So far there has not been a confluence of people who want this, people who know enough to construct a nice general solution, and people who have time to do it ... Ben Bolker
David Winsemius
2010-Oct-30 18:53 UTC
[R] Confidence interval for response variable in mixed effects models
On Oct 30, 2010, at 11:33 AM, Brian Willis wrote:> HI, > > I am using lmer() for a simple mixed effects model. The model is of > the form > logit(y)~ x + (1|z), where x is an indicator variable and z a multi- > level > factor. > > I would like an estimate of the response variable (either y or logit > y)There is a fitted method for objects of class "mer". ?"mer-class"> .... with an associated confidence interval for a given value of x.That is the sticking point as I understand it. See below.> > There does not appear to be a predict function written for lmer(). > > The output for the fixed effects gives a standard error for the > intercept, > the coefficient of x and the correlation. For n observations, I > transform > the std errors to variances, and with the correlation, I think I can > use the > formula Var(intercept + x) = Var(intercept) + Var(x) + > 2Cov(x,intercept) to > get the variance of the fixed effects component of the response > variable. > > However, I would like to include the random effects component of the > variance, so I may derive a standard error and confidence interval > for the > variance. > > Does anyone know how to do this? Is there a ready made function like > predict() or does anyone know how to incorporate the variance of > random > effects term to derive the std error of the response variable?I see Ben Bolker has offered a suggestion that you search the mixed models list. An earlier question on this topic elicited this citation (from Bolker): http://glmm.wikidot.com/faq One of the available choices in Baron's search page is R-sig-mixed- models and here are a few links to threads (by people who know more than me) that may offer at least informed commentary and options if not a general solution (from both R-help and the SIG-ME archives): http://search.r-project.org/cgi-bin/namazu.cgi?query=+confidence+intervals+lmer&max=100&result=normal&sort=score&idxname=functions&idxname=Rhelp08&idxname=Rhelp10&idxname=R-sig-mixed-models&idxname=Rhelp02 http://finzi.psych.upenn.edu/Rhelp10/2008-May/161516.html http://rwiki.sciviews.org/doku.php?id=guides:lmer-tests http://finzi.psych.upenn.edu/R/Rhelp02/archive/76742.html http://finzi.psych.upenn.edu/R/Rhelp02/archive/81237.html http://finzi.psych.upenn.edu/R/Rhelp02/archive/82567.html -- David Winsemius, MD West Hartford, CT