I would like to know how can I be able to interpret the results from fitting splines with the scam
package.
My data points are taken from the chileancredit
dataset available in the package smbinning
.
Here are my x
and y
data points:
library("scam")
library("zoo")
data(chileancredit, package = "smbinning")
chilean_clean <- na.omit(chileancredit)
x <- unique(sort(chilean_clean$TOB[1000:length(chilean_clean$TOB)]))
y_mav <- rollmean(chilean_clean$FlagGB, k = 1000)
y <- y_mav[(length(y_mav)-length(x)+1):length(y_mav)]
y
is the moving average of a binary target variable.
With the scam
function I could fit a convex spline to my datapoints (I specified 5 parameters in total):
spline_fit <- scam(y~ s(x,k=5,bs="cx",m=2),
family=gaussian(link="identity"),
data=as.data.frame(x=x,y=y))
However, the five coefficients I could get from scam
, I'm having trouble interpreting them:
(Intercept) s(x).1 s(x).2 s(x).3 s(x).4
0.9275358 -4.3564887 -4.8378830 -4.8522646 -4.8950387
The first term is the intercept, however I've lookup up in the results of scam
for knots or cuts - seems like there is none. I don't know how I could interpret the smoothing parameters without the knots. Anyone has any idea? Thanks.
s(x).i
terms are the penalised regression coefficients for the 4 basis functions in the model, they're not smoothness parameters. You code isn't working for me; I get an error that thex
andy
lengths differ. Can you run your code in a clean session and update as needed? Then I'll take a closer look. $\endgroup$