Closed prestevez closed 1 year ago
I noticed a bug whereby panelmatch objects created with PanelMatch refined using Mahalanobis distance were missing the max.match.size attribute.
PanelMatch
max.match.size
## Using CRAN's PanelMatch v2.0.1 PM.results.none <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem", refinement.method = "none", data = dem, match.missing = TRUE, size.match = 5, qoi = "att", outcome.var = "y", lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE) #Extract the matched.set object msets.none <- PM.results.none$att #Call PanelMatch with refinement PM.results.maha <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem", refinement.method = "mahalanobis", # use Mahalanobis distance data = dem, match.missing = TRUE, covs.formula = ~ tradewb, size.match = 5, qoi = "att" , outcome.var = "y", lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE) msets.maha <- PM.results.maha$att PM.results.psm <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem", refinement.method = "ps.match", # use Mahalanobis distance data = dem, match.missing = TRUE, covs.formula = ~ tradewb, size.match = 5, qoi = "att" , outcome.var = "y", lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE) msets.psm <- PM.results.psm$att attr(msets.none, "max.match.size") #> NULL attr(msets.psm, "max.match.size") #> 5 attr(msets.maha, "max.match.size") #> NULL # <---- This should be five
I noticed that the attribute was not set in the helper function perform_refinement, so this was added toward the end of the function.
perform_refinement
# Call PanelMatch without any refinement PM.results.none <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem", refinement.method = "none", data = dem, match.missing = TRUE, size.match = 5, qoi = "att", outcome.var = "y", lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE) #Extract the matched.set object msets.none <- PM.results.none$att #Call PanelMatch with refinement PM.results.maha <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem", refinement.method = "mahalanobis", # use Mahalanobis distance data = dem, match.missing = TRUE, covs.formula = ~ tradewb, size.match = 5, qoi = "att" , outcome.var = "y", lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE) msets.maha <- PM.results.maha$att PM.results.psm <- PanelMatch(lag = 4, time.id = "year", unit.id = "wbcode2", treatment = "dem", refinement.method = "ps.match", # use Mahalanobis distance data = dem, match.missing = TRUE, covs.formula = ~ tradewb, size.match = 5, qoi = "att" , outcome.var = "y", lead = 0:4, forbid.treatment.reversal = FALSE, use.diagonal.variance.matrix = TRUE) msets.psm <- PM.results.psm$att attr(msets.none, "max.match.size") #> NULL attr(msets.psm, "max.match.size") #> 5 attr(msets.maha, "max.match.size") #> 5 # <---- Correct attribute
Closing this, as other pull request was integrated
I noticed a bug whereby panelmatch objects created with
PanelMatch
refined using Mahalanobis distance were missing themax.match.size
attribute.Bug
prestevez/PanelMatch@mahalanobis-match-size-fix
I noticed that the attribute was not set in the helper function
perform_refinement
, so this was added toward the end of the function.