I keep encountering a problem while running tidysynth. I'm pretty new to R and I'm applying the tidysynth manual to my data. I keep getting the message "Error in unique(data$.id) : argument "data" is missing, with no default" after the "generate_control() command. Here are my codes.
synth_js<- synth %>%
synthetic_control (outcome = q69, # outcome (job satisfaction)
unit = name, # unit index in the panel data
time = year, # time index in the panel data
i_unit = "Securities and Exchange Commission, All Other", # unit where the intervention occurred
i_time = 2014, # time period when the intervention occurred
generate_placebos= T) # generate placebo synthetic controls (for inference) %>%)
# Generate the aggregate predictors used to fit the weights
# lnemp lnsal avgtenure profpc collegepc d_politicize richardson from 2006 - 2014
generate_predictor(time_window = 2006:2014,
salary = mean(lnsal, na.rm = T),
tenure = mean(avgtenure, na.rm = T),
professionals = mean(profpc, na.rm = T),
college = mean(collegepc, na.rm = T),
politicize = mean(d_politicize, na.rm = T),
ideology = mean(richardson, na.rm = T)) %>%
# average Job Satisfaction in the donor pool from 2006 - 2014
generate_predictor(time_window = 2006:2014,
job_satisfaction = mean(q69, na.rm = T)) %>%
# Lagged Job Satisfaction
generate_predictor(time_window = 2008,
js_2008 = q69) %>%
generate_predictor(time_window = 2010,
js_2010 = q69) %>%
generate_predictor(time_window = 2011,
js_2011 = q69) %>%
generate_predictor(time_window = 2012,
js_2012 = q69) %>%
generate_predictor(time_window = 2013,
js_2013 = q69) %>%
# Generate the fitted weights for the synthetic control
generate_weights(optimization_window = 2006:2014, # time to use in the optimization task
margin_ipop = .02,sigf_ipop = 7,bound_ipop = 6 # optimizer options) %>%
# Generate the synthetic control
generate_control()
I keep getting the following error
+ generate_control()
Error in unique(data$.id) : argument "data" is missing, with no default
Does anyone know why this happens? Thanks.