[R-sig-ME] How to calculate predictions

Ben Bolker bbolker at gmail.com
Wed Feb 29 15:58:21 CET 2012


Stuart Luppescu <slu at ...> writes:

> 
> On Tue, 2012-02-28 at 04:26 +0000, Ben Bolker wrote:
> > Stuart Luppescu <slu at ...> writes:
> > 
> > > 
> > > On Mon, 2012-02-27 at 16:07 -0700, Jake Westfall wrote:
> > > 
> > > I believe that fitted() is giving fitted values for each observation. 
> > > 
> > >  length(fitted(math.lme3))
> > > [1] 520573
> > >  length(unique(math.lme3 <at> frame$sid))
> > > [1] 236994
> > > 
> > > I have about 520,000 observations nested within 236,994 students. I want
> > > a fitted value for each student at age 15 (which may or may not be
> > > actually observed).
> > 
> >   Have you looked at the code on http://glmm.wikidot.com/faq ... ?
> 
> Yes, I have. Unless I'm missing something (which is very possible) it
> doesn't seem that the code includes the individual random effects.

  Hmm.  If you're comfortable doing a bit of coding, you can certainly
extract the random effects with ranef() and apply them to the predictions ...
if you wanted to get fancy you could create a sparse model matrix yourself
and use it (although in this case just taking ranef(math.lme3)[[1]]
out manually and doing the sensible thing with it should work.

> 
> > Also, the new lme4Eigen package does have a ?predict method ...
> 
> Doesn't seem to be available on CRAN -- only on R-forge? I don't think I
> can convince our sysadmin to install a non-stable package.
> 

  Yes, it's on r-forge.

  Maybe you can try installing it to a local directory and seeing
if it does what you want?

  Ben Bolker




More information about the R-sig-mixed-models mailing list