I have some problems getting predictions from a mixed model with autocor. When I fit a mixed model with just one covariable and try to get the fitted without the random effect I use re_formula = NA, and the predictions should be equals for the same value on the covariable, but it doesn’t happen. When I try to predict without autocor it works fine.
I show you a toy example to guide you.
set.seed(123)
data <- data.frame(nhc = factor(rep(1:5, each = 10)), time = seq(0.5,5, by = 0.5),
con = rlnorm(50,0.3428,0.614))
library(brms)
library(splines)
no_work <- brm(con ~ ns(time,4) + (1|nhc),
data = data, autocor = cor_ar(~time|nhc), control = list(adapt_delta = 0.99))
work <- brm(con ~ ns(time,4) + (1|nhc),
data = data, control = list(adapt_delta = 0.99))
data.frame(Prediction=exp(fitted(no_work, re_formula = NA)[,1]), nhc=data$nhc, time=data$time)
data.frame(Prediction=exp(fitted(work, re_formula = NA)[,1]), nhc=data$nhc, time=data$time)
The prediction for the same time should be the same, but with autocor it is not.
--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/dae8477d-41bb-40c4-b00d-0cea49ea4207%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.