lme4 / lme4

Mixed-effects models in R using S4 classes and methods with RcppEigen
Other
621 stars 146 forks source link

support for `se.fit` argument in `predict.merMod` function #147

Open jlegewie opened 10 years ago

jlegewie commented 10 years ago

Hi,

I saw that the development version of lme4 includes a predict.merMod function, which is great. It would be nice if this function supports a se.fit argument as do other predict functions (e.g. predict.glm). se.fit is false be default. If it's true, predict returns a list with one object named fit (predicted values) and one object named se.fit with the standard errors.

bbolker commented 10 years ago

The reason that this hasn't yet happened is that I've never been able to come up with a good way to compute standard errors on predictions that I was comfortable with. There are two particular problems: (1) I don't know of any approach other than MCMC or parametric bootstrap approaches that will allow us to account for uncertainty in the random-effects (theta) parameters; (2) it's complicated (although not impossible) to decide which components of variance should be included when predictions are made either conditional on particular values of the random effects or with the random effects set to zero.

Bottom line: I agree that this would be nice but it's far from trivial.

bbolker commented 10 years ago

Just to clarify: it would be easy to write a version of se.fit that simply ignored all uncertainty due to either uncertainty in the random-effects parameter estimates, or in the conditional modes, but I am very uncomfortable doing that, because I know that it will be used widely and uncritically. It's one thing to give people the recipe (as we do at http://glmm.wikidot.com/faq ) for computing these naive standard errors, and another to provide an automatic method to do it ...