I have been playing around with using restricted cubic splines using the RMS package. Output below.

nlmodel_ni_bi_4 <- lrm(outcome~ rcs(age,4) + ethnicity + AV + sex + nb, data=df)

Frequencies of Missing Values Due to Each Variable

       outcome           age          ethnicity       AV_binary          poisex      n_charge_binary 
          0               0            3896               0              12               0 

Logistic Regression Model

 lrm(formula = outcome ~ rcs(age, 4) + ethnicity + 
     AV + sex + nb, data = df)

                       Model Likelihood     Discrimination    Rank Discrim.    
                          Ratio Test           Indexes           Indexes       
 Obs         62364    LR chi2    4200.40    R2       0.112    C       0.690    
  0          52455    d.f.             7    g        0.719    Dxy     0.380    
  1           9909    Pr(> chi2) <0.0001    gr       2.052    gamma   0.386    
 max |deriv| 2e-11                          gp       0.100    tau-a   0.102    
                                            Brier    0.123                     

                           Coef    S.E.   Wald Z Pr(>|Z|)
 Intercept                 -7.2339 0.3149 -22.97 <0.0001 
 age                        0.4079 0.0239  17.05 <0.0001 
 age'                      -0.6351 0.0483 -13.15 <0.0001 
 age''                      2.4672 0.2589   9.53 <0.0001 
 ethnicity=NI              -0.6664 0.0299 -22.31 <0.0001 
 AV=1                       0.6583 0.0252  26.14 <0.0001 
 sex=M                      0.2920 0.0274  10.67 <0.0001 
 nb=1                       1.1922 0.0244  48.82 <0.0001 

I am used to running logistic regression where all of the predictors are either continuous linear or categorical. Here, when describing the individual predictors effect on the outcome, we would present the adjusted odds ratio, associated p value and sometimes relative risk. I am not sure how to report the age predictor in my current model with RCS. I am lost on a number of issues:

  1. Exactly what are the three terms associated with the age variable in the output (age, age', age''). Is this the derivative and the derivative of the derivative? or is it a term for each knot that has been fitted?

  2. With a linear term the adjusted odds ratio has a simple interpretation, with a consistent slope. Given that the RCS is not linear, what is the recommended way to describe its effect?

  3. Are there any guidelines for how to report predictors fitted with splines?


  • $\begingroup$ Hi I am curious whether you have figured out the answers to these 3 questions as i am currently struggling with the same questions too!! $\endgroup$
    – R Beginner
    Dec 11, 2021 at 4:02
  • 2
    $\begingroup$ @RBeginner Frank Harrell's course notes, linked from his answer below, recommend this paper (see Fig. 2) as an example of how to report results of spline fits: plot continuous curves with confidence intervals. These can be produced via plot(Predict(fit)) if fit is an appropriate object produced by the rms package. As Harrell says below, "Don't try to interpret individual terms" of the spline-fit coefficients. His course notes show where they come from in detail; you need to put all the terms together to get the spline. $\endgroup$
    – EdM
    Dec 11, 2021 at 20:10
  • $\begingroup$ @EdM This is very helpful! I am really grateful for your support/guidance! $\endgroup$
    – R Beginner
    Dec 11, 2021 at 20:13

1 Answer 1


My course notes describe the components of a restricted cubic spline function, and provides ways to interpret the model when general smooth effects are included. You can compute an odds ratio at two selected points for age (default in the summary.rms function is quartiles), or better: show the partial effect plots to depict the entire age effect. You can also use plot(nomogram(fit)) to construct a nomogram for the whole model. Don't try to interpret individual terms.

The terms such as age' represent differences in cubes that restrict the function of age to be linear beyond the outer knots.

  • 1
    $\begingroup$ Thanks, very helpful. When you write "don't try to interpret individual terms." are you saying that the estimate provided in the table above should not be reported or interpreted. Or are you suggesting that the estimates should be reported but interpreted through other means (e.g. the odds ratio at different points), partial effects plots etc.? Would you suggest the use of these same method for plotting interactions with variables that have a spline fit to them. $\endgroup$
    – user183974
    Feb 15, 2018 at 5:15
  • 1
    $\begingroup$ Yes to the last question, and also I think it's not helpful to report the coefficients and standard errors. Partial effect plots and ANOVA tables are more helpful. $\endgroup$ Feb 15, 2018 at 12:53
  • $\begingroup$ Hi @FrankHarrell sorry to necro this, but the link to your course notes is dead, I think I have found them, would you be able to direct me to where in the notes I can learn about computing odds ratios for two points on a spline? Thanks! $\endgroup$ Feb 6, 2021 at 12:57
  • $\begingroup$ Link fixed - thanks for pointing this out. $\endgroup$ Feb 7, 2021 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.