Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re-running a program and saving results


From   Michael McCulloch <[email protected]>
To   Statalist <[email protected]>
Subject   st: re-running a program and saving results
Date   Sat, 8 Mar 2008 15:07:56 -0800

Dear Statalist members,
I've written the following simple program, which will estimate the hazard ratio from a large simulated dataset containing 10,000 observations.

I'd like to ask for suggestions on how to modify my program so that it will:

1. Draw random samples from the dataset in memory, 1,000-observation intervals,
2. save the results (hazard ratio and confidence interval), and then
3. plot the results showing how the analysis performs on sample sizes of 1,000, 2,000, 3,000 and so on up to 10,000.

This is the first program I've written, so not sure how to go about this. I imagine it's something concise at the very last line?

capture program drop pcox
version 9.2
program define pcox, rclass
tempname a

* stset the data
stset risktime, failure(failed==1)

* cox
stcox a
indeplist, local
foreach var of varlist `X' {
return scalar `var' = exp(_b[`var'])
}

end
set seed 12358
bootstrap a=r(a), eform reps(10): pcox

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index