kdonnay / mwa

Matched Wake Analysis
GNU Lesser General Public License v3.0
2 stars 1 forks source link

Error when using covariates with the formula "dependent_post - dependent_pre ~ treatment" #2

Closed mehmeterdemarslan closed 3 months ago

mehmeterdemarslan commented 3 months ago

Hi,

I am receiving the error below when I include covariates in the estimation and use the formula "dependent_post - dependent_pre ~ treatment" for diff-in-diff.

Error in model.frame.default(formula = dependent_post - dependent_pre ~ : object is not a matrix

I guess it is related to the part in mwa source code where it handles the estimation formula using the covariates given by the user (lines 434-446 in mwa.R). When I checked, I see that part of the code gives the final formula as:

[1] "dependent_post - dependent_pre ~ treatment + troops + pop_1km + elev_1km + nl_1km + logdist + dependent_post - dependent_pre ~ treatment"

However, it works well when I use the default formula ("dependent_post ~ dependent_pre + treatment") and covariates:

[1] "dependent_post ~ dependent_pre + troops + pop_1km + elev_1km + nl_1km + logdist + treatment"

I guess it is a simple glitch where the former formula input does not split in line 435, then added up again altogether at the end of final formula.

Thanks in advance for your time!

kdonnay commented 3 months ago

Hi Mehmet,

Thank you for flagging this bug. I also assume this issue arises from some error in how the formula you entered is parsed in that segment of the code.

I am still actively maintaining mwa but at reduced capacity. Your issue has been added to the things that I will aim to fix for the next release, most likely later this summer/early fall.

My apologies for the delay in addressing this. I hope in the meantime the "standard" diff-in-diff estimation formula that works without issue is a useful alternative.

Thanks again for flagging this!

mehmeterdemarslan commented 3 months ago

Hi Karsten,

Many thanks for the reply. Yes, standard formula is working just well.

Best,

Mehmet