I'm trying to fit a quadratic function to an HLM model using R's nlme
.
My data looks like this:
Data <- structure(list(X = c(2L, 3L, 4L, 5L, 22L, 23L),
userId = c("0014","0014", "0014", "0014", "0059", "0059"),
who_score = c(24L, 60L, 40L, 48L, 80L, 92L),
response_date = c("2021-06-02 00:00:00", "2021-06-22 00:00:00",
"2021-07-07 00:00:00", "2021-07-22 00:00:00", "2021-08-05 00:00:00", "2021-08-23 00:00:00"),
previous_response_date = c("2021-06-02 00:00:00", "2021-06-02 00:00:00",
"2021-06-22 00:00:00", "2021-07-07 00:00:00", "2021-07-29 00:00:00", "2021-08-05 00:00:00"),
days_since_last_response = c(0, 20, 15, 15, 7, 18), user_join_date = c("2021-06-02", "2021-06-02", "2021-06-02", "2021-06-02", "2021-07-29", "2021-07-29"),
night = c(0, 0, 0, 0, 0, 0),
morning = c(0, 31, 14, 28, 14, 20),
evening = c(0, 9, 11, 11, 10, 13),
noon = c(0, 12, 20, 15, 10, 21),
total_daily_incoming = c(0, 52,45, 54, 34, 54),
active_day = c(0, 13, 13, 13, 3, 15),
response_ind = c(0L, 1L, 2L, 3L, 0L, 1L),
id = c("0014", "0014", "0014", "0014", "0059", "0059"),
utcOffset = c(-5, -5, -5, -5, -4, -4)),
row.names = c(NA, 6L), class = "data.frame")
My model is as follows.
mod4 <-
lme(
who_score ~ response_ind + I(response_ind^2) +
total_daily_incoming + active_day +
active_day * total_daily_incoming,
random = ~ response_ind + I(response_ind^2) | userId,
data = Data1,
method = "ML", control =list(msMaxIter = 1000, msMaxEval = 1000)
)
summary(mod4)
intervals(mod4)
but no matter what I do I keep getting this error
Error in lme.formula(who_score ~ response_ind + I(response_ind^2) + total_daily_incoming + : nlminb problem, convergence error code = 1 message = singular convergence (7)
I have tried increasing the number of iterations, dropping from the data participants with less then 3 observations, but nothing works. Help...
Thank you