[R] prediction intervals from a mixed-effects models?
Spencer Graves
spencer.graves at pdf.com
Wed Apr 16 05:08:08 CEST 2008
Thank you Dieter and Greg for your replies. Reinhold Kliegl
suggested Gelman & Hill (2007), which looks like it contains an answer
to my question.
Thanks again.
Spencer Graves
Gregory Warnes wrote:
> On Apr 13, 2008, at 1:41PM , Dieter Menne wrote:
>
>> Spencer Graves <spencer.graves <at> pdf.com> writes:
>>
>>
>>> How can I get prediction intervals from a mixed-effects model?
>>> Consider the following example:
>>>
>>> library(nlme)
>>> fm3 <- lme(distance ~ age*Sex, data = Orthodont, random = ~ 1)
>>> df3.1 <- with(Orthodont, data.frame(age=seq(5, 20, 5),
>>> Subject=rep(Subject[1], 4),
>>> Sex=rep(Sex[1], 4)))
>>> predict(fm3, df3.1, interval='prediction')
>>> # M01 M01 M01 M01
>>> # 22.69012 26.61199 30.53387 34.45574
>>>
>>> # NOTE: The 'interval' argument to the 'predict' function was
>>> ignored.
>>> # It works works for an 'lm' object, but not an 'lme' object.
>>>
>>>
>> In theory, ci from gmodels should work
>>
>> library(gmodels)
>> ci(df3.1)
>>
>>
>> However, I get an error message. I will forward this to Greg to let
>> him check if
>> I did something stupid.
>>
>
> gmodels::ci() will give confidence intervals for the fixed effects via
>
> ci(fm3)
>
> ci() won't generate prediction intervals for individual parameters,
> and according to
>
> ?predict.lme
>
> it won't either.
>
> -Greg
>
>
>
>
>> Dieter
>>
>> ______________________________________________
>> 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