GAM Penalised Splines - Intercept

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GAM Penalised Splines - Intercept

Lucas Holland
Hey all,

I'm using the gam() function inside the mgcv package to fit a penalised spline to some data. However, I don't quite understand what exactly the intercept it includes by default is / how to interpret it.

Ideally I'd like to understand what the intercept is in terms of the B-Spline and/or truncated power series basis representation.

Thanks!

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: GAM Penalised Splines - Intercept

Gavin Simpson
On Tue, 2013-04-23 at 17:51 +0200, Lucas Holland wrote:
> Hey all,
>
> I'm using the gam() function inside the mgcv package to fit a
> penalised spline to some data. However, I don't quite understand what
> exactly the intercept it includes by default is / how to interpret
> it.
>
> Ideally I'd like to understand what the intercept is in terms of the
> B-Spline and/or truncated power series basis representation.

It is the mean of the response:

library(mgcv)
set.seed(2) ## simulate some data...
dat <- gamSim(1, n=400, dist="normal", scale=2)
#Gu & Wahba 4 term additive model

> b <- gam(y ~ s(x2), data = dat)
> coef(b)[1]
(Intercept)
   7.833279
> with(dat, mean(y))
[1] 7.833279
> b2 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)
> coef(b2)[1]
(Intercept)
   7.833279

In models with parametric factor terms what the intercept is depends on
the contrasts used - the default in R would represent the mean of the
response for the reference level(s) of factor terms in the model.

The intercept is separates from the penalised spline terms in the model.

HTH

G

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.