Statalist


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

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


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: different stcox output when used in a program
Date   Sun, 5 Aug 2007 17:09:32 +0100 (BST)

--- Michael McCulloch <[email protected]> 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.
<snip>
> .         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'])
	}
end

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
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

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

Hope this helps,
Maarten

-----------------------------------------
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

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ 
*
*   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