synth-inference / synthdid

Synthetic difference in differences
https://synth-inference.github.io/synthdid
BSD 3-Clause "New" or "Revised" License
262 stars 98 forks source link

Proposal to enhance stopping criterion in sc.weight.fw.covariates #116

Open PetraTschuchnig opened 9 months ago

PetraTschuchnig commented 9 months ago

When using the sc.weight.fw.covariates function, the stopping criterion is currently defined as follows: while (t < max.iter && (t < 2 || vals[t - 1] - vals[t] > min.decrease^2)) {...}. However, during optimization with covariates, vals can increase from one iteration to the next, causing the difference vals[t - 1] - vals[t] to become negative. This can prematurely terminate the optimization task even if there's actually a deterioration. To prevent this issue, I suggest using the absolute difference abs(vals[t - 1] - vals[t]) as part of the stopping criterion, like so: while (t < max.iter && (t < 2 || abs(vals[t - 1] - vals[t]) > min.decrease^2)) {...}. If you find this change reasonable, I would be happy to push the changes to a fork and create a merge request.

davidahirshberg commented 9 months ago

Good catch. Please submit a PR.