0

I'm trying to merge a zeroinfl Poisson regression with a lmer model. How can I do that?

cro<-zeroinfl(carbapenem~time+COVID-19+time*COVID-19+month+(time|ORGANISM),data=all_mall)

This is the error it gives:

Error in X1 | ORGANISM : 
  operations are possible only for numeric, logical or complex types
Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30
x peng
  • 3
  • 1
  • Please make this question *reproducible*. This includes sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))`). Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Apr 22 '22 at 13:27
  • 1
    You could look at the glmmTMB package; https://cran.r-project.org/web/packages/glmmTMB/index.html – user20650 Apr 22 '22 at 13:30
  • Thank you guys!! – x peng Apr 22 '22 at 16:50

1 Answers1

0

Probably the easiest way would be to use a Bayesian approach with the brms package. For example,

brm(carbapenem~time+`COVID-19`+time*`COVID-19`+month+(time|ORGANISM),
    data = all_mall, family = zero_inflated_poisson())

Note that to treat COVID-19 as a variable, you should enclose it in back-ticks.

DaveArmstrong
  • 18,377
  • 2
  • 13
  • 25
  • THANK YOU SO MUCH!!! didn't expect to receive an answer so quickly...This is great help, thank you!!!!! – x peng Apr 22 '22 at 16:49