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

Re: st: different stcox output when used in a program

From   Michael McCulloch <>
Subject   Re: st: different stcox output when used in a program
Date   Sun, 5 Aug 2007 09:30:19 -0700

Thanks Maarten! When I run the example exactly as defined, the coefficient is still returned. Is there some global option I need to define for Stata?

--- Michael McCulloch <> wrote:
 Using the same simple stcox command, Stata 9.2 outputs the hazard
 ratio when I issue the command, but the coefficient when I use it
 within a program. I'd like to learn how to obtain the hazard ratio
 within my simple program.
 .         bootstrap, reps(1000): msmcox_stageII
The reason is not that you call -stcox- from within a program, but that
you use -bootstrap- on that program. -bootstrap- does not bootstrap the
coefficients that are displayed, but the coefficients that are returned
by -stcox-, and -stcox- returns the coefficients and not the hazard
ratio. The hazard ratio is exp(coefficient), so if you want to
bootstrap the hazard ratio you do:

*---------------- begin example -------------
sysuse cancer, clear
stset studytim, failure(died)
xi: stcox i.drug age

capture program drop test
program define test, rclass
	xi: stcox i.drug age
	indeplist, local
	foreach var of varlist `X' {
		return scalar `var' = exp(_b[`var'])

bootstrap age=r(age) _Idrug_2=r(_Idrug_2) /*
*/ _Idrug_3=r(_Idrug_3), reps(100): test
*--------------- end example -----------------------
(For more on how to use examples I sent to the Statalist, see )

(this example requires -indeplist- which can be downloaded from -ssc-)

Hope this helps,

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
*   For searches and help try:
*   For searches and help try:

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