Dear Maarten (& list)
Thank you for the quick reply. It is a very nice syntax that already
can tidy up my code. However, it is still not quite what I want. In
your setting, I want to set the variable ammonia to a given reference,
for example 3. Then, the relative hazard should be 1 for ammonia=3. In
your example code, the reference level for ammonia is set to 0, which
is out of the observed range.
In other words, I would like to draw the risk association as a nice
and smooth spline. Some sort of "limiting behaviour" of cutting the
continous variable into percentiles and choosing a reference level. In
your fashion:
set more off
use http://www.stata-press.com/data/cgg/reyes, clear
xtile qammonia=ammonia, nq(10)
char qammonia[omit] 7
xi: stcox i.qammonia
adjust , by(qammonia) ci replace exp
twoway rarea lb ub ammonia || ///
line exp ammonia, ///
legend(off) ///
ytitle(hazard ratio)
But how can I do it with a spline?
Best,
Claus
On Thu, Jan 15, 2009 at 3:47 PM, Maarten buis <[email protected]> wrote:
> --- Claus Dethlefsen <[email protected]> wrote:
>> I am doing Cox-regression with a continuous exposure, x
>>
>> I would like to fit a crude model with x modelled as a restricted
>> cubic spline. In Stata 10, I do
>>
>> mkspline rcx = x, cubic nknots(7)
>>
>> /* crude */
>> stcox rcx*
>>
>> Now, I would like to draw the hazard ratio as a function of x with
>> one value of x as reference level. Also, I want 95% confidence
> limits.
>
> *------------------- begin example ------------------
> set more off
> use http://www.stata-press.com/data/cgg/reyes, clear
> mkspline rsam = ammonia, cubic nknots(3)
> stcox treat rsam*
> adjust treat=0, by(ammonia) ci replace exp
> twoway rarea lb ub ammonia || ///
> line exp ammonia, ///
> legend(off) ///
> ytitle(hazard ratio)
> *-------------------- 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 )
>
> 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 N515
>
> +31 20 5986715
>
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
>
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/