### CHANCE OF SECOND SEIZURE FOLLOWING A FIRST BREAKTHROUGH SEIZURE ### library(cmprsk) library(MASS) # load dataset # sdat2 <- read.csv("Outcomes following Breakthrough.csv") sdata <- subset(sdat2,with.Arm=="CBZ") sdatb <- subset(sdat2,with.Arm=="VPS") # Kaplan-Meier curve # library(prodlim) tiff(file="Fig 3.tiff",width=2250,heigh=2625,units="px",res=300) ttime <- sdat2$ttss.sseztime/365 fit <- prodlim(Surv(ttime,ttss.sscens)~1,data=sdat2) plot(fit,type="cuminc",percent=FALSE,background=FALSE,lwd=0.7,atRisk.dist=1,xlab="Time from 1st Breakthrough Seizure (years)",ylab="Probability of Seizure Recurrence",confint=FALSE,legend.x=0,legend.y=1,atrisk.labels="No. at risk:",atRisk.times=c(0,1,2,3,4),atRisk.adjust.labels=FALSE) dev.off() # Risk of a seizure 2 years following breakthrough # summary(fit,times=2) ## Patient Characteristics ## # No. seizure recurrences # sum(sdat2$ttss.sscens) # Time to seizure recurrence # sezpeeps <- subset(sdat2,ttss.sscens==1) summary(sezpeeps$ttss.sseztime) # Duration of follow-up after acheiving 12 month remission # summary((sdat2$lastfup.dlfu-sdat2$ttss.mdfsez)/365) # Gender # table(sdata$all.sex) prop.table(table(sdata$all.sex)) table(sdatb$all.sex) prop.table(table(sdatb$all.sex)) table(sdat2$all.sex) prop.table(table(sdat2$all.sex)) # Febrile Seizure History # table(sdata$all.feb) prop.table(table(sdata$all.feb)) table(sdatb$all.feb) prop.table(table(sdatb$all.feb)) table(sdat2$all.feb) prop.table(table(sdat2$all.feb)) # First degree relative # table(sdata$all.rels) prop.table(table(sdata$all.rels)) table(sdatb$all.rels) prop.table(table(sdatb$all.rels)) table(sdat2$all.rels) prop.table(table(sdat2$all.rels)) # Neurological Insult # neuro <- function(data) { neuro <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$all.neur[i]=="Y") neuro[i] <- 1 } return(neuro) } neuroa <- neuro(sdata) neurob <- neuro(sdatb) neuroab <- neuro(sdat2) learn <- function(data) { learn <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$all.learn[i]=="Y") learn[i] <- 1 } return(learn) } learna <- learn(sdata) learnb <- learn(sdatb) learnab <- learn(sdat2) nsigna <- neuroa + learna nsignb <- neurob + learnb nsignab <- neuroab + learnab nsign <- function(data) { nsign <- rep(-1/2,length(data)) for(i in 1:length(data)){ if(data[i]>0) nsign[i] <- 1/2 } return(nsign) } table(nsign(nsigna)) prop.table(table(nsign(nsigna))) table(nsign(nsignb)) prop.table(table(nsign(nsignb))) table(nsign(nsignab)) prop.table(table(nsign(nsignab))) # Stype # stype <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 1 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 1 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- 2 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- 2 if(data$all.scgtc[i]>=1) stype[i] <- 2 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 3 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- 4 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- 4 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.otc[i]>=1) stype[i] <- 6 if(data$all.o[i]>=1) stype[i] <- 7 } return(stype) } table(stype(sdata)) prop.table(table(stype(sdata))) table(stype(sdatb)) prop.table(table(stype(sdatb))) table(stype(sdat2)) prop.table(table(stype(sdat2))) # Epilepsy Type # table(sdata$all.type) prop.table(table(sdata$all.type)) table(sdatb$all.type) prop.table(table(sdatb$all.type)) table(sdat2$all.type) prop.table(table(sdat2$all.type)) # EEG result # eegfour <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.nonspecab)[i]) data$all.nonspecab[i]<-"N" } eegfour <- rep(3,nrow(data)) for(i in 1:nrow(data)){ if(data$all.eegabnormal[i]=="NR") eegfour[i]<-1 if(data$all.eegabnormal[i]=="N") eegfour[i]<-0 if(data$all.eegabnormal[i]=="Y" && data$all.nonspecab[i]=="Y") eegfour[i]<-2 } return(eegfour) } # Normal = 0 # Non-spec = 2 # Abnorm = 3 # Not indicated = 1 table(eegfour(sdata)) prop.table(table(eegfour(sdata))) table(eegfour(sdatb)) prop.table(table(eegfour(sdatb))) table(eegfour(sdat2)) prop.table(table(eegfour(sdat2))) # CT/MRI Scan Result # table(sdata$all.ctabnormal) prop.table(table(sdata$all.ctabnormal)) table(sdatb$all.ctabnormal) prop.table(table(sdatb$all.ctabnormal)) table(sdat2$all.ctabnormal) prop.table(table(sdat2$all.ctabnormal)) # Randomised treatment # table(sdata$with.Treat) prop.table(table(sdata$with.Treat)) table(sdatb$with.Treat) prop.table(table(sdatb$with.Treat)) table(sdat2$with.Treat) prop.table(table(sdat2$with.Treat)) # Number of drugs to achieve remission # mono <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$drugs.nodrugs)[i]) data$drugs.nodrugs[i]<-0 } mono <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$drugs.nodrugs[i]<=1) mono[i] <- 0 if(data$drugs.nodrugs[i]>=2) mono[i] <- 1 } return(mono) } table(mono(sdata)) prop.table(table(mono(sdata))) table(mono(sdatb)) prop.table(table(mono(sdatb))) table(mono(sdat2)) prop.table(table(mono(sdat2))) # Number t-c at achievement of remission # summary(sdata$newtc) summary(sdatb$newtc) summary(sdat2$newtc) # Age at achievement of remission # summary(sdata$newage) summary(sdatb$newage) summary(sdat2$newage) # Time to achieve 12 month remission # summary(sdata$rem.Remtime/365) summary(sdatb$rem.Remtime/365) summary(sdat2$rem.Remtime/365) # Time on randomised (monotherapy) treatment # summary(sdata$with.Withtime/365) summary(sdatb$with.Withtime/365) summary(sdat2$with.Withtime/365) # Pre-breakthrough decision # table(sdata$ttss.predec) prop.table(table(sdata$ttss.predec)) table(sdatb$ttss.predec) prop.table(table(sdatb$ttss.predec)) table(sdat2$ttss.predec) prop.table(table(sdat2$ttss.predec)) # Post-breakthrough decision # table(sdata$ttss.postdec) prop.table(table(sdata$ttss.postdec)) table(sdatb$ttss.postdec) prop.table(table(sdatb$ttss.postdec)) table(sdat2$ttss.postdec) prop.table(table(sdat2$ttss.postdec)) # Duration of follow-up after breakthrough seizure # summary((sdata$lastfup.dlfu-sdata$ttss.mdfsez)/365) summary((sdatb$lastfup.dlfu-sdatb$ttss.mdfsez)/365) summary((sdat2$lastfup.dlfu-sdat2$ttss.mdfsez)/365) ## Univariable analysis ## # Gender # sind <- function(data) { sind <- rep(1/2,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sex[i]=="F") sind[i] <- -1/2 } return(sind) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~sind(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # Febrile Seizure History # fsh <- function(data) { fsh <- rep(-1/2,nrow(data)) for(i in 1:nrow(data)){ if(data$all.feb[i]=="Y") fsh[i] <- 1/2 } return(fsh) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~fsh(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # First degree relative with epilepsy # fdr <- function(data) { fdr <- rep(-1/2,nrow(data)) for(i in 1:nrow(data)){ if(data$all.rels[i]=="Y") fdr[i] <- 1/2 } return(fdr) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~fdr(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # Neurological Signs # neuro <- function(data) { neuro <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$all.neur[i]=="Y") neuro[i] <- 1 } return(neuro) } neuroa <- neuro(sdat2) learn <- function(data) { learn <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$all.learn[i]=="Y") learn[i] <- 1 } return(learn) } learna <- learn(sdat2) nsigna <- neuroa + learna nsign <- function(data) { nsign <- rep(-1/2,length(data)) for(i in 1:length(data)){ if(data[i]>0) nsign[i] <- 1/2 } return(nsign) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~nsign(nsigna)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # Seizure Type # stype <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 2 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 2 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- 1 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- 1 if(data$all.scgtc[i]>=1) stype[i] <- 1 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 3 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- 4 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- 4 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.otc[i]>=1) stype[i] <- 6 if(data$all.o[i]>=1) stype[i] <- 7 } return(stype) } stype1 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(-1/7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 6/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 6/7 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.otc[i]>=1) stype[i] <- -1/7 if(data$all.o[i]>=1) stype[i] <- -1/7 } return(stype) } stype2 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(-1/7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 6/7 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.otc[i]>=1) stype[i] <- -1/7 if(data$all.o[i]>=1) stype[i] <- -1/7 } return(stype) } stype3 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(-1/7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 6/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 6/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 6/7 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- 6/7 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- 6/7 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.otc[i]>=1) stype[i] <- -1/7 if(data$all.o[i]>=1) stype[i] <- -1/7 } return(stype) } stype4 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(-1/7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- 6/7 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- 6/7 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- 6/7 if(data$all.otc[i]>=1) stype[i] <- -1/7 if(data$all.o[i]>=1) stype[i] <- -1/7 } return(stype) } stype5 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(-1/7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.otc[i]>=1) stype[i] <- 6/7 if(data$all.o[i]>=1) stype[i] <- -1/7 } return(stype) } stype6 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(6/7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- -1/7 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.scgtc[i]>=1) stype[i] <- -1/7 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- -1/7 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- -1/7 if(data$all.otc[i]>=1) stype[i] <- -1/7 if(data$all.o[i]>=1) stype[i] <- 6/7 } return(stype) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~stype1(sdat2)+stype2(sdat2)+stype3(sdat2)+stype4(sdat2)+stype5(sdat2)+stype6(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # P/G/U analysis # pgu1 <- function(data) { x1 <- rep(-1/3,nrow(data)) for(i in 1:nrow(data)){ if(is.na(data$all.type)[i]) data$all.type[i]<-"U" } for(i in 1:nrow(data)){ if(data$all.type[i]=="P") x1[i] <- -1/3 if(data$all.type[i]=="G") x1[i] <- 2/3 if(data$all.type[i]=="U") x1[i] <- -1/3 } return(x1) } pgu2 <- function(data) { x2 <- rep(-1/3,nrow(data)) for(i in 1:nrow(data)){ if(is.na(data$all.type)[i]) data$all.type[i]<-"U" } for(i in 1:nrow(data)){ if(data$all.type[i]=="P") x2[i]<- -1/3 if(data$all.type[i]=="G") x2[i]<- -1/3 if(data$all.type[i]=="U") x2[i]<- 2/3 } return(x2) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~pgu1(sdat2)+pgu2(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # EEG Results # eegfour <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.nonspecab)[i]) data$all.nonspecab[i]<-"N" } eegfour <- rep(3,nrow(data)) for(i in 1:nrow(data)){ if(data$all.eegabnormal[i]=="NR") eegfour[i]<-1 if(data$all.eegabnormal[i]=="N") eegfour[i]<-0 if(data$all.eegabnormal[i]=="Y" && data$all.nonspecab[i]=="Y") eegfour[i]<-2 } return(eegfour) } eeg1 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.nonspecab)[i]) data$all.nonspecab[i]<-"N" } eegfour <- rep(-1/4,nrow(data)) for(i in 1:nrow(data)){ if(data$all.eegabnormal[i]=="NR") eegfour[i]<-3/4 if(data$all.eegabnormal[i]=="N") eegfour[i]<--1/4 if(data$all.eegabnormal[i]=="Y" && data$all.nonspecab[i]=="Y") eegfour[i]<--1/4 } return(eegfour) } eeg2 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.nonspecab)[i]) data$all.nonspecab[i]<-"N" } eegfour <- rep(-1/4,nrow(data)) for(i in 1:nrow(data)){ if(data$all.eegabnormal[i]=="NR") eegfour[i]<--1/4 if(data$all.eegabnormal[i]=="N") eegfour[i]<--1/4 if(data$all.eegabnormal[i]=="Y" && data$all.nonspecab[i]=="Y") eegfour[i]<-3/4 } return(eegfour) } eeg3 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.nonspecab)[i]) data$all.nonspecab[i]<-"N" } eegfour <- rep(3/4,nrow(data)) for(i in 1:nrow(data)){ if(data$all.eegabnormal[i]=="NR") eegfour[i]<--1/4 if(data$all.eegabnormal[i]=="N") eegfour[i]<--1/4 if(data$all.eegabnormal[i]=="Y" && data$all.nonspecab[i]=="Y") eegfour[i]<--1/4 } return(eegfour) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~eeg1(sdat2)+eeg2(sdat2)+eeg3(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # CT/MR Results # ctmr1 <- function(data) { ctmr <- rep(-1/3,nrow(data)) for(i in 1:nrow(data)){ if(data$all.ctabnormal[i]=="Y") ctmr[i] <- 2/3 if(data$all.ctabnormal[i]=="NR") ctmr[i] <- -1/3 } return(ctmr) } ctmr2 <- function(data) { ctmr <- rep(-1/3,nrow(data)) for(i in 1:nrow(data)){ if(data$all.ctabnormal[i]=="Y") ctmr[i] <- -1/3 if(data$all.ctabnormal[i]=="NR") ctmr[i] <- 2/3 } return(ctmr) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~ctmr1(sdat2)+ctmr2(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # Treatment # treat <- function(data) { treat <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$with.Treat[i]=="CBZ") treat[i] <- 1 if(data$with.Treat[i]=="GBP") treat[i] <- 2 if(data$with.Treat[i]=="LTG") treat[i] <- 3 if(data$with.Treat[i]=="OXC") treat[i] <- 4 if(data$with.Treat[i]=="TPM") treat[i] <- 5 if(data$with.Treat[i]=="VPS") treat[i] <- 6 } return(treat) } treat1 <- function(data) { treat <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$with.Treat[i]=="CBZ") treat[i] <- -1/6 if(data$with.Treat[i]=="GBP") treat[i] <- 5/6 if(data$with.Treat[i]=="LTG") treat[i] <- -1/6 if(data$with.Treat[i]=="OXC") treat[i] <- -1/6 if(data$with.Treat[i]=="TPM") treat[i] <- -1/6 if(data$with.Treat[i]=="VPS") treat[i] <- -1/6 } return(treat) } treat2 <- function(data) { treat <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$with.Treat[i]=="CBZ") treat[i] <- -1/6 if(data$with.Treat[i]=="GBP") treat[i] <- -1/6 if(data$with.Treat[i]=="LTG") treat[i] <- 5/6 if(data$with.Treat[i]=="OXC") treat[i] <- -1/6 if(data$with.Treat[i]=="TPM") treat[i] <- -1/6 if(data$with.Treat[i]=="VPS") treat[i] <- -1/6 } return(treat) } treat3 <- function(data) { treat <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$with.Treat[i]=="CBZ") treat[i] <- -1/6 if(data$with.Treat[i]=="GBP") treat[i] <- -1/6 if(data$with.Treat[i]=="LTG") treat[i] <- -1/6 if(data$with.Treat[i]=="OXC") treat[i] <- 5/6 if(data$with.Treat[i]=="TPM") treat[i] <- -1/6 if(data$with.Treat[i]=="VPS") treat[i] <- -1/6 } return(treat) } treat4 <- function(data) { treat <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$with.Treat[i]=="CBZ") treat[i] <- -1/6 if(data$with.Treat[i]=="GBP") treat[i] <- -1/6 if(data$with.Treat[i]=="LTG") treat[i] <- -1/6 if(data$with.Treat[i]=="OXC") treat[i] <- -1/6 if(data$with.Treat[i]=="TPM") treat[i] <- 5/6 if(data$with.Treat[i]=="VPS") treat[i] <- -1/6 } return(treat) } treat5 <- function(data) { treat <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$with.Treat[i]=="CBZ") treat[i] <- -1/6 if(data$with.Treat[i]=="GBP") treat[i] <- -1/6 if(data$with.Treat[i]=="LTG") treat[i] <- -1/6 if(data$with.Treat[i]=="OXC") treat[i] <- -1/6 if(data$with.Treat[i]=="TPM") treat[i] <- -1/6 if(data$with.Treat[i]=="VPS") treat[i] <- 5/6 } return(treat) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~treat1(sdat2)+treat2(sdat2)+treat3(sdat2)+treat4(sdat2)+treat5(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # Monotherapy to achieve remission # mono <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$drugs.nodrugs)[i]) data$drugs.nodrugs[i]<-0 } mono <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$drugs.nodrugs[i]<=1) mono[i] <- 0 if(data$drugs.nodrugs[i]>=2) mono[i] <- 1 } return(mono) } monodat <- mono(sdat2) mntp <- function(data) { mntp <- rep(-1/2,length(data)) for(i in 1:length(data)){ if(data[i]==1) mntp[i] <- 1/2 } return(mntp) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~mntp(monodat)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # Post-seizure decision # post1 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$ttss.postdec)[i]) data$ttss.postdec[i]<-4 } post1 <- rep(-1/3,nrow(data)) for(i in 1:nrow(data)){ if(data$ttss.postdec[i]==1) post1[i] <- -1/3 if(data$ttss.postdec[i]==2) post1[i] <- 2/3 if(data$ttss.postdec[i]==3) post1[i] <- -1/3 if(data$ttss.postdec[i]==4) post1[i] <- -1/3 } return(post1) } post2 <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$ttss.postdec)[i]) data$ttss.postdec[i]<-4 } post2 <- rep(-1/3,nrow(data)) for(i in 1:nrow(data)){ if(data$ttss.postdec[i]==1) post2[i] <- -1/3 if(data$ttss.postdec[i]==2) post2[i] <- -1/3 if(data$ttss.postdec[i]==3) post2[i] <- 2/3 if(data$ttss.postdec[i]==4) post2[i] <- 2/3 } return(post2) } coxfita=coxph(Surv(ttss.sseztime,ttss.sscens)~post1(sdat2)+post2(sdat2)+strata(with.Arm),data=sdat2) coxfita exp(coxfita$coefficients) exp(confint(coxfita)) # Number of tonic-clonic seizures at first breakthrough # library(mfp) library(Hmisc) fit1 <- coxph(Surv(ttss.sseztime,ttss.sscens)~newtc+strata(with.Arm),data=sdat2) extractAIC(fit1) fit2 <- coxph(Surv(ttss.sseztime,ttss.sscens)~log(newtc+1)+strata(with.Arm),data=sdat2) extractAIC(fit2) fit3 <- mfp(Surv(ttss.sseztime,ttss.sscens)~fp(newtc)+strata(with.Arm),family=cox,data=sdat2,select=0.05,verbose=TRUE) extractAIC(fit3) summary(fit1) summary(sdat2$newtc) # Age at first breakthrough seizure # fit1 <- coxph(Surv(ttss.sseztime,ttss.sscens)~newage+strata(with.Arm),data=sdat2) extractAIC(fit1) fit2 <- coxph(Surv(ttss.sseztime,ttss.sscens)~log(newage)+strata(with.Arm),data=sdat2) extractAIC(fit2) coxfitf1 <- mfp(Surv(ttss.sseztime,ttss.sscens)~fp(newage)+strata(with.Arm),family=cox,data=sdat2,select=0.05,verbose=TRUE) extractAIC(coxfitf1) summary(fit1) summary(sdat2$newage) # Time to achieve first period of 12 month remission # fit1 <- coxph(Surv(ttss.sseztime,ttss.sscens)~rem.Remtime+strata(with.Arm),data=sdat2) extractAIC(fit1) fit2 <- coxph(Surv(ttss.sseztime,ttss.sscens)~log(rem.Remtime)+strata(with.Arm),data=sdat2) extractAIC(fit2) coxfitf1 <- mfp(Surv(ttss.sseztime,ttss.sscens)~fp(rem.Remtime)+strata(with.Arm),family=cox,data=sdat2,select=0.05,verbose=TRUE) extractAIC(coxfitf1) summary(fit2) summary(sdat2$rem.Remtime) # Time on randomised treatment # fit1 <- coxph(Surv(ttss.sseztime,ttss.sscens)~with.Withtime+strata(with.Arm),data=sdat2) extractAIC(fit1) fit2 <- coxph(Surv(ttss.sseztime,ttss.sscens)~log(with.Withtime)+strata(with.Arm),data=sdat2) extractAIC(fit2) coxfitf1 <- mfp(Surv(ttss.sseztime,ttss.sscens)~fp(with.Withtime)+strata(with.Arm),family=cox,data=sdat2,select=0.05,verbose=TRUE) extractAIC(coxfitf1) summary(fit1) summary(sdat2$with.Withtime) ### Multivariable Model ### neuro <- function(data) { neuro <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$all.neur[i]=="Y") neuro[i] <- 1 } return(neuro) } neuroa <- neuro(sdat2) learn <- function(data) { learn <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$all.learn[i]=="Y") learn[i] <- 1 } return(learn) } learna <- learn(sdat2) nsigna <- neuroa + learna nsign <- function(data) { nsign <- rep(0,length(data)) for(i in 1:length(data)){ if(data[i]>0) nsign[i] <- 1 } return(nsign) } stype <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.sp)[i]) data$all.sp[i]<-0 if(is.na(data$all.cp)[i]) data$all.cp[i]<-0 if(is.na(data$all.scgtc)[i]) data$all.scgtc[i]<-0 if(is.na(data$all.tc)[i]) data$all.tc[i] <- 0 if(is.na(data$all.ta)[i]) data$all.ta[i] <- 0 if(is.na(data$all.aa)[i]) data$all.aa[i] <- 0 if(is.na(data$all.m)[i]) data$all.m[i] <- 0 if(is.na(data$all.otc)[i]) data$all.otc[i] <- 0 if(is.na(data$all.o)[i]) data$all.o[i] <- 0 } stype <- rep(7,nrow(data)) for(i in 1:nrow(data)){ if(data$all.sp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 2 if(data$all.cp[i]>=1 && data$all.scgtc[i]==0) stype[i] <- 2 if(data$all.sp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- 1 if(data$all.cp[i]>=1 && data$all.scgtc[i]>=1) stype[i] <- 1 if(data$all.scgtc[i]>=1) stype[i] <- 1 if(data$all.tc[i]>=1 && data$all.aa[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 3 if(data$all.aa[i]>=1 && data$all.tc[i]==0 && data$all.ta[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]==0 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.ta[i]>=1 && data$all.tc[i]==0 && data$all.aa[i]>=1 && data$all.m[i]==0 && data$all.otc[i]==0 && data$all.o[i]==0) stype[i] <- 4 if(data$all.m[i]>=1 && data$all.ta[i]>=1) stype[i] <- 4 if(data$all.m[i]>=1 && data$all.aa[i]>=1) stype[i] <- 4 if(data$all.aa[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.m[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.ta[i]>=1 && data$all.tc[i]>=1) stype[i] <- 5 if(data$all.otc[i]>=1) stype[i] <- 6 if(data$all.o[i]>=1) stype[i] <- 7 } return(stype) } eegfour <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$all.nonspecab)[i]) data$all.nonspecab[i]<-"N" } eegfour <- rep(3,nrow(data)) for(i in 1:nrow(data)){ if(data$all.eegabnormal[i]=="NR") eegfour[i]<-1 if(data$all.eegabnormal[i]=="N") eegfour[i]<-0 if(data$all.eegabnormal[i]=="Y" && data$all.nonspecab[i]=="Y") eegfour[i]<-2 } return(eegfour) } post1a <- function(data) { for(i in 1:nrow(data)){ if(is.na(data$ttss.postdec)[i]) data$ttss.postdec[i] <- 4 } post1a <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(data$ttss.postdec[i]==1) post1a[i] <- 1 if(data$ttss.postdec[i]==2) post1a[i] <- 2 if(data$ttss.postdec[i]==3) post1a[i] <- 3 if(data$ttss.postdec[i]==4) post1a[i] <- 3 } return(post1a) } aeds1a <- function(data) { aeda <- rep(0,nrow(data)) for(i in 1:nrow(data)){ if(is.na(data$drugs.nodrugs)[i]) data$drugs.nodrugs[i]<-0 } for(i in 1:nrow(data)){ if(data$drugs.nodrugs[i]==2) aeda[i] <- 1 if(data$drugs.nodrugs[i]==3) aeda[i] <- 1 } return(aeda) } coxfitb=coxph(Surv(ttss.sseztime,ttss.sscens)~all.sex+all.feb+all.rels+nsign(nsigna)+factor(stype(sdat2))+factor(eegfour(sdat2))+factor(all.ctabnormal)+aeds1a(sdat2)+newtc+newage+log(rem.Remtime)+factor(post1a(sdat2))+strata(with.Arm),data=sdat2) rema.step=stepAIC(coxfitb,scope=list(upper=~all.sex+all.feb+all.rels+nsign(nsigna)+factor(stype(sdat2))+factor(eegfour(sdat2))+factor(all.ctabnormal)+aeds1a(sdat2)+newtc+newage+log(rem.Remtime)+factor(post1a(sdat2))+strata(with.Arm)),direction="backward",trace=FALSE) rema.step remb.step=stepAIC(coxfitb,scope=list(upper=~all.sex+all.feb+all.rels+nsign(nsigna)+factor(stype(sdat2))+factor(eegfour(sdat2))+factor(all.ctabnormal)+aeds1a(sdat2)+newtc+newage+log(rem.Remtime)+factor(post1a(sdat2))+strata(with.Arm)),direction="both",trace=FALSE) remb.step remamod = coxph(Surv(ttss.sseztime,ttss.sscens)~aeds1a(sdat2)+log(rem.Remtime)+factor(post1a(sdat2))+strata(with.Arm),data=sdat2) summary(remamod) exp(remamod$coef) exp(confint(remamod)) ## Forest Plot # library(grid) # read in relevant dataset # seizure <- read.table("Risk Factor Combos - Seizure.txt",header=TRUE) Ys=seq(from=1,to=nrow(seizure),by=1) par(mfrow=c(1,3),mar=c(5,1,1,1)) plot(0,0,xlim=c(0,100),ylim=c(0,nrow(seizure)+3),type="n",axes=F,xlab="",ylab="",main="") text(10,Ys,rev(seizure$aeds),cex=0.7) text(50,Ys,c(rep("No Change",3),rep("Increase",3),rep("No Change",3),rep("Increase",3)),cex=0.7) text(90,Ys,rev(seizure$rtime),cex=0.7) text(10,nrow(seizure)+3,"No. drugs",font=2,cex=0.7) text(10,nrow(seizure)+2,"attempted",font=2,cex=0.7) text(50,nrow(seizure)+3,"Treatment",font=2,cex=0.7) text(50,nrow(seizure)+2,"decision",font=2,cex=0.7) text(90,nrow(seizure)+3,"Time to",font=2,cex=0.7) text(90,nrow(seizure)+2,"remission",font=2,cex=0.7) text(90,nrow(seizure)+1,"(years)",font=2,cex=0.7) abline(h=6.5) plot(0,0,xlim=c(0,100),ylim=c(0,nrow(seizure)+3),type="n",axes=F,xlab="Risk of Seizure Recurrence at 0.5 years after breakthrough (%)",ylab="",main="",cex.lab=0.7) estimate0.5y <- rev(seizure$HR0.5)*100 lower0.5y <- rev(seizure$Lower0.5)*100 upper0.5y <- rev(seizure$Upper0.5)*100 points(estimate0.5y,Ys,pch=15,cex=1.5,) for(i in 1:length(Ys)){ lines(c(lower0.5y[i],upper0.5y[i]),rep(Ys[i],2),lwd=1.0) } axis(1,at=c(0,10,20,30,40,50,60,70,80,90,100),c(0,10,20,30,40,50,60,70,80,90,100),cex.axis=0.7) abline(h=6.5) plot(0,0,xlim=c(0,100),ylim=c(0,nrow(seizure)+3),type="n",axes=F,xlab="Risk of Seizure Recurrence at 1 year after breakthrough (%)",ylab="",main="",cex.lab=0.7) estimate1y <- rev(seizure$HR1)*100 lower1y <- rev(seizure$Lower1)*100 upper1y <- rev(seizure$Upper1)*100 points(estimate1y,Ys,pch=15,cex=1.5,) for(i in 1:length(Ys)){ lines(c(lower1y[i],upper1y[i]),rep(Ys[i],2),lwd=1.0) } axis(1,at=c(0,10,20,30,40,50,60,70,80,90,100),c(0,10,20,30,40,50,60,70,80,90,100),cex.axis=0.7) abline(h=6.5)