estimate_gam: Estimate residual treatment effect after taking into account...

Description Usage Arguments Value Examples

View source: R/estimate_gam.R

Description

Estimate residual treatment effect after taking into account longitudinal surrogate marker with a GAM'

Usage

1
estimate_gam(y_t, y_c, X_t, X_c, verbose = FALSE, ...)

Arguments

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

Value

estimate of residual treatment effect

Examples

 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_gam(y_t = y_t, y_c = y_c, X_t = X_t, X_c = X_c)

denisagniel/longsurr documentation built on March 1, 2020, 3:35 a.m.