## load data
data(bmt)
bmt = transform(bmt, d4=d2+d3)
A = as.numeric(bmt$group>1)
X = as.matrix(bmt[,c('z1','z3','z5')])
## Composite variable strategy,
## nonparametric estimation without covariates
fit1 = surv.tteICE(A, bmt$t2, bmt$d4, "composite")
## Hypothetical strategy (natural effects),
## nonparametric estimation with inverse probability weighting
fit2 = surv.tteICE(A, bmt$t2, bmt$d4, "natural", X, method='ipw')
## nonparametric estimation with weights as inverse propensity score
ps = predict(glm(A ~ X, family='binomial'), type='response')
w = A/ps + (1-A)/(1-ps)
fit2 = surv.tteICE(A, bmt$t2, bmt$d4, "natural", weights=w)
## Hypothetical strategy (removing intercurrent events),
## semiparametrically efficient estimation with covariates
fit3 = surv.tteICE(A, bmt$t2, bmt$d4, "removed", X, method='eff')
Run the code above in your browser using DataLab