将GAM预测分解为变量引起的分量

时间:2019-07-30 09:32:51

标签: r prediction gam mgcv

加性GAM模型对预测的单纯分解不具有相等性:

library(mgcv)

set.seed(123)
x1=rnorm(123)
x2=rnorm(123)
y=x1**2+x2**2

GAM <- gam(y~s(x1)+s(x2)-1) # model with no constant 

(newdata = data.frame(x1 = c(1, 0, 1), x2 = c(0, 2, 2)))
(predict(GAM, newdata = newdata) -> pred)
pred[1]+pred[2] # which is not equal to pred[3]

因为s()样条曲线本身包含常数项(我想),所以s(0)不一定等于0,然后prediction(0,1)+prediction(2,0) <> prediction(2,1) 但是在GAM(y〜s(x1)+ s(x2))模型的情况下,如何分解预测以使prediction(0,1)+prediction(2,0) == prediction(2,1)成立?

0 个答案:

没有答案