library(IPDfromKM)
# a sample dataset that we already extracted from Wang et al, 2018.
df<- read.csv(system.file("extdata", "df.csv", package = "OneArm2stage"))
# risk time points
trisk <- c(0,2,4,6,8,10,12,14,16,18,20,22,24)
# number of patients at risk at each risk time point
nrisk.radio <- c(124,120,115,110,107,104,103,95,46,18,11,8,0)
# Preprocess the raw coordinates into an proper format for reconstruct IPD
pre_radio <- preprocess(dat=df, trisk=trisk,
nrisk=nrisk.radio,totalpts=NULL,maxy=100)
#Reconstruct IPD
est_radio <- getIPD(prep=pre_radio,armID=0,tot.events=NULL)
# shift the IPD data into the proper format for 'FitDat()'
ipd <- est_radio$IPD
dat3 <- as.data.frame(cbind(rep(0, nrow(ipd)),ipd$time, ipd$status))
colnames(dat3) <- c("Entry", "Time", "Cens")
# use FitDat function to fit the historical dat
modelSelect <- FitDat(dat3)
modelSelect$AIC
# Weibull
# 301.7776
# check the estimated parameters from the modeling results
modelSelect$parameter.estimates
# $Weibull
# shape scale
# 0.1133671 3.9939753
Run the code above in your browser using DataLab