Description Usage Arguments Value Examples
View source: R/presmooth_data.R
Pre-smooth sparse longitudinal data
1 | presmooth_data(obs_data, ...)
|
obs_data |
data.frame or tibble containing the observed data, with columns |
... |
additional arguments to pass to the function PCA function |
list containing matrices X_t
and X_c
, which are the smoothed surrogate values for the treated and control groups, respectively, for use in downstream analyses
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(dplyr)
library(longsurr)
obs_data <-
generate_discontinuous_data(n = 50, n_i = 5, delta_s = 0.5,
k = 1, s_y = 0.1, s_x = 0.1)$obs_ds
head(obs_data)
presmooth_X <- presmooth_data(obs_data)
wide_ds <- full_data %>%
dplyr::select(id, a, tt, x, y) %>%
tidyr::spread(tt, x)
y_t <- wide_ds %>%
filter(a == 1) %>%
pull(y)
y_c <- wide_ds %>%
filter(a == 0) %>%
pull(y)
X_t <- presmooth_X$X_t
X_c <- presmooth_X$X_c
estimate_surrogate_value(y_t = y_t, y_c = y_c,
X_t = X_t, X_c = X_c, method = 'linear')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.