Smooth terms are constrained to sum to zero over the covariate values. This is an identifiability constraint designed to avoid confounding with the intercept (particularly important if you have more than one smooth). If you remove the intercept from you model altogether (m2) then the smooth will still sum to zero over the covariate values, which in your case will mean that the smooth is quite a long way from the data. When you include the intercept (m1) then the intercept is effectively shifting the constrained curve up towards the data, and you get a nice fit.

So it's not quite true that m2 has nothing to do with the data. The curve you get is as close to the data as a curve constrained to average to zero can get.

best,
Simon



On 10/10/12 23:22, SAEC wrote:
Hi everybody,

I am trying to fit a GAM model without intercept using library mgcv.
However, the result has nothing to do with the observed data. In fact
the predicted points are far from the predicted points obtained from the
model with intercept. For example:

#First I generate some simulated data:

library(mgcv)
x<-seq(0,10,length=100)
y<-x^2+rnorm(100)

#then I fit a gam model with and without intercept

m1<-gam(y~s(x,k=10,bs='cs'))
m2<-gam(y~s(x,k=10,bs='cs')-1)

#and now I obtain predicted values for the interval 0-1

x1<-seq(0,10,0.1)
y1<-predict(m1,newdata=list(x=x1))
y2<-predict(m2,newdata=list(x=x1))

#plotting predicted values

plot(x,y,ylim=c(0,100))
lines(x1,y1,lwd=4,col='red')
lines(x1,y2,lwd=4,col='blue')

In this example you can see that the red line are the predicted points
from the model with intercept which fit pretty good to the data, but the
blue line (without intercept) is far from the observed points.

Probably I missunderstanding some key elements in gam modelling or using
incorrect syntaxis. I don't know what the problem is. Any ideas will be
helpful.

Sergio









--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603               http://people.bath.ac.uk/sw283

______________________________________________
R-help@r-project.org 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 via email to