chaisemartinPackages / did_multiplegt_dyn

|| Stata | R || Estimation of event-study Difference-in-Difference (DID) estimators in designs with multiple groups and periods, and with a potentially non-binary treatment that may increase or decrease multiple times.
38 stars 8 forks source link

SOLVED [Problem with the setting of the Placebo] #79

Closed lbiagini75 closed 3 months ago

lbiagini75 commented 3 months ago

After the recent update of the package, I have rerun the code that, just two days ago, did not have problems. The setting is: "did_multiplegt_dyn( df = dataset, outcome = outcome_var, group = group_var, time = time_var, treatment = treatment_var, design = list(2, "console"),

design 2 enter and exit

normalized = TRUE, normalized_weights = TRUE, controls = controls_var, weight = "weights", cluster = cluster_names, ci_level = 95, graph_off = FALSE, save_results = results_name, save_sample = T, dont_drop_larger_lower = F, drop_if_d_miss_before_first_switch = T ) but after the summary, I have incurred this error "Error in withCallingHandlers(expr, warning = function(w) if (inherits(w, : object 'p_jointeffects' not found"

@DiegoCiccia, the data is the same as what I included in the previous email.

lbiagini75 commented 3 months ago

If one specifies the number of times of the placebo, this error does not occur.

DiegoCiccia commented 3 months ago

Hi Luigi, I think that I fixed your issue in the new development version of DYN. You can find it on Github:

library(devtools)
devtools::install_github("chaisemartinPackages/did_multiplegt_dyn/R")

Let me know if this solves your issue. Best, Diego

lbiagini75 commented 3 months ago

Thank you, Diego, The error is fixed. I have developed a script to update each day the package did_multiplegt_dyn, I hope that is useful.

" timestamp_file <- "~/package_update_timestamp.txt"

# Check if the package was updated today
was_updated_today <- function(timestamp_file) {
  if (file.exists(timestamp_file)) {
    last_update <- file.info(timestamp_file)$mtime
    return(as.Date(last_update) == Sys.Date())
  } else {
    return(FALSE)
  }
}

# Update the package and the timestamp file
update_package <- function() {
  devtools::install_github("chaisemartinPackages/did_multiplegt_dyn/R",  force = TRUE, dependencies = TRUE)
  write(Sys.time(), file = timestamp_file)
}

if (!was_updated_today(timestamp_file)) {
  update_package()
} else {
  message("The package has already been updated today.")
}
"