我在运行 tidysynth 时一直遇到问题。我对 R 很陌生,我正在将 tidysynth 手册应用于我的数据。在“generate_control() 命令之后,我不断收到消息“唯一错误(数据 $.id):参数“数据”丢失,没有默认值”。这是我的代码。
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()
我不断收到以下错误
+ generate_control()
Error in unique(data$.id) : argument "data" is missing, with no default
有谁知道为什么会这样?谢谢。