Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to enhance standard error estimation for CI using placebo_se #128

Open
PetraTschuchnig opened this issue Oct 1, 2024 · 0 comments

Comments

@PetraTschuchnig
Copy link
Contributor

The current implementation of the placebo_se function uses the weights from the true treatment group as the initial weights for the placebo estimation (adjusted for the placebo number of control groups, N0). This initialization can lead to biased weights in the placebo evaluation, as it may cause the optimization to get stuck in a local minimum. To ensure that the placebo_se function works for all estimation methods (e.g., SDID, SC, DID, ...), the theta function in the placebo_se function should be modified as follows:

theta = function(ind) {
    N0 = length(ind)-N1
    noise.level = sd(apply(setup$Y[ind[1:(length(ind)-1)], 1:setup$T0], 1, diff))
    opts$min.decrease = 1e-05 * noise.level
    if((opts$zeta.omega/noise.level) > 1e-05){
      eta.omega = (N1 * (ncol(setup$Y) - setup$T0))^(1/4)
      opts$zeta.omega = eta.omega * noise.level
    }else{
      eta.omega = 1e-06
      opts$zeta.omega = eta.omega * noise.level
    }
    if((opts$zeta.lambda/noise.level) < 1e-05){
      eta.lambda = 1e-06
      opts$zeta.lambda = eta.lambda * noise.level
    }
    weights.boot = list()
    if(opts$update.lambda == TRUE){
      weights.boot$lambda = rep(1/setup$T0, setup$T0)
    }else{
      weights.boot$lambda = weights$lambda
    }
    if(opts$update.omega == TRUE){
      weights.boot$omega = rep(1/N0, N0)
    }else{
      weights.boot$omega = sum_normalize(weights$omega[ind[1:N0]])
    }
    do.call(synthdid_estimate, c(list(Y=setup$Y[ind,], N0=N0,  T0=setup$T0, weights=weights.boot), opts))
  }

If you find this change reasonable, I would be happy to push the changes to a fork and create a merge request.

(To know what the unbiased standard errors need to be, I used the specific function for each estimation method during the placebo evaluation, without applying options or weights from the true treatment group. For example, as theta function in the placebo_se function for SC I used:

theta = function(ind) {
    N0 = length(ind)-N1
    do.call(sc_estimate, c(list(Y=setup$Y[ind,], N0=N0,  T0=setup$T0)))
  }

If needed, I'd be happy to send you the code via email.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant