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 segmented package for plant data
library(segmented)
#load splines package
library(splines)
#get data
data <- data("plant")
#run GLM and get summary
glm_model <- glm(y ~ time, data = plant)
summary(glm_model)
#add spline and get summary
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!
summarystatement is the orthogonal coefficients. – Jordan Mar 12 '18 at 19:34bshas a dot-product of 0. The coefficients are not orthogonal. "Standard coefficients": why wouldn't you get them by fitting the model regressed with nobscall totime? 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:36splinesdoes not show me what I need to know. I can get the slopes and intercept using thesegmentedpackage but that only works for continuous segments so I need thesplinespackage 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:40matplot(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