tvmb {tvmediation}R Documentation

Time Varying Mediation Function: Binary Outcome and Two Treatment Groups

Description

Function to estimate the time-varying mediation effect and bootstrap standard errors, involving two treatment groups and binary outcome.

Usage

tvmb(
  treatment,
  t.seq,
  mediator,
  outcome,
  span = 0.75,
  plot = FALSE,
  CI = "boot",
  replicates = 1000,
  verbose = FALSE
)

Arguments

treatment

a vector indicating treatment group

t.seq

a vector of unique time points for each observation

mediator

matrix of mediator values in wide format

outcome

matrix of outcome values in wide format

span

Numeric value of the span to be used for LOESS regression. Default = 0.75.

plot

TRUE or FALSE for producing plots. Default = "FALSE". (OPTIONAL ARGUMENT)

CI

"none" or "boot" method of deriving confidence intervals. Default = "boot". (OPTIONAL ARGUMENT)

replicates

Number of replicates for bootstrapping confidence intervals. Default = 1000. (OPTIONAL ARGUMENT)

verbose

TRUE or FALSE for printing results to screen. Default = "FALSE". (OPTIONAL ARGUMENT)

Value

timeseq

time points of estimation

alpha_hat

estimated treatment effect on mediator

CI.lower.a

CI lower limit for estimated coefficient alpha_hat

CI.upper.a

CI upper limit for estimated coefficient alpha_hat

gamma_hat

estimated treatment effect on outcome (direct effect)

CI.lower.g

CI lower limit for estimated coefficient gamma_hat

CI.upper.g

CI upper limit for estimated coefficient gamma_hat

beta_hat

estimated mediator effect on outcome

CI.lower.b

CI lower limit for estimated coefficient beta_hat

CI.upper.b

CI upper limit for estimated coefficient beta_hat

tau_hat

estimated treatment effect on outcome (total effect)

CI.lower.t

CI lower limit for estimated coefficient tau_hat

CI.upper.t

CI upper limit for estimated coefficient tau_hat

medEffect

time varying mediation effect

CI.lower

CI lower limit for medEffect

CI.upper

CI upper limit for medEffect

Plot Returns

  1. plot1_a plot for alpha_hat with CIs over t.seq

  2. plot2_g plot for gamma_hat with CIs over t.seq

  3. plot3_b plot for beta_hat with CIs over t.seq

  4. plot4_t plot for tau_hat with CIs over t.seq

  5. MedEff plot for medEffect over t.seq

  6. MedEff_CI plot for medEffect with CIs over t.seq

  7. bootstrap plot for estimated medEffect from bootstrapped samples over t.seq

Note

  1. Currently supports 2 treatment groups

  2. ** IMPORTANT ** An alternate way of formatting the data and calling the function is documented in detail in the tutorial for the tvmb() function.

References

  1. Fan, J. and Gijbels, I. Local polynomial modelling and its applications: Monographs on statistics and applied probability 66. CRC Press; 1996.

  2. Fan J, Zhang W. Statistical Estimation in Varying Coefficient Models. The Annals of Statistics. 1999;27(5):1491-1518.

  3. Fan J, Zhang JT. Two-step estimation of functional linear models with applications to longitudinal data. Journal of the Royal Statistical Society: Series B (Statistical Methodology). 2000;62(2):303-322.

  4. Baker TB, Piper ME, Stein JH, et al. Effects of Nicotine Patch vs Varenicline vs Combination Nicotine Replacement Therapy on Smoking Cessation at 26 Weeks: A Randomized Clinical Trial. JAMA. 2016;315(4):371.

  5. B. Efron, R. Tibshirani. Bootstrap Methods for Standard Errors, Confidence Intervals, and Other Measures of Statistical Accuracy. Statistical Science. 1986;1(1):54-75.

Examples

## Not run: data(smoker)

# REDUCE DATA SET TO ONLY 2 TREATMENT CONDITIONS (EXCLUDE COMBINATION NRT)
smoker.sub <- smoker[smoker$treatment != 4, ]

# GENERATE WIDE FORMATTED MEDIATORS
mediator <- LongToWide(smoker.sub$SubjectID,
                       smoker.sub$timeseq,
                       smoker.sub$NegMoodLst15min)

# GENERATE WIDE FORMATTED OUTCOMES
outcome <- LongToWide(smoker.sub$SubjectID,
                      smoker.sub$timeseq,
                      smoker.sub$smoke_status)

# GENERATE A BINARY TREATMENT VARIABLE
trt <- as.numeric(unique(smoker.sub[, c("SubjectID","varenicline")])[, 2])-1

# GENERATE A VECTOR OF UNIQUE TIME POINTS
t.seq <- sort(unique(smoker.sub$timeseq))

# COMPUTE TIME VARYING MEDIATION ANALYSIS USING BOOTSTRAPPED CONFIDENCE INTERVALS
results <- tvmb(trt, t.seq, mediator, outcome)
## End(Not run)


[Package tvmediation version 1.1.0 Index]