I have been playing around with using restricted cubic splines using the RMS package. Output below.
library(rms)
nlmodel_ni_bi_4 <- lrm(outcome~ rcs(age,4) + ethnicity + AV + sex + nb, data=df)
nlmodel_ni_bi_4
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:
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?
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?
Are there any guidelines for how to report predictors fitted with splines?
Thanks
plot(Predict(fit))
iffit
is an appropriate object produced by therms
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$