library(dplyr)
data(full_data)
wide_ds <- full_data %>%
dplyr::select(id, a, tt, x, y) %>%
tidyr::spread(tt, x)
wide_ds_0 <- wide_ds %>% filter(a == 0)
wide_ds_1 <- wide_ds %>% filter(a == 1)
X_t <- wide_ds_1 %>% dplyr::select(`-1`:`1`) %>% as.matrix
y_t <- wide_ds_1 %>% pull(y)
X_c <- wide_ds_0 %>% dplyr::select(`-1`:`1`) %>% as.matrix
y_c <- wide_ds_0 %>% pull(y)
estimate_surrogate_value(y_t = y_t, y_c = y_c, X_t = X_t, X_c = X_c,
method = 'gam', var = FALSE)
estimate_surrogate_value(y_t = y_t, y_c = y_c, X_t = X_t, X_c = X_c,
method = 'linear', var = TRUE, bootstrap_sample = 50)
Run the code above in your browser using DataLab