# How do I interpret and analyze the estimates based on specified knots in restricted cubic spline?

First time asking here in CV. I'm trying to perform an adjusted linear regression with a 3-knot restricted cubic spline on R. The 3-knots are explicitly specified based on literature/discussions. A sample code is below:

model.temp <- lm(outc~rcs(exp,knots=c(10,22,48))+age+sex+ethn+dev+com+tbf,data=master)


As many of you are familiar with, the resulting "summary(model.temp)" will show a Coefficients table with all the variables, it's Estimates, Std. Error, t, value, and Pr(>|t|).

Mock results for the first 5 estimates (excluding Intercept) are shown below :

Coefficients // Estimate // P-value
(Intercept)
rcs(exp, knots = c(10, 22, 48))exp // est:0.22 // p=0.04
rcs(exp, knots = c(10, 22, 48))exp' // est:-3.24 // p=0.23
rcs(exp, knots = c(10, 22, 48))exp'' // est:6.95 // p=0.02
rcs(exp, knots = c(10, 22, 48))exp''' // est:-4.13 // p=0.55

My question is, are these estimates representative of the range of exp between each knots?

What I would like to know is the effect/estimates of my exposure "exp" on my outcome "outc" when "exp" is: 0-10, 10-22, 22-48, 48+

In other words, are these ^ the estimates shown on my results, or are they the estimates only at those exact points/knots of "exp" i.e. :

1. rcs(exp, knots = c(10, 22, 48))exp = estimate when model is linear (w/o spline/knots?)
2. rcs(exp, knots = c(10, 22, 48))exp' = model estimate at exp=10
3. rcs(exp, knots = c(10, 22, 48))exp' = model estimate at exp=22
4. rcs(exp, knots = c(10, 22, 48))exp' = model estimate at exp=48

If so, how would I go about showing the estimates across those ranges of "exp" stated above: when "exp" is: 0-10, 10-22, 22-48, 48+ ?

Any help would be appreciated!

A couple things:

1. If you're using the rms::rcs function, then you should be using the rms::ols function. I'm not intimately familliar with the library, but I do know there are some problems when you try to use rms::rcs with stats::lm.

2. Regarding

My question is, are these estimates representative of the range of exp between each knots?

The answer is "no". Those estimates are the estimated weights of each basis function. If you wanted to know the effect of the exposure on the outcome, you would need to plot the effect for a varying exposure level, holding all other variables constant.

Here is an example in R

library(rms)
library(tidyverse)

N = 1000
x = rnorm(N)
z = rbinom(N, 1, 0.5)
y= sin(x*pi/2) + x + 2*z + rnorm(N, 0, 0.3)

fit = ols(y ~ rcs(x, 4) + z,
x=TRUE, y=TRUE)

Predict(fit) %>%
ggplot()



The plot below shows the effect of x on y. If you wanted to know how $$x$$ affects $$y$$ at a particular value, then you would put your finger on the $$x$$ value you were interested in and read off the corresponding y value. Additionally, you can just make model predictions (that's what the code does). • Hi @Demetri Pananos ! Thanks for your reply. I'm not too familiar with the Predict function but will definitely try it out. I guess in terms of my particular case (and following your example), if I wanted to find out the estimate, 95%CI, and p-value for when exp= 10-22, I would do: fit = ols(outc ~ rcs(exp, 3) + ..., x=TRUE, y=TRUE) then: predict(fit, exp=c(10,22), interval = "confidence") ? Does this make sense? Feb 7, 2021 at 5:06
• @Monarch The effect of the exposure when the exposure is between 10-22 is not a single number, it is a function since you are using restricted cubic splines. You could talk about the marginal effect, but I don't think that is what you want. Is your exposure variable inherently categorical? Feb 7, 2021 at 5:09
• My exposure is a continuous numeric variable. The problem is, I found out it has a non-lin relationship with my outcome which led me to exploring splining it. In terms of the exact ranges, since the exp is clinical based, I had to reference specific intervals that would make sense / would be interesting to explore and see if they are different Feb 7, 2021 at 5:11
• @Monarch OK, good. Yea, like I said the effect of the exposure between two numbers doesn't make a whole lot of sense under the provided model. If you are interested in collapsing the effect into a single number i think marginal effects are what you want. Else, the best route is to just plot the effect holding all other variables constant. Feb 7, 2021 at 5:14
• Perfect, that makes sense! Thanks a lot for your help @Demetri Pananos! Feb 7, 2021 at 5:20