View source: R/grab-methods.R View source: R/grab-methods.R
grab_predictor_weights | R Documentation |
Extract the predictor variable weights generated by generate_weights()
from the
synth pipeline.
grab_predictor_weights(data, placebo = FALSE)
data |
nested data of type |
placebo |
boolean flag; if TRUE placebo values are returned as well (if available). Default is FALSE. |
tibble data frame
# Smoking example data
data(smoking)
smoking_out <-
smoking %>%
# initial the synthetic control object
synthetic_control(outcome = cigsale,
unit = state,
time = year,
i_unit = "California",
i_time = 1988,
generate_placebos=TRUE) %>%
# Generate the aggregate predictors used to generate the weights
generate_predictor(time_window=1980:1988,
lnincome = mean(lnincome, na.rm = TRUE),
retprice = mean(retprice, na.rm = TRUE),
age15to24 = mean(age15to24, na.rm = TRUE)) %>%
generate_predictor(time_window=1984:1988,
beer = mean(beer, na.rm = TRUE)) %>%
generate_predictor(time_window=1975,
cigsale_1975 = cigsale) %>%
generate_predictor(time_window=1980,
cigsale_1980 = cigsale) %>%
generate_predictor(time_window=1988,
cigsale_1988 = cigsale) %>%
# Generate the fitted weights for the synthetic control
generate_weights(optimization_window =1970:1988,
Margin.ipop=.02,Sigf.ipop=7,Bound.ipop=6) %>%
# Generate the synthetic control
generate_control()
# Grab the predictor weights data frame for the treated unit.
smoking_out %>% grab_predictor_weights()
# Grab the predictor weights data frame for the placebo units as well.
smoking_out %>% grab_predictor_weights(placebo=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.