# Computing GLM Relativities from Spline Regression

I'm wondering if someone can assist me in extracting GLM relativities when using splines? I have searched CV and cannot find an easily understandable answer.

Here is some code in R (my apologies as I do not know python).

#load segemented package for plant data
library(segmented)
library(splines)

#get data
data <- data("plant")

#run GLM and get summary
glm_model <- glm(y ~ time, data = plant)
summary(glm_model)

glm_model2 <- glm(y ~ bs(time, degree = 1, knots = c(366.5)), data = plant)
summary(glm_model2)


Here is the summary from the splines model.

Call: glm(formula = y ~ bs(time, degree = 1, knots = c(366.5)), data = plant)

Deviance Residuals:

Min 1Q Median 3Q Max
-0.37187 -0.15317 0.05867 0.12065 0.23452

Coefficients:

Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.36133 0.04236 8.529 1.63e-13 ***

bs(time, degree = 1, knots = c(366.5))1 0.48467 0.05794 8.365 3.71e-13 ***

bs(time, degree = 1, knots = c(366.5))2 0.42415 0.05469 7.756 7.59e-12 ***

How would I convert the polynomial coeefficients in the spline summary to actual GLM relativities? It doesn't need to be in R if someone can explain the math but if anyone has an R example, that would be great!

• What are relativities? – AdamO Mar 12 '18 at 19:25
• My apologies. I'm using insurance language. I mean standard coefficients. I believe the estimates the spline packages gives in the summary statement is the orthogonal coefficients. – Jordan Mar 12 '18 at 19:34
• By orthogonal, the spline forms a basis, yes, each column of the spline representation using bs has a dot-product of 0. The coefficients are not orthogonal. "Standard coefficients": why wouldn't you get them by fitting the model regressed with no bs call to time? Or is there a different spline representation you are trying to code? I talk about some alternate parametrizations in another SE answer here. – AdamO Mar 12 '18 at 19:36
• I could. In doing this "real world," I do then add splines to form a piecewise regression model to those variables that the technique is applicable to. This changes what the coefficients are but the summary in splines does not show me what I need to know. I can get the slopes and intercept using the segmented package but that only works for continuous segments so I need the splines package or something comparable to fit non-continuous splines. I still need to get those coefficients in the end though. – Jordan Mar 12 '18 at 19:40
• I think the post I linked will be useful to you, if anything to clarify what you're asking for here. I recommend working through an exhaustive set of simulations and examples. The version I propose in the answer is interpretable, albeit cumbersome. The basis version is practically uninterpretable. Inspecting matplot(model.matrix( ~ bs(time, degree = 1, knots = c(366.5)), data = plant)) will show you just how contrived the coding is. – AdamO Mar 12 '18 at 19:45

By "relative" do you mean "relative risk"? If so, this question doesn't have a simple answer, since it will be different for different values of $x$ (time). You can do this empirically for two values of time. Something like this should work:
 pred1 <- predict(glm_model, data.frame(time = whatever1), type = 'response') pred2 <- predict(glm_model, data.frame(time = whatever2), type = 'response') relative_risk <- pred1 / pred2