After fitting a non-linear mixed model with crossed categorical covariates, how do you write the model equation (with parameter estimates) for each group combination?
library(ggplot2)
library(tidyr)
library(dplyr)
data(CO2)
Using the CO2
data set as referenced in Pinheiro and Bates 2000:
ggplot(CO2, aes(x=conc, y=uptake, group=Plant))+
geom_line()+
facet_grid(Treatment ~ Type)
Fit a model with an Asymptotic regression model with an offset, allowing the Asym
and lrc
to vary by Type
and Treatment
(but requiring c0
be constant), according to a model in section 8.2.2 in Pinheiro and Bates.
library(nlme)
fm4CO2.nlme <- nlme(uptake ~ SSasympOff(conc, Asym, lrc, c0), data=CO2,
fixed= list(Asym + lrc ~ Type * Treatment, c0 ~ 1),
random = Asym + lrc ~ 1,
start = c(32.412, 0, 0, 0, -4.5603,0, 0, 0, 49.344))
summary(fm4CO2.nlme)
Nonlinear mixed-effects model fit by maximum likelihood
Model: uptake ~ SSasympOff(conc, Asym, lrc, c0)
Data: CO2
AIC BIC logLik
388.418 420.0186 -181.209
Random effects:
Formula: list(Asym ~ 1, lrc ~ 1)
Level: Plant
Structure: General positive-definite, Log-Cholesky parametrization
StdDev Corr
Asym.(Intercept) 2.34968017 As.(I)
lrc.(Intercept) 0.07960176 -0.92
Residual 1.79195963
Fixed effects: list(Asym + lrc ~ Type * Treatment, c0 ~ 1)
Value Std.Error DF t-value p-value
Asym.(Intercept) 41.81755 1.562449 64 26.76410 0.0000
Asym.TypeMississippi -10.53047 2.208351 64 -4.76848 0.0000
Asym.Treatmentchilled -2.96942 2.213205 64 -1.34169 0.1844
Asym.TypeMississippi:Treatmentchilled -10.89926 3.112279 64 -3.50202 0.0008
lrc.(Intercept) -4.55726 0.096292 64 -47.32762 0.0000
lrc.TypeMississippi -0.10411 0.121685 64 -0.85557 0.3954
lrc.Treatmentchilled -0.17124 0.111962 64 -1.52947 0.1311
lrc.TypeMississippi:Treatmentchilled 0.74124 0.221716 64 3.34322 0.0014
c0 50.50804 4.364848 64 11.57155 0.000
(output truncated)
I know how to plot the modeled data with conditional predicted values (using the plant information "Plant") and marginal predicted values (ignoring the plant information; "fixed")
plot(augPred(fm4CO2.nlme, level=0:1))
And I know how to add onto data frame the marginal predicted values (ignoring the effect of the plant random effect)
CO2$predict=predict(fm4CO2.nlme, CO2 , level=0)
Is there an easy way to obtain the parameters for the four model equations for each of the Type * Treatment
combos?