[R] predict lmer

Kingsford Jones kingsfordjones at gmail.com
Wed May 7 22:59:50 CEST 2008


One question that arises is: at what level is the prediction desired?
Within a given ID:TRKPT2 level?  Within a given ID level?  At the
marginal level (which Bert's code appears to produce).  Also, there is
the question:  how confident can you be in your predictions.  This
thread discusses possible ways to get prediction intervals:

https://stat.ethz.ch/pipermail/r-sig-mixed-models/2008q2/thread.html#841

Finally, why assume a Poisson error distribution for a binary response?

Kingsford Jones

On Wed, May 7, 2008 at 10:13 AM, Bert Gunter <gunter.berton at gene.com> wrote:
> Sorry, my reply below may be too terse. You'll need to also construct the
>  appropriate design matrix to which to apply the fixef() results to.
>
>  If newDat is a data.frame containing **exactly the same named regressor and
>  response columns** as your original vdata dataframe, and if me.fit.of is
>  your fitted lmer object as you have defined it below, then
>
>   model.matrix(terms(me.fit.of),newDat) %*% fixef(me.fit.of)
>
>  gives your predictions. Note that while the response column in newDat is
>  obviously unnecessary for prediction (you can fill it with 0's,say), it is
>  nevertheless needed for model.matrix to work. This seems clumsy to me, so
>  there may well be better ways to do this, and **I would appreciate
>  suggestions for improvement.***
>
>
>  Cheers,
>  Bert
>
>
>
>
>  -----Original Message-----
>  From: bgunter
>  Sent: Wednesday, May 07, 2008 9:53 AM
>  To: May, Roel; r-help at r-project.org
>  Subject: RE: [R] predict lmer
>
>  ?fixef
>
>  gets you the coefficient vector, from which you can make your predictions.
>
>  -- Bert Gunter
>  Genentech
>
>  -----Original Message-----
>  From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
>  Behalf Of May, Roel
>  Sent: Wednesday, May 07, 2008 7:23 AM
>  To: r-help at r-project.org
>  Subject: [R] predict lmer
>
>
>
> Hi,
>
>  I am using lmer to analyze habitat selection in wolverines using the
>  following model:
>
>  (me.fit.of <-
>  lmer(USED~1+STEP+ALT+ALT2+relM+relM:ALT+(1|ID)+(1|ID:TRKPT2),data=vdata,
>  control=list(usePQL=TRUE),family=poisson,method="Laplace"))
>
>  Here, the habitat selection is calaculated using a so-called discrete
>  choice model where each used location has a certain number of
>  alternatives which the animal could have chosen. These sets of locations
>  are captured using the TRKPT2 random grouping. However, these sets are
>  also clustered over the different individuals (ID). USED is my binary
>  dependent variable which is 1 for used locations and zero for unused
>  locations. The other are my predictors.
>
>  I would like to predict the model fit at different values of the
>  predictors, but does anyone know whether it is possible to do this? I
>  have looked around at the R-sites and in help but it seems that there
>  doesn't exist a predict function for lmer???
>
>  I hope someone can help me with this; point me to the right functions or
>  tell me to just forget it....
>
>  Thanks in advance!
>
>  Cheers Roel
>
>  Roel May
>  Norwegian Institute for Nature Research
>  Tungasletta 2, NO-7089 Trondheim, Norway
>
>
>         [[alternative HTML version deleted]]
>
>  ______________________________________________
>  R-help at r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>
>  ______________________________________________
>  R-help at r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list