ssdavenport / microsynth

Synthetic controls for micro-level data
16 stars 9 forks source link

Microsynth function will not accept date variables #29

Open mjharris95 opened 11 months ago

mjharris95 commented 11 months ago

I kept getting this error when running the microsynth function:

Error in value[3L] : promise already under evaluation: recursive default argument reference or earlier problems?

I was able to resolve by converting my timevar, which was formatted as an R date variable to a numeric variable before feeding it to the function.

For example, if I start out with a column called year_month where entries look like "201905"

df  %<>%  mutate(time = ym(year_month))

synth <- microsynth(df, 
           idvar="id",
           timevar="time",
           intvar="int",
           match.out = c("var"))

will not work but

df  %<>%  mutate(time = ym(year_month)) %>%
                  mutate(time = as.numeric(time))

synth <- microsynth(df, 
           idvar="id",
           timevar="time",
           intvar="int",
           match.out = c("var"))

will work.

Thought I'd share in case others run into something similar!