[R] GAM Penalised Splines - Intercept
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed Apr 24 00:03:35 CEST 2013
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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list