# load data
data(simulation)
# order the data by observed time and select the first 200 patients to speed up
simulation=simulation[order(simulation$Survival)[1:200],]
# convert the data into a datalist
datalist=list(z=simulation$Instrument,a=simulation$Treatment,
obs.t=simulation$Survival,delta=simulation$Status,
l=cbind(simulation$Covariate1,simulation$Covariate2))
# predetermined t0
t0=1
# calculate ps and prep
ps=Fps.DRKMEIV(datalist, t0)
prep=Fprep.DRKMEIV(datalist, ps, t0)
Genetic.optim.DRKMEIV(datalist, ps, prep, t0, smooth=TRUE)
Run the code above in your browser using DataLab