3
$\begingroup$

I am learning spline transformation and am confused about several concepts. Any guidance is all appreciated!

  1. Am I understanding this correctly: I should only spline-transform my continuous predictors if my logistic regression model does not have a good model fit?
  2. It appears that we cannot obtain the odds ratio from the spline-transformed logistic regression, is this correct? If so, how should I report the finding (as I always think odds ratio is the must-report outcomes in logistic regression)?
  3. Is it allowed to log transform some predictors and spline transform the others in my regression model or I 'MUST' keep their methods of transformation consistent?
$\endgroup$

2 Answers 2

5
$\begingroup$

Note that Occam's razor applies only to two pre-specified models of the world. It does not apply when one plays with multiparameter model fits in general.

You can get odds ratios even when fits are nonlinear; you just need to specify the low and high values of X over which you want the OR.

Don't think of a spline fit as something you try temporarily just to check goodness of fit against a simple linear in X model. This will make you ignore model uncertainty in your final model, resulting in invalid p-values and confidence intervals. All of these issues are discussed in detail in RMS and here.

A useful overall strategy is this:

  • when the sample size is not tiny, use spline functions for continuous predictors not already known to act linear in the log odds
  • you can test for linearity of effects to impress your boss that things are not simple and to help specify models on future datasets
  • keep the spline for the current dataset. The spline function with its multiple degrees of freedom properly penalize you for not knowing an effect is linear
  • use partial effects plots, interquartile-range odds ratios, and nomograms to describe the result
$\endgroup$
1
  • $\begingroup$ Thank you for the great response. You mention spline functions can be used when the sample size is not tiny. If I only have ~50 participants, do you think the spline function is still applicable to my data? $\endgroup$
    – R Beginner
    Commented Dec 8, 2021 at 19:15
3
$\begingroup$

Interesting questions!

  1. In general, if you have a simple method like a log transformation that does the same job comparably well as the more complicated method (spline transformation) stick to the simpler method. Think of Occam's razor. How do you evaluate "comparably well"? Use methods for model evaluation like information criteria, cross-validation etc.
  2. You still have an odds ratio, but the nonlinear effect of your covariate is not interpretable anymore because its effect on the odds ratio is not constant anymore. I think one way of reporting it, would be to just plot the nonlinear effect on the scale of the (log) odds ratio. I would argue that this is rather uncommon in the (applied) literature.
  3. It is perfectly fine to use different methods of transformation in the same model.
$\endgroup$
6
  • $\begingroup$ Thank you! So, if I only have one predictor (no covariate as I am building a predictive model), does it mean I can't report the odds ratio for this spline-transformed predictor? $\endgroup$
    – R Beginner
    Commented Dec 8, 2021 at 19:11
  • $\begingroup$ You didn't read my response above, which addresses that question fully. Remember that even with a linear (in the logit) model, you have to decide the values over which to compute the OR. $\endgroup$ Commented Dec 8, 2021 at 20:09
  • $\begingroup$ Pls correct me if I am wrong but as far as I understand, there will be multiple ORs for a single spline-transformed predictor and it is up to us to decide which OR to report? $\endgroup$
    – R Beginner
    Commented Dec 9, 2021 at 5:05
  • 1
    $\begingroup$ Your reasoning is right - there are many ORs for a single spline. However this does not mean you can decide which to report. It means that you need to report things like Frank Harrell mentioned in his fourth point. $\endgroup$
    – BalaGizeh
    Commented Dec 10, 2021 at 15:39
  • 2
    $\begingroup$ @RBeginner those can all be provided by functions in the rms package. For example, summary(fit) on an rms object (with a datadist pre-specified) provides interquartile-range odds ratios, as you have found here. There's a nomogram() function to represent a regression fit visually. It takes some study, but with Harrell's book and notes as a guide you can master very useful methods for data analysis and reporting. $\endgroup$
    – EdM
    Commented Dec 10, 2021 at 18:38

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.