I am trying to extract the placement of the knots from a GAM model in order to delineate my predictor variable into categories for another model. My data contains a binary response variable (used) and a continuous predictor (open).
data <- data.frame(Used = rep(c(1,0,0,0),1250),
Open = round(runif(5000,0,50), 0))
I fit the GAM as such:
mod <- gam(Used ~ s(Open), binomial, data = data)
I can get the predicted values, and the model matrix etc with either type=c("response", "lpmatrix")
within the predict.gam
function but I am struggling with out to extract the knot locations at which which the coefficients change. Any suggestion is really appreciated!
out<-as.data.frame(predict.gam(model1, newdata = newdat, type = "response"))
I would also be interested if possible to do something like:
http://www.fromthebottomoftheheap.net/2014/05/15/identifying-periods-of-change-with-gams/
in which the statistical increase/decrease of the splines is identified, however, I am not using a GAMM at this point, and thus, am having problems identifying the similar model characteristics in GAM that are extracted from his GAMM model. This second item is more out of curiosity than anything.