Closed matthewolckers closed 4 years ago
Hi @matthewolckers , we actually do have the ability to handle moderating variables in the current version of the master branch (the master branch also has some other updates/fixes that are not currently on CRAN). You can just specify the moderating variable when you run PanelEstimate:
library(PanelMatch)
dem$moderating.thing <- 0
dem$moderating.thing <- ifelse(dem$wbcode2 > 100, 1, 2)
PM.results <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2",
treatment = "dem", refinement.method = "mahalanobis",
data = dem, match.missing = TRUE,
covs.formula = ~ I(lag(tradewb, 1:4)) + I(lag(y, 1:4)), # lags
size.match = 5, qoi = "att", outcome.var = "y",
lead = 0:4, forbid.treatment.reversal = FALSE,
use.diagonal.variance.matrix = TRUE)
PE.results <- PanelEstimate(sets = PM.results, data = dem, moderating.variable = "moderating.thing")
It would be great if you'd be willing to try out this functionality and offer any feedback. We want to add this in to the next update!
Thanks @adamrauh , that's great news! I will test it out in the coming week.
@adamrauh I just tried out the modifying.variable
functionality. It's great!
The only suggestion that came to mind was to change the default behaviour of summary(PE.results)
and plot(PE.results)
when the modifying variable is included. I expected the results to be displayed in a single table and the plot to have both effects with a legend.
I am a beginner user with R so perhaps keeping each results table separate is optimal.
@adamrauh when I run the code you provided, I get this error: "Error in PanelEstimate(sets = PM.results, data = dem, moderating.variable = "moderating.thing") : unused argument (moderating.variable = "moderating.thing")" Any idea how I can fix this?
Hi @matthewolckers , we actually do have the ability to handle moderating variables in the current version of the master branch (the master branch also has some other updates/fixes that are not currently on CRAN). You can just specify the moderating variable when you run PanelEstimate:
library(PanelMatch) dem$moderating.thing <- 0 dem$moderating.thing <- ifelse(dem$wbcode2 > 100, 1, 2) PM.results <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem", refinement.method = "mahalanobis", data = dem, match.missing = TRUE, covs.formula = ~ I(lag(tradewb, 1:4)) + I(lag(y, 1:4)), # lags size.match = 5, qoi = "att", outcome.var = "y", lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE) PE.results <- PanelEstimate(sets = PM.results, data = dem, moderating.variable = "moderating.thing")
It would be great if you'd be willing to try out this functionality and offer any feedback. We want to add this in to the next update!
@ujefferson My guess is that you are using the version of PanelMatch from CRAN that doesn't have the moderating.variable
functionality included yet.
You need to use the latest development version of PanelMatch downloaded directly from GitHub.
See here: https://github.com/insongkim/PanelMatch#installation-instructions
Thanks, that helped
@ujefferson My guess is that you are using the version of PanelMatch from CRAN that doesn't have the
moderating.variable
functionality included yet.You need to use the latest development version of PanelMatch downloaded directly from GitHub.
See here: https://github.com/insongkim/PanelMatch#installation-instructions
@matthewolckers Thanks for helping @ujefferson! We really appreciate it.
Just to give a better idea about the use of moderating.variable
: What we do is to create the matched set as usual, but within PanelEstimate
we (1) focus on the treated observations that take a specific value of the moderator (note that the moderator variable should be a categorical variable, but it can be either time-varying or time-invariant), and (2) estimate the effects using all the control observations (that may consist of those taking different values of the categorical variable). We do this for efficiency reasons. We will put some formal description in the future versions. Thank you very much.
Could the method be extended to allow analysis of heterogeneous treatment effects?
Instead of implementing difference-in-difference, a triple difference (sometimes referred to as a difference-in-difference with an interaction) could be taken. The user would specify the interaction term.