Я хочу оценить каждый компонент предиктора из модели GAM отдельно, используя опцию type="terms"
. В качестве проверки работоспособности я сравнил результаты с оценкой общего прогноза с использованием опции type="response"
.
Оказывается, результаты разные. Вот пример:
library(mgcv)
n<-200
sig <- 2
dat <- gamSim(1,n=n,scale=sig)
b<-gam(y~x0+s(I(x1^2))+s(x2)+offset(x3),da=dat)
nd <- data.frame(x0=c(.25,.5),x1=c(.25,.5),x2=c(.25,.5),x3=c(.25,.5))
a1 <- predict.gam(b,newdata=nd,type="response")
a2 <- rowSums(predict.gam(b,newdata=nd,type="terms")) + b$coefficients[1]
a1 - a2 # Should be zero!
# 1 2
# 0.25 0.50
Может ли кто-нибудь помочь мне с этой проблемой? Большое спасибо за Вашу помощь!