Mediation analysis in panel data

Hi All,

Currently working on panel data and looking for help in mediation analysis-

Here I tried the code-
model.M <- lm(data2$M ~ data2$X + factor(data$firmid) , data2)
model.Y <- lm(data2$Y ~ data2$X+ data2$M + factor(data$firmid), data2)
results <- mediation::mediate(model.M, model.Y, treat='data2$X', mediator='data2$Y',boot=TRUE, sims=1)

But the code is giving an error-

Error in if (xhat == 0) out <- 1 else { :
missing value where TRUE/FALSE needed

How to resolve this?
Is there any other method to perform mediation analysis for panel data plz suggest


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.