[R-sig-ME] Predictions and/or confidence (or prediction) intervals on predictions

Andrzej agalecki at umich.edu
Wed Apr 25 18:14:22 CEST 2012


Hi Yann,

Reparameterize the  model. This is probably what you are looking for:

 > fm1a <- lme(distance ~ -1 + Sex +age:Sex, random = ~ 1 + age | 
Subject, data = Orthodont)
 > fixef(fm1a)
       SexMale     SexFemale   SexMale:age SexFemale:age
    16.3406250    17.3727273     0.7843750     0.4795455

Hope it helps

Andrzej

PS. age is continuous not "sort of categorical"

On 4/25/2012 11:36 AM, Yann Hautier wrote:
> Dear all,
>
> On the FAQ page of http://glmm.wikidot.com/faq, Ben Bolker gives a nice
> example of how to get predictions and/or confidence (or prediction)
> intervals on predictions from the following model for lme:
> fm1<- lme(distance ~ age*Sex, random = ~ 1 + age | Subject, data =
> Orthodont)
> and for lmer
> fm1 = lmer(formula = distance ~ age*Sex + (age|Subject), data = Orthodont,)|
>
> |In this example, to calculate the predictions and confidence intervals,
> the variable age is sort of considered as categorical,
> age=c(8,10,12,14), and therefore the coefficients reported are the means
> with their SE.
> However, the fixef(fm1) output of the model shows that age is a
> continuous variable and therefore the output
> (Intercept)         age     SexMale age:SexMale
>       17.3727      0.4795     -1.0321      0.3048
> reports the intercept of Female (Intercept), the slope of Female (age),
> the difference in the intercept for Male (SexMale) and the difference in
> slope for Male (age:SexMale). The intercept and slope for Male have to
> be calculated, the intercept is then 17.3727+(-1.0321)=16.3406 and the
> slope is then 0.4795+0.3048=0.7843.
>
> Here is my question. In the same fashion as the means are calculated
> with the model.matrix
> newdat<- expand.grid(age=c(8,10,12,14),Sex=c("Male","Female"),distance = 0)
> mm = model.matrix(terms(fm1),newdat)
> newdat$distance = mm %*% fixef(fm1)
> Is it possible to directly calculate the slopes and intercepts from this
> model? I am of course talking about the estimates of each of the slope
> and intercept for each gender (male and female). So with the calculation
> from the fixef(lm1) output.
>
> Thanks in advance,
> Yann
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>



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