# GAM in R; an intercept term

I am dealing with GAM models. I don't understand the intercept term there. Consider the following simple model.

library(mgcv)

n=1000
X1=rnorm(n,1,2)
X2=rnorm(n,0,1)
y= -1 + sin(X1) + exp(X2) + rnorm(n)
fit=gam(y~s(X1)+s(X2))

summary(fit)

#Family: gaussian
#Formula: y ~ s(X1) + s(X2)

#Parametric coefficients:

#            Estimate Std. Error t value Pr(>|t|)
#(Intercept)  0.80632    0.03286   24.54   <2e-16 ***

#Approximate significance of smooth terms:
#       edf Ref.df      F p-value
#s(X1) 7.938  8.718  59.88  <2e-16 ***
#s(X2) 8.309  8.873 405.74  <2e-16 ***
#R-sq.(adj) =  0.807   Deviance explained =   81%
#GCV = 1.0987  Scale est. = 1.0798    n = 1000


The estimation of an intercept term 0.8 is far away from -1. I feel that this intercept there means something else. Then, how can I get an estimation of that -1 term?

Edit: just for better context. What I have is that the response $$Y=f_1(X_1) + f_2(X_2) + \varepsilon$$, where $$\varepsilon$$ is not nessesarily centered (nor normal actually). I want to estimate the distribution of this non-centered noise.

• The exponential term in your linear predictor is effecting the intercept since exp(0)=1. Remove it and the estimate of the intercept becomes more reasonable. Feb 3, 2022 at 16:02
• What do you mean by "Remove it"? The fact that $y$ has this form is not my choice, this is just how the data were generated. Also, the same problem is even if we have $y= -1 + sin(X1) + (X2^2 + 3*X2) + rnorm(n)$ Feb 3, 2022 at 16:44

The intercept (here) is the mean of the response:

r$$> n <- 1000 X1 <- rnorm(n,1,2) X2 <- rnorm(n,0,1) y <- -1 + sin(X1) + exp(X2) + rnorm(n) r$$> mean(y)
[1] 0.8166637
r\$> fit <- gam(y~s(X1)+s(X2))

summary(fit)
Family: gaussian

Formula:
y ~ s(X1) + s(X2)

Parametric coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)  0.81666    0.03119   26.18   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Approximate significance of smooth terms:
edf Ref.df      F p-value
s(X1) 7.312  8.331  55.45  <2e-16 ***
s(X2) 8.640  8.964 450.87  <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-sq.(adj) =  0.821   Deviance explained = 82.4%
GCV = 0.9895  Scale est. = 0.97272   n = 1000


It would represent something slightly different if you had factor terms (it would be the mean of the response in the reference group for a single factor, etc)

• Oh nice, I see that this intercept means the mean of y. In that case, do you know how can I estimate -1? Feb 3, 2022 at 21:38