たとえば、次の 1 ノット、次数 1 のスプラインを考えてみましょう。
library(splines)
library(ISLR)
age.grid = seq(range(Wage$age)[1], range(Wage$age)[2])
fit.spline = lm(wage~bs(age, knots=c(30), degree=1), data=Wage)
pred.spline = predict(fit.spline, newdata=list(age=age.grid), se=T)
plot(Wage$age, Wage$wage, col="gray")
lines(age.grid, pred.spline$fit, col="red")
# NOTE: This is **NOT** the same as fitting two piece-wise linear models becase
# the spline will add the contraint that the function is continuous at age=30
# fit.1 = lm(wage~age, data=subset(Wage,age<30))
# fit.2 = lm(wage~age, data=subset(Wage,age>=30))
結び目の前後の線形モデル (およびその係数) を抽出する方法はありますか? つまり、 の切断点の前後の 2 つの線形モデルをどのように抽出できage=30
ますか?
summary(fit.spline)
利回り係数を使用しますが、(私の理解では)解釈には意味がありません。