setzler / eventStudy

R package and guide for performing event studies with heterogeneous dynamic effects.
MIT License
71 stars 18 forks source link

Error Message #29

Open tweedmann opened 1 year ago

tweedmann commented 1 year ago

Hello there, I am trying to use your packe to create an Event Study Plot and when I use your ES() function I receive the following error message:

Error in eval(bysub, x, parent.frame()) : object 'treatment_month' not found

where treatment_month is my "onset_time_var". Have you encountered something like this before?

Thanks in advance

davidnov commented 1 year ago

Hi @tweedmann, can you share your code (or the ES()-relevant part of it)? Hard to diagnose based on the information you have provided.

mrasska commented 6 months ago

Hi @davidnov !

I encounter the same error.

INFO [2024-03-13 13:55:25] Beginning ES.
INFO [2024-03-13 13:55:25] Beginning data stacking.
INFO [2024-03-13 13:55:25] Given min_control_gap='1' & max_control_gap='Inf', no control units found for treatment_week='12'
INFO [2024-03-13 13:55:25] Successfully produced a stacked dataset with 0 rows.
Error in eval(bysub, x, parent.frame()) : 
  object 'treatment_week' not found

Here is my code:

df_first <- econometrics_weekly_uploads[which(econometrics_weekly_uploads$week>'2017-01'),]
df_first <- df_first[which(df_first$week<'2017-23'),]

df_event <- subset(df_first, select=c('week', 'channel','id_0'))
df_event$nb_week <- gsub("2017-","",as.character(df_event$week))
df_event$nb_week <- as.integer(df_event$nb_week)
df_event$treatment_week <- as.integer(12)

df_event <- setDT(df_event)

results <- ES(long_data=df_event, outcomevar="id_0", 
              unit_var="channel", cal_time_var="nb_week", 
              onset_time_var="treatment_week", cluster_vars="channel")

My database is structured as follows: image image

Thank you in advance!