GAM regression with splines basis is defined by the following cost function:
cost = ||y - S \beta ||^2 + scale * integral(|S'' \beta|^2)
where S
is the design matrix defined by the splines.
In R I can compute gam
with the following code:
library('mgcv')
data = data.frame('x'=c(1,2,3,4,5), 'y'=c(1,0,0,0,1))
g = gam(y~s(x, k = 4),family = 'binomial', data = data, scale = 0.5)
plot(g)
I would like to get the design matrix S
that is generated by s()
function.
How can I do that?
I believe there are two ways to get the design matrix from a
gamObject