# Computing GLM Relativities from Spline Regression

Cross Validated Asked by Jordan on September 8, 2020

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!

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 

Answered by Tim Atreides on September 8, 2020

## Related Questions

### Specifying and extracting random intercepts and slopes from GAMM using bam in mgcv

1  Asked on January 1, 2022 by wdnsd

### Where is the proof that replacing missing lagged values with zero in Arellano-Bond like estimators is a valid approach?

0  Asked on January 1, 2022 by federico-tedeschi

### How to extend Plackett-Burman design to further explore the interactions?

1  Asked on January 1, 2022 by nothanks93330

### What is the difference between RMSE and SEP

1  Asked on January 1, 2022 by tiago-dias

### How to choose an optimizer for your Neural Network?

1  Asked on January 1, 2022 by white

### Box-Cox data transformation to enable linear regression

1  Asked on January 1, 2022 by cbgodbole

### Why isn’t simulation showing that ridge regression better than linear model

1  Asked on January 1, 2022 by andy_dorsey

### Does the t statistic have uses unrelated to hypothesis testing?

2  Asked on January 1, 2022

### survival analysis using unbalanced sample

2  Asked on December 29, 2021 by jessi

### Randomly sample point from a 2D pdf image

1  Asked on December 29, 2021 by c-wang

### Spline regression with many features in R

1  Asked on December 29, 2021 by user2117258

### transfer function-noise modelling in R

1  Asked on December 29, 2021 by stucash

### Interpreting classification report scores

1  Asked on December 29, 2021 by mxavier

### Laplace mechanism on vector record?

1  Asked on December 29, 2021

### About Murphy’s notation: why is $p(y|x, theta)$ a conditional expectation when there is no probabilistic interpretation on $x$ or $theta$?

1  Asked on December 29, 2021

### Can I fit a complex model in two stages (maximum likelihood)?

0  Asked on December 29, 2021

### Should I run a machine learning model many times?

2  Asked on December 29, 2021 by ka28mi

### Which correlation method to us?

1  Asked on December 29, 2021

### How to interpret coefficients from regularized cox regression?

1  Asked on December 29, 2021

Get help from others!