ebenmichael / augsynth

Augmented Synthetic Control Method
MIT License
147 stars 52 forks source link

Issue with matching prior to weighting #67

Closed anjoung closed 2 years ago

anjoung commented 2 years ago

Just trying out this package, so wanted to run a simple example where I match on total population prior to weighting. I run the following command:

spool_syn2 <- multisynth(outcome~ legal | educ_median + familyincome + nwshare + percap_MD | totpop, county_id, year, AHA, 
                        nu = 0, n_leads = 4, n_lags = 15, time_cohort = TRUE)

However, I get the following error:

Error in get_knn_donors(trt, Z, donors, k) : 
  Number of neighbors for knn not selected, please choose k.

Is my syntax incorrect? Or is it likely that my data is structured incorrectly?

anjoung commented 2 years ago

One small comment. My matching variable is time-invariant.

anjoung commented 2 years ago

Sorry for back to back comments. I did find this code you wrote (https://rdrr.io/github/ebenmichael/augsynth/src/tests/testthat/test_multisynth_covariates.R) and my best guess from reading it is that I need to include an option where I set k equal to the size of my donor pool?

ebenmichael commented 2 years ago

Hi sorry for the delay, you'll have to set the number of neighbors as a keyword argument with k = XXX. I'll make sure to add that to the documentation