kosukeimai / mediation

R package mediation
58 stars 29 forks source link

Error in offset(years.in.study) : object 'years.in.study' not found #48

Open jordanjohnlee24 opened 1 year ago

jordanjohnlee24 commented 1 year ago

Hello,

I am currently running a causal mediation analysis for a clinical trial where my mediator model uses a negative binomial regression model and my outcome model uses a logistic regression model.

model.x <- glm.nb(total.malaria.incident.events ~ Txarm + offset(years.in.study), data = delivery.analysis) model.y = glm(compositeBO ~ Txarm + total.malaria.incident.events + offset(years.in.study), family = "binomial", data = delivery.analysis) m.out = mediate(malaria.glm.nb, model.3.malaria.compositeBO, treat = "Txarm", mediator = "total.malaria.incident.events", boot=T)

However, I get the following error: Error in offset(years.in.study) : object 'years.in.study' not found Does the mediate package allow for an "offset" function to be in the model because the time each participant contributes varies? If so, how can I correct this error? If not, is there another way to handle these models?

Thanks in advance!