Statalist


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

Re: st: cubic spline


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: cubic spline
Date   Sat, 4 Jul 2009 14:12:22 +0000 (GMT)

--- On Fri, 3/7/09, Noori, Nazanin wrote:
> I want to run a spline cubic to assess the spline models
> with 95% CI reflecting mortality predictability of 
> dietary phosphorus in a group.
> 
> I have two variables:
> 
> 1-Death
> 
> 2- Phosphorus intake
> 
> Would you please help me which syntax I should use? I want
> the Y axis to show the Log hazard ratio and the X axis to
> show the dietary phosphorus.
> Also I want to know if I want to adjust for age make second
> spline) what should I do. So far I ran these syntaxes:
> 
> 
> stset time to death, failure(death)
> 
> stcox Phosphorus intake
> 
> predict hr1, hr
> 
> generate lnhr = ln(hr1)

The easiest way is to use restricted cubic splines because
these have already been implemented in official Stata's 
-mkspline- command. Than use -adjust- to create adjusted 
predictions and than plot these.

*------------- begin example ------------
sysuse cancer, clear
stset studytime, failure(died)
mkspline sp_age = age, cubic nknots(3)
xi: stcox i.drug sp_age*

adjust _Idrug_2=1 _Idrug_3=0, ///
       by(age) ci replace xb

twoway rarea lb ub age ||     ///
       line xb age,           ///
       legend(off)            ///
       ytitle("ln(hazard ratio)")
*------------- end example ------------

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

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/



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