Description Usage Arguments Value Examples
View source: R/estimate_linear.R
Estimate residual treatment effect after taking into account longitudinal surrogate marker with a linear model
1 | estimate_linear(y_t, y_c, X_t, X_c, verbose = FALSE, ...)
|
y_t |
vector of n1 outcome measurements for treatment group |
y_c |
vector of n0 outcome measurements for control or reference group |
X_t |
n1 x T matrix of longitudinal surrogate measurements for treatment group |
X_c |
n0 x T matrix of longitudinal surrogate measurements for control or reference group |
estimate of residual treatment effect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | library(dplyr)
library(longsurr)
full_data <-
generate_discontinuous_data(n = 50, n_i = 5, delta_s = 0.5,
k = 1, s_y = 0.1, s_x = 0.1)$full_ds
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_linear(y_t = y_t, y_c = y_c, X_t = X_t, X_c = X_c)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.