get_delta_s: Estimate residual treatment effect

Description Usage Arguments Value Examples

View source: R/get_delta_s.R

Description

Estimate residual treatment effect

Usage

1
get_delta_s(y_t = NULL, y_c = NULL, X_t = NULL, X_c = NULL)

Arguments

y_t

vector of outcomes in the treatment arm.

y_c

vector of outcomes in the control arm.

X_t

matrix of surrogate values in the treatment arm.

X_c

matrix of surrogate values in the control arm.

Value

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

Examples

 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')

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