When trying to use cAIC4::cAIC()
for my mixed model (I have several models with different random effects structures, including random intercepts only, random intercepts and slopes, random intercepts and specification of serial correlation etc.) fitted by nlme::lme()
, immediately after running I get the message: R Session Aborted, R encountered a fatal error, the session was terminated.
Similar models (e.g. with random intercepts and slopes) fitted using lme4::lmer()
do not cause any problems.
Unfortunately, I cannot share my data for confidentiality reasons. A different longitudinal data set does not cause the same issue, however I can include the model specification and an impression of the data:
> head(df, 10)
ID S A BT AT outcome Time
1 1 0 0.40 0 5 90 4
2 1 0 0.40 0 5 90 6
3 1 0 0.40 0 5 90 7
4 1 0 0.40 0 5 90 11
5 2 0 1.32 0 7 90 5
6 2 0 1.32 0 7 90 7
7 2 0 1.32 0 7 90 11
8 3 1 5.78 0 3 85 0
9 3 1 5.78 0 3 85 2
10 4 1 5.98 1 3 58 2
model <- lme(outcome ~ S + BT + A + AT*Time, random = ~ 1|ID,
data = df, na.action = na.exclude, method = "REML")
library(cAIC4)
cAIC(model)
Could anything in the model specification be a possible issue? The data is unbalanced with a different number of measurements for each ID and irregular time intervals.
Additional note: I want to use cAIC
for model comparison in terms of the random effects, since the LRT does not seem a valid way to compare mixed models in many cases (especially more complex models).
EDIT: after some days, the terminal error does not happen anymore, however an error occurs when running cAIC
:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'crossprod': error in evaluating the argument 'x' in selecting a method for function 'crossprod': non-conformable arguments
This happens only for the model with a specific variance-covariance structure for the residuals (and intercepts only), since it now works for random intercepts and random intercepts + slopes models.
If my data contains missings, this results in an additional warning:
In addition: Warning message:
In RLRsim::extract.lmeDesign(m) :
Removing incomplete cases from supplied data.