I am pleased to announce that rcsplot is now available from the SSC archive. To install:
ssc install rcsplot
rcsplot fits a restricted cubic spline (RCS) model for a continuous exposure and produces a publication-ready dose–response curve in a single command. It works with logistic, logit, poisson, stcox, and regress, and returns odds ratios, hazard ratios, rate ratios, or beta coefficients depending on the model.
Key features:
webuse nhanes2, clear
rcsplot logistic highbp zinc age i.sex bmi, knots(4) ciband histogram
This fits a 4-knot RCS logistic model for zinc (adjusted for age, sex, and BMI), plots the OR curve with a shaded 95% CI, overlays a histogram of zinc.
The command is documented with a full help file (help rcsplot).
Feedback and bug reports are welcome.
ssc install rcsplot
rcsplot fits a restricted cubic spline (RCS) model for a continuous exposure and produces a publication-ready dose–response curve in a single command. It works with logistic, logit, poisson, stcox, and regress, and returns odds ratios, hazard ratios, rate ratios, or beta coefficients depending on the model.
Key features:
- Reference-centred curves — the curve is anchored at a user-specified reference (median by default), so the effect estimate is exactly 1 (or 0 for linear models) at that point.
- Two P-values reported — overall association and non-linearity, printed in the output and optionally on the plot.
- Built-in trimming — observations outside the 1st–99th percentile of the exposure are dropped before fitting, and the plotted x-range matches the modelled sample by default.
- Survey support — works with svy, including domain estimation via svyopts(, subpop(if ...)), with knots and reference computed on the trimmed subpopulation.
- Publication-ready graphics — optional histogram overlay, shaded confidence bands in Nature-journal style (ciband), and adjustable band opacity (cibopacity()).
webuse nhanes2, clear
rcsplot logistic highbp zinc age i.sex bmi, knots(4) ciband histogram
This fits a 4-knot RCS logistic model for zinc (adjusted for age, sex, and BMI), plots the OR curve with a shaded 95% CI, overlays a histogram of zinc.
The command is documented with a full help file (help rcsplot).
Feedback and bug reports are welcome.
