[R-sig-ME] Mixed models with a dichotomous outcome, random slopes, and accounting for autocorrelation
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Tue Apr 4 15:47:18 CEST 2023
This seems to have slipped through the cracks, sorry about that.
lme4 doesn't do correlation structures, but glmmTMB does. The closest
analogue would be something like
## this should be observation number within group
dat$times <- numFactor(dat$times)
model2 <- glmmTMB(continuous_outcome ~ 1 + Predictor_X + Day +
(1 + Day | Team / Year) + ar1(times + 0 | Team:Year)
(your random effect has two | in it; was the second meant to be a / ?)
See https://glmmtmb.github.io/glmmTMB/articles/covstruct.html
On 2023-01-25 5:13 p.m., Adam Roebuck wrote:
> Hello,
>
> I am attempting to set up a multilevel model with two grouping variables
> (team and year), random slopes for day of the year, and accounting for
> autocorrelation. I have a number of different outcome variables I can use.
> When the outcome variable is continuous, I can set up a simple growth model
> using the nlme package that looks something like the following:
>
> model1 <- lme(continuous_outcome ~ 1 + Predictor_X + Day,
>
> random = ~1 + Day | Team | Year, data = dat, method = "REML",
>
> control=list(opt="optim"), correlation = corAR1()
>
> However, I now want to build a model with a dichotomous outcome variable.
> As far as I know, nlme cannot account for all of the above and a
> dichotomous outcome. I have, however, seen a few references to glmer (in
> the lme4 package) and glmmTMB being capable of such. I've gone back through
> the archives, though, and am not seeing any clear explanations on how to
> set up such a model.
>
> Using the parameters above and the variables I specified, could someone
> please help specify what that model might look like in R or at least point
> me in the right direction?
>
> Thanks,
> Adam
>
--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics
> E-mail is sent at my convenience; I don't expect replies outside of
working hours.
More information about the R-sig-mixed-models
mailing list