Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Calculation of cubic splines


From   Mikkel Brabrand <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Calculation of cubic splines
Date   Thu, 19 May 2011 14:57:01 +0200

All.

I am trying to use cubic splines to assess risk of in-hospital mortality using some vital signs. I would like to calculate the predicted mortality using cubic splines manually. 

I have defined the following knots:
. mkspline _Ssbt = sbt, cubic nknots(5) displayknots

             |     knot1      knot2      knot3      knot4      knot5 
-------------+-------------------------------------------------------
         sbt |        97        119        132        146        178 

. mat sbt_knots = r(knots)

. mkspline _Stemp = temp, cubic nknots(5) displayknots

             |     knot1      knot2      knot3      knot4      knot5 
-------------+-------------------------------------------------------
        temp |      35.9       36.6         37       37.3       38.8 

. mat temp_knots = r(knots)

. mkspline _Salder = alder, cubic nknots(5) displayknots

             |     knot1      knot2      knot3      knot4      knot5 
-------------+-------------------------------------------------------
       alder |        23         53         66         76         88 

. mat alder_knots = r(knots)

And have run the logistic regression as follows:

. xi: logit in_hosp_mort _Ssbt* _Stemp* _Salder*, or

Iteration 0:   log likelihood = -364.70483  
Iteration 1:   log likelihood = -322.05257  
Iteration 2:   log likelihood = -301.68143  
Iteration 3:   log likelihood = -299.60534  
Iteration 4:   log likelihood =  -299.5029  
Iteration 5:   log likelihood = -299.50192  
Iteration 6:   log likelihood = -299.50192  

Logistic regression                               Number of obs   =       2979
                                                  LR chi2(12)     =     130.41
                                                  Prob > chi2     =     0.0000
Log likelihood = -299.50192                       Pseudo R2       =     0.1788

------------------------------------------------------------------------------
in_hosp_mort | Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      _Ssbt1 |   .9557737   .0141873    -3.05   0.002     .9283678    .9839888
      _Ssbt2 |    1.19366   .1618851     1.31   0.192     .9150398    1.557117
      _Ssbt3 |   .4041954   .3164691    -1.16   0.247     .0871232    1.875205
      _Ssbt4 |   3.502106   4.366206     1.01   0.315     .3041618    40.32311
     _Stemp1 |   .2456296   .0807298    -4.27   0.000     .1289796    .4677788
     _Stemp2 |   6.086799   31.49901     0.35   0.727     .0002396    154643.8
     _Stemp3 |   1.01e+11   3.39e+12     0.75   0.452     2.19e-18    4.62e+39
     _Stemp4 |   3.34e-36   2.06e-34    -1.33   0.185     1.19e-88    9.42e+16
    _Salder1 |   1.078022   .0906853     0.89   0.372     .9141613    1.271254
    _Salder2 |   1.004445   .1631946     0.03   0.978     .7305158    1.381093
    _Salder3 |   .7612758   .8178836    -0.25   0.800     .0926928    6.252275
    _Salder4 |    2.45316    5.18604     0.42   0.671     .0389283    154.5918
------------------------------------------------------------------------------

. predict p_spline if e(sample)
(option pr assumed; Pr(in_hosp_mort))
. 
. roctab in_hosp_mort p_spline, summary 

                      ROC                    -Asymptotic Normal--
           Obs       Area     Std. Err.      [95% Conf. Interval]
         --------------------------------------------------------
          2979     0.8207       0.0240        0.77361     0.86786

. 

My question is: What is the formula I should use to calculate the predicted mortality? I have spend a great deal of time on this and have not been able to figure it out.

Thanks.

Mikkel
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index