Mediation analysis in survival context with robust standard errors taking the weights into account via influence function computations. Mediator and exposure must be factors. This is based on numerical derivative wrt parameters for weighting. See vignette for more examples.

mediatorSurv(
  survmodel,
  weightmodel,
  data = data,
  wdata = wdata,
  id = "id",
  silent = TRUE,
  ...
)

Arguments

survmodel

with mediation model (binreg, aalenMets, phreg)

weightmodel

mediation model

data

for computations

wdata

weighted data expansion for computations

id

name of id variable, important for SE computations

silent

to be silent

...

Additional arguments to survival model

Author

Thomas Scheike

Examples


n <- 400
dat <- kumarsimRCT(n,rho1=0.5,rho2=0.5,rct=2,censpar=c(0,0,0,0),
          beta = c(-0.67, 0.59, 0.55, 0.25, 0.98, 0.18, 0.45, 0.31),
    treatmodel = c(-0.18, 0.56, 0.56, 0.54),restrict=1)
dfactor(dat) <- dnr.f~dnr
dfactor(dat) <- gp.f~gp
drename(dat) <- ttt24~"ttt24*"
dat$id <- 1:n
dat$ftime <- 1

weightmodel <- fit <- glm(gp.f~dnr.f+preauto+ttt24,data=dat,family=binomial)
wdata <- medweight(fit,data=dat)

### fitting models with and without mediator
aaMss2 <- binreg(Event(time,status)~gp+dnr+preauto+ttt24+cluster(id),data=dat,time=50,cause=2)
aaMss22 <- binreg(Event(time,status)~dnr+preauto+ttt24+cluster(id),data=dat,time=50,cause=2)

### estimating direct and indirect effects (under strong strong assumptions) 
aaMss <- binreg(Event(time,status)~dnr.f0+dnr.f1+preauto+ttt24+cluster(id),
                data=wdata,time=50,weights=wdata$weights,cause=2)
## to compute standard errors , requires numDeriv
library(numDeriv)
ll <- mediatorSurv(aaMss,fit,data=dat,wdata=wdata)
summary(ll)
#> 
#>    n events
#>  800    398
#> 
#>  400 clusters
#> coeffients:
#>              Estimate   Std.Err      2.5%     97.5% P-value
#> (Intercept) -0.134117  0.166703 -0.460848  0.192614  0.4211
#> dnr.f01      0.301168  0.253081 -0.194862  0.797197  0.2340
#> dnr.f11      0.156053  0.066805  0.025116  0.286989  0.0195
#> preauto      0.012287  0.239470 -0.457065  0.481639  0.9591
#> ttt24        0.393456  0.262283 -0.120609  0.907521  0.1336
#> 
#> exp(coeffients):
#>             Estimate    2.5%  97.5%
#> (Intercept)  0.87449 0.63075 1.2124
#> dnr.f01      1.35144 0.82295 2.2193
#> dnr.f11      1.16889 1.02543 1.3324
#> preauto      1.01236 0.63314 1.6187
#> ttt24        1.48209 0.88638 2.4782
#> 
#> 
## not run bootstrap (to save time)
## bll <- BootmediatorSurv(aaMss,fit,data=dat,k.boot=500)