Restricted Cubic Spline (RCS)
Use restricted cubic splines to characterise the non-linear relationship between a continuous variable and the outcome, giving a smooth {OR/HR} curve vs the variable (with a 95% confidence band) and a nonlinearity test. Supports logistic and Cox, can adjust for other covariates, and exports code reproducible in R (rms package) with one click. Computed locally in your browser; data are not uploaded.
① Data
Paste data with a header (first row = column names, Tab/comma-separated, ≥20 rows). The continuous predictor and covariates are numeric; the outcome/status column is coded 0/1.
How to use & methodology
When should I use RCS?
When you suspect a continuous variable (e.g. age, BMI, a marker) is not in a simple straight-line relationship with the outcome (possibly U-shaped, threshold, saturating). RCS flexibly captures the bend in the middle while keeping the ends smooth and avoiding the wild swings of high-order polynomials — a common method in clinical prediction and dose-response research.
How are knots chosen and placed?
This tool follows Harrell's recommendations: 3 knots at the 10/50/90 percentiles, 4 knots at 5/35/65/95, 5 knots at 5/27.5/50/72.5/95. Use 3–5 knots; more is more flexible but more prone to overfitting, so use 3 with few samples/events.
How do I read the nonlinearity test?
It tests whether all nonlinear spline terms are simultaneously 0. P<0.05 means the relationship significantly departs from a straight line, so model it nonlinearly; if non-significant, the linear assumption is acceptable and a plain linear term is simpler. The overall association test asks whether the variable has any association with the outcome.
What is the reference value?
The curve shows the OR/HR relative to a reference value (=1 at that point). It defaults to the median knot but can be set to a clinically meaningful value (e.g. a normal reference point). Changing the reference only shifts the curve, not its shape or the nonlinearity test result.