Extracting knot points from glm when using bs in R as a variable
r
Solution
You're on the right track. `mymodel$terms` contains information about the terms in the model, and `attr(mymodel$terms, "predvars")` is a language object that is a list of predictors with the computed values of the knots.
To get them out:
x <- attr(mymodel$terms, "predvars")
x[[2]] # bs(LA, degree=3, knots=<vector>, Boundary.knots=<vector>, intercept=FALSE)
x[[2]]$knots
x[[2]]$Boundary.knots
Problem
I fit a model using the following: ``` mymodel <- glm(LS ~ bs(LA, df = 8) + bs(IN, df = 7), family = binomial, data = mydata, na.action = na.omit) ``` No problem, I have the model fit now I am trying to extract the knot points used. I followed a post on extracting knot points using `attr` and `str`. That was for a model that was just a spline. I think the knots are somewhere in the structure in terms I called `str(mymodel$terms)` there are `..-attr(*, "variables")`. I am having trouble going further with `attr` but I am relatively certain that this is basically what I need to do. Any guidance to get the knots is appreciated.