estimate_surrogate_value: Estimate the surrogate value of a longitudinal marker

Description Usage Arguments Value Examples

View source: R/estimate_surrogate_value.R

Description

Estimate the surrogate value of a longitudinal marker

Usage

1
2
estimate_surrogate_value(y_t, y_c, X_t, X_c, method = c("gam", "linear",
  "kernel"), k = 3, bootstrap_samples = 0, alpha = 0.05, ...)

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

method

method for dimension-reduction of longitudinal surrogate, either 'gam', 'linear', or 'kernel'

bootstrap_samples

number of bootstrap samples to use for variance estimation. The default is 0, which estimates without providing a variance estimate.

Value

a tibble containing estimates, standard errors, and quantile-based confidence intervals for the residual treatment effect Deltahat_s_* and the proportion of treatment effect explained R_*

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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_surrogate_value(y_t = y_t, y_c = y_c, X_t = X_t, X_c = X_c, method = 'kernel')
estimate_surrogate_value(y_t = y_t, y_c = y_c, X_t = X_t, X_c = X_c, method = 'linear', bootstrap_sample = 50)

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