If there are 2 nlme models with same non-linear mean function, model 1 and model 2, how do you compare them ? Which R function does this for us ?
And when there are random effects or fixed effects, I don't know how a nested model is defined ?
For example model 1,
`model1 <- nlme(df_measures ~ meanfunc(w, time, b0,b1,b2) , fixed = list(b0 ~1, b1 ~ 1, b2 ~ 1), random = b0 + b1 + b2 ~ 1, groups = ~ subject , data = dataa, start = list(fixed = c(b0 = 3,1, b1 = 5,1,b2 = 1,1)), verbose = T )`
and model 2:
`model2 <- nlme(df_measures ~ meanfunc(w, time, b0,b1,b2) , fixed = list(b0 ~w, b1 ~ w, b2 ~ w), random = b0 + b1 + b2 ~ 1, groups = ~ subject , data = dataa, start = list(fixed = c(b0 = 3,1, b1 = 5,1,b2 = 1,1)), verbose = T )`
Is model2 a nested model of model 1 ? This is confusing me and how do I compare them ?
If model 2 is a nested model of model 1, can I still use ANOVA
function in R to compare them ?
What if model 2 is not a nested model of model 1 ? How should I compare between these 2 models? Based on what criteria ?
Thanks.
Best Answer
Model A is nested within Model B if A is a special case of B. In your example, model 1 is nested within model2 because it equals to the special case of model2, where the slope for w
is set to be 0.
My understanding is that the nested nature can apply to both random effects structure and fixed effects structure. Yours is nested in the fixed effect structure. (edit: in the original post I said "nested in the random effect structure", which is wrong)
I am not sure about ANOVA
, but yes you can use anova
to compare them (anova(model2,model1)
), although the authors of nlme
advise against it, because the likelihood ratio test (for comparing fixed effects) will be anti-conservative. That is, the p-value will be less than what it actually is.
They recommend using the conditional t-test, which is implemented in the summary
function. So in your case, there is no need to fit model1, and you can simply look at summary(model2)
. The alternative they recommend is the conditional F-test, which is implemented in the anova
but with 1 model only. That is, anova(model2)
. So you have 2 to choose from.
For completeness sake perhaps I should say that the above advice seems to hold only for fixed effect comparison. If you are making inference on the variance components, then the Likelihood ratio test (from anova
) will be conservative instead. But people tend to accept being conservative, which means anova
can be used.
My reference is the author's book. Pinheiro & Bates (2000), Mixed-Effects model for S and S-plus
Similar Posts:
- Solved – modelling random structure in lmer and nlme:lme
- Solved – Non-linear model in lme4
- Solved – How to mixed-effect and fixed-effect generalised linear models be compared using BIC
- Solved – Meaning of “Error in contr.treatment(n = 0L) : not enough degrees of freedom to define contrasts” when adding fixed effects to nlme
- Solved – Autocorrelation *across* random effects in nlme:lme