0

I would like some clarification on fitting a beta mixed model.

My dependent variable is the proportion of days that patients take medication. For every patient(Patient.ID), the pharmacy either had an intervention or no intervention (Int_code of 0/1). below is my model

library(glmmTMB)

Model5 <- glmmTMB(Proportion ~ Int_Name + (1|Patient.ID), data, family=list(family="beta",link="logit"))

I keep getting the the following error:

enter image description here

Pitouille
  • 1,482

1 Answers1

0

I'd guess your problem is that the proportion is sometimes 0 or 1, which is a problem, because of the logit link function (you end of taking the log of 0 in either case). You can avoid such issues by using a random effects logistic regression that models the number of days directly instead of the proportion. Then you could do this with the glmer function from the lme4 package: glm( cbind(days_taken, days_not_taken) ~ Int_Name + (1|Patient.ID), family = binomial(link="logit")).

Björn
  • 32,022
  • Bjorn.

    This was really helpful I really appreciate your assistance. I really should have asked for help sooner. Things make sense now.

    – Lindo M Nov 24 '21 at 20:58