R version 3.0.3 (2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
# more with logistic curve fits
from nlmer class examples
> fixef(m1)
Asym xmid scal
192.0410 727.8908 347.9680
> data(Orange)
> attach(Orange)
# do nls which assumes 35 indep obs
> Asym = 190; xmid = 730; scal = 350 # from nlmer fit initial values
> onls = nls(circumference ~ SSlogis(age, Asym, xmid, scal), Orange)
> summary(onls)
Formula: circumference ~ SSlogis(age, Asym, xmid, scal)
Parameters:
Estimate Std. Error t value Pr(>|t|)
Asym 192.69 20.24 9.518 7.48e-11 ***
xmid 728.75 107.30 6.792 1.12e-07 ***
scal 353.53 81.47 4.339 0.000134 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 23.37 on 32 degrees of freedom
Number of iterations to convergence: 0
Achieved convergence tolerance: 3.544e-06
# get smaller s.e for asymptote, larger for others
> fitted(onls)
[1] 29.07602 64.26484 87.54483 132.06193 155.19807 165.80813 176.85797
[8] 29.07602 64.26484 87.54483 132.06193 155.19807 165.80813 176.85797
[15] 29.07602 64.26484 87.54483 132.06193 155.19807 165.80813 176.85797
[22] 29.07602 64.26484 87.54483 132.06193 155.19807 165.80813 176.85797
[29] 29.07602 64.26484 87.54483 132.06193 155.19807 165.80813 176.85797
# use curve to get plot of 'average' curve using the fixed effects estimates
> curve(192.04/(1 + exp(-(x - 727.89)/347.97)), from = 0, to = 1500)
# to get a plot of data with mean curve superimposed
> plot(age, circumference)
> curve(192.04/(1 + exp(-(x - 727.89)/347.97)), add = TRUE)
#saves nicely as a pdf; I didn't post mine
#you can also superimpose the curve on the xyplot giving individual tree trajectories
xyplot(circumference ~ age, Orange, groups = Tree, type = c("g", "b"),
auto.key = list(space = "right", lines = TRUE), aspect = "xy",
xlab = "Age (days since 1968/12/31)", ylab = "Circumference (mm)")
# but I get a graphics error when I try to save that as a pdf