# NOT RUN {
# load required packages
library(NNMIS)
library(survival)
# load data set - stanford2 in package 'survival'
data("stanford2")
head(stanford2)
attach(stanford2)
# performance multiple imputation on missing covariate t5
imp.dat <- NNMIS(t5, xa=age, xb=age, time=time, event=status, Seed = 2016)
# this program can impute censoring time based on the imputed missing covariate
# imp.dat <- NNMIS(t5, xa=age, xb=age, time=time, event=status, imputeCT=T, Seed = 2016)
# check imputation results
# head(imp.dat$dat.NNMI) #> missing covariates
# head(imp.dat$dat.T.NNMI) #> censoring time
# head(imp.dat$dat.Id.NNMI) #> censoring indicator
# check imputation results
head(imp.dat$dat.NNMI)
# combine inference from imputed data sets by using Rubin's rules
# estimates in Cox regression
coxph.pool(imp.dat, time, status, age)
# }
Run the code above in your browser using DataLab