Dear Stata-users,
I am running a large number of cox-regressions with bootstrap (50 rep) and storing several estimates in a tempfile.
This takes a lot of time (multiple hours). Is there maybe a way to speed things up?
I am using Stata MP 16.1.
Thanks!
Marianne Heins
This is the code I am using:
forval subgroeplft=1/4 {
set more off
tempname nc1tot5subgrlft`subgroeplft'
postfile `nc1tot5subgrlft`subgroeplft'' subgroeplft icpc nicpc double(basesurv hr p) FUPcat using "$BEWERKT\Tussenbestanden\nc1tot5subgrlft`subg roep lft'.dta", replace
forval i=1001(1)2629 {
capture confirm variable icpc`i'
if !_rc {
gen exit=t_incdatplus5
format exit %td
gen entry=t_incdatplus1
format entry %td
stset exit, failure(icpc`i'==1) origin(time entry)
quietly stcox case if subgroeplft==`subgroeplft', vce(boot, seed(12345))
if _rc!=0 {
display "`i': regression failed"
}
else {
matrix t = r(table)
matrix list t
scalar hr = t[1,1]
scalar pwaarde= t[4,1]
predict xb, xb
predict s, basesurv
count if icpc`i'==1 & case==1 & subgroeplft==`subgroeplft'
scalar nicpc = r(N)
egen tt=max(_t) if subgroeplft==`subgroeplft'
sum s if _t==tt, meanonly
scalar basesurv=r(mean)
drop xb s tt
post `nc1tot5subgrlft`subgroeplft'' (`subgroeplft') (`i') (nicpc) (basesurv) (hr) (pwaarde) (3)
}
drop entry exit
stset, clear
}
else {
display "icpc`i' does not exist"
}
}
postclose `nc1tot5subgrlft`subgroeplft''
}
I am running a large number of cox-regressions with bootstrap (50 rep) and storing several estimates in a tempfile.
This takes a lot of time (multiple hours). Is there maybe a way to speed things up?
I am using Stata MP 16.1.
Thanks!
Marianne Heins
This is the code I am using:
forval subgroeplft=1/4 {
set more off
tempname nc1tot5subgrlft`subgroeplft'
postfile `nc1tot5subgrlft`subgroeplft'' subgroeplft icpc nicpc double(basesurv hr p) FUPcat using "$BEWERKT\Tussenbestanden\nc1tot5subgrlft`subg roep lft'.dta", replace
forval i=1001(1)2629 {
capture confirm variable icpc`i'
if !_rc {
gen exit=t_incdatplus5
format exit %td
gen entry=t_incdatplus1
format entry %td
stset exit, failure(icpc`i'==1) origin(time entry)
quietly stcox case if subgroeplft==`subgroeplft', vce(boot, seed(12345))
if _rc!=0 {
display "`i': regression failed"
}
else {
matrix t = r(table)
matrix list t
scalar hr = t[1,1]
scalar pwaarde= t[4,1]
predict xb, xb
predict s, basesurv
count if icpc`i'==1 & case==1 & subgroeplft==`subgroeplft'
scalar nicpc = r(N)
egen tt=max(_t) if subgroeplft==`subgroeplft'
sum s if _t==tt, meanonly
scalar basesurv=r(mean)
drop xb s tt
post `nc1tot5subgrlft`subgroeplft'' (`subgroeplft') (`i') (nicpc) (basesurv) (hr) (pwaarde) (3)
}
drop entry exit
stset, clear
}
else {
display "icpc`i' does not exist"
}
}
postclose `nc1tot5subgrlft`subgroeplft''
}
Comment