Hi everyone,

I am trying to do internal validation in Cox regression in order to compare with R (rms package, validate function) and learn how to do in flexible parametric survival in the near future.

1) I have done this in standard rms package in R as below : I got results: the original Dxy = 0.1832, training Dxy = 0.1930. I use this as gold standard

library(rms)

library(rstpm2)

data(brcancer)

cphfit <- cph(Surv(rectime,censrec==1)~hormon + x1 + x2 + x3,data=brcancer, x=TRUE, y=TRUE)

#logfit <- lrm(censrec~hormon + x1 + x2 + x3,data=brcancer, x=TRUE, y=TRUE)

#stpm2fit <- stpm2(Surv(rectime,censrec==1)~hormon + x1 + x2 + x3,data=brcancer, x=TRUE, y=TRUE)

#set.seed(129)

validate(cphfit, B=200)

2) I have done this in stata below

webuse brcancer, clear

stset rectime, failure(censrec)

save brcancer.dta, replace

*step0 original Dxy

stcox hormon x1 x2 x3, nohr

estat concor

dis r(D) // Dxy original = 0.1832

* step1 trainging Dxy

quietly stcox hormon x1 x2 x3, nohr

estat concor

matrix observe=r(D) // training Dxy

*step2 training Dxy

capture drop Dxy

gen Dxy=.

capture program drop myboot

program define myboot

preserve

bsample

stcox hormon x1 x2 x3, nohr

estat concor

replace Dxy = r(D)

restore

end

*step3 training Dxy

simulate Dxy=r(D), reps(200) seed(129): myboot

*step4 training Dxy

bstat, stat(observe) n(200)

estat bootstrap, all // look for observed Dxy

sum Dxy, de // look for training Dxy = mean = observe Dxy + bias ?

dis .183164 + .0126265 // = mean .1957905

I am trying to upload the results in picture jpg later

My question is I am doing the right thing and interpreting correct ?

I am trying to do internal validation in Cox regression in order to compare with R (rms package, validate function) and learn how to do in flexible parametric survival in the near future.

1) I have done this in standard rms package in R as below : I got results: the original Dxy = 0.1832, training Dxy = 0.1930. I use this as gold standard

library(rms)

library(rstpm2)

data(brcancer)

cphfit <- cph(Surv(rectime,censrec==1)~hormon + x1 + x2 + x3,data=brcancer, x=TRUE, y=TRUE)

#logfit <- lrm(censrec~hormon + x1 + x2 + x3,data=brcancer, x=TRUE, y=TRUE)

#stpm2fit <- stpm2(Surv(rectime,censrec==1)~hormon + x1 + x2 + x3,data=brcancer, x=TRUE, y=TRUE)

#set.seed(129)

validate(cphfit, B=200)

2) I have done this in stata below

webuse brcancer, clear

stset rectime, failure(censrec)

save brcancer.dta, replace

*step0 original Dxy

stcox hormon x1 x2 x3, nohr

estat concor

dis r(D) // Dxy original = 0.1832

* step1 trainging Dxy

quietly stcox hormon x1 x2 x3, nohr

estat concor

matrix observe=r(D) // training Dxy

*step2 training Dxy

capture drop Dxy

gen Dxy=.

capture program drop myboot

program define myboot

preserve

bsample

stcox hormon x1 x2 x3, nohr

estat concor

replace Dxy = r(D)

restore

end

*step3 training Dxy

simulate Dxy=r(D), reps(200) seed(129): myboot

*step4 training Dxy

bstat, stat(observe) n(200)

estat bootstrap, all // look for observed Dxy

sum Dxy, de // look for training Dxy = mean = observe Dxy + bias ?

dis .183164 + .0126265 // = mean .1957905

I am trying to upload the results in picture jpg later

My question is I am doing the right thing and interpreting correct ?

## Comment