Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Draw splines after Cox-regression


From   "Claus Dethlefsen" <[email protected]>
To   [email protected]
Subject   st: Draw splines after Cox-regression
Date   Thu, 15 Jan 2009 15:09:35 +0100

Dear List

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.

For the crude model, I could try

predict hr
predict sd, stdp

But, despite the label given to "hr", this is not the relative hazard,
but rather the hazard function. I need to divide by the value at the
reference level of x, which I call xref.

replace hr=hr/xref

and a novel attempt at calculating 95% confidence limits would be
gen ll = exp(log(hr) - 2*sd)
gen ul = exp(log(hr) + 2*sd)

line hr x, sort

However, in order to draw 95% confidence limits, I have to "adjust" sd
accordingly so that the width of the confidence interval is zero at
the reference value. The plot should look like a "butterfly". Is there
a way of obtaining this?

I have tried replacing x with x - xref, but the predicted value of the
"hazard ratio" does not become 1 as expected at the value xref. I
tried looking at the mvrs package, but the fracplot does not give me a
"butterfly".

Any help is highly appreciated,

Claus Dethlefsen
Center for Cardiovascular Research
Aalborg Hospital, Aarhus University Hospital
Denmark
*
*   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/



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