# [R-sig-ME] Confidence intervals on predictions for a non-linear mixed model (nlme)

Paul Buerkner paul.buerkner at gmail.com
Mon Aug 22 19:58:33 CEST 2016

```Hi Piet,

as already pointed out on stackexchange, there is no direct way with nlme
to determine the distribution of the parameters so that we don't know if a
normal approximation is justified.

One solution to overcome this problem is to use Bayesian methods. With the
brms package, for instance, this looks as follows:

library(nlme)
library(brms)

# define some reasonable priors
prior = c(set_prior("normal(80, 20)", nlpar = "Asym"),
set_prior("normal(0, 10)", nlpar = "R0"),
set_prior("normal(0, 5)", nlpar = "lrc"))

# fit the model
fm2 <- brm(height ~ Asym+(R0-Asym)*exp(-exp(lrc)*age),
data = Loblolly, prior = prior,
nonlinear = list(Asym ~ 1 + (1|Seed), R0 ~ 1, lrc ~ 1))
summary(fm2)
plot(fm2)

# effect of age without RE variance
marginal_effects(fm2)
# effect of age with RE variance
marginal_effects(fm2, re_formula = NULL)

Using brms may be a bit cumbersome at start as you need a C++ compiler at
run time. That is you need Rtools on Windows or Xcode on Mac (see
https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#prerequisites)
for more details.

question.

- Paul

2016-08-22 14:23 GMT+02:00 Piet van den Berg <pvdberg1 at gmail.com>:

> Dear all,
>
> I'm trying to get confidence intervals on my predictions for a non-linear
> mixed model in nlme, using resampling of parameter values. I got a result,
> but would like to know if I'm going in the right direction.
>
> I posted my problem here:
> http://stats.stackexchange.com/questions/231074/confidence-intervals-on-
> predictions-for-a-non-linear-mixed-model-nlme
>
> Any help would be appreciated.
>
> All best,
> Piet.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

[[alternative HTML version deleted]]

```