Title
xbrcspline - Differences in predicted responses after restricted cubic spline models
Syntax
xbrcspline stubname , matknots(matname) values(numlist) reference(#) [ lsplines level(#) eform format(%fmt) ]
Description
xbrcspline displays differences in the predicted responses (linear combinations of coefficients) after estimating a restricted cubic spline model. The location and spacing of the knots is determined by the specification of the matknots() option. The list of covariate values at which calculate differences is specified with the values(numlist) option. The reference value is specified with the reference(#) option.
Options
+---------+ ----+ Options +----------------------------------------------------------
matknots(matname) specifies the matrix of knots used to create the splines. This can be easily obtained from the saved results of the mkspline command.
values(numlist) specifies the values of the original covariate at which the xbrcspline calculates differences in predicted responses.
reference(#) specifies the reference covariate value (not necessarily included in values(numlist)).
lsplines displays the values of the restricted cubic splines corresponding to values(numlist).
eform specifies that all report coefficient estimates as exp(b) rather than b.
format(%fmt) specifies the display format for presenting numbers. format(%3.2f) is the default; see help format.
level(#) specifies a confidence level to use for confidence intervals. The default is 95%. See help on level.
generate(newvar1 newvar2 newvar3 newvar4) specifies that the specified values(numlist) of the continuous covariate , the differences in predicted responses, lower and upper confidence limits to be be saved in newvar1, newvar2, newvar3, and newvar4 respectively.
Example
use http://nicolaorsini.altervista.org/data/whitehall1, clear
// Step 1. Create the restricted cubic splines and save the knots.
mkspline sysbps = sysbp , nknots(4) cubic displayknots mat knots = r(knots)
// Step 2. Fit the model.
logit all10 sysbps* age
// Step 3. Display the results in a tabular or graphical form.
* Display odds ratios and 95% CI for a set of exposure values of interest.
xbrcspline sysbps , values(89 98 107 116 126 135 148 167 188 211) ref(107) eform matknots(knots)
* Display and save as new variables odds ratios and 95% CI for each distinct observed value of the exposure.
levelsof sysbp xbrcspline sysbps , values(`r(levels)') ref(107) matknots(knots) eform gen(sbp or lb ub)
* Plot the results. Below is an example suitable for publication that you can copy and paste in the do-file editor:
twoway (line lb ub or sbp, lp(- - l) lc(black black black) ) /// if inrange(sbp,98,200) , /// scheme(s1mono) legend(off) /// ylabel(0(.5)4, angle(horiz) format(%2.1fc) ) // > / xlabel(100(10)200) /// ytitle("Odds ratio of death within 10-years") / > // xtitle("Systolic blood pressure, mm Hg")
More examples and information
The command xbrcspline was introduced at the 2009 Nordic and Baltic Stata Users Group meeting. The slides of the talk are here http://www.stata.com/meeting/sweden09/se09_orsini.pdf
Author
nicola.orsini@ki.se, Karolinska Institutet http://nicolaorsini.altervista.org
Also see
Manual: [R] mkspline
Help: [R] mkspline
SSC Archive: postrcspline (if installed)