[R] Understanding why a GAM can't suppress an intercept

Simon Wood s.wood at bath.ac.uk
Wed Apr 17 11:16:31 CEST 2013


hi Andrew.

gam does suppress the intercept, it's just that this doesn't force the 
smooth through the intercept in the way that you would like. Basically 
for the parameteric component of the model '-1' behaves exactly like it 
does in 'lm' (it's using the same code). The smooths are 'added on' to 
the parametric component of the model, with sum to zero constraints to 
force identifiability.

There is a solution to forcing a spline through a particular point at
http://r.789695.n4.nabble.com/Use-pcls-in-quot-mgcv-quot-package-to-achieve-constrained-cubic-spline-td4660966.html
(i.e. the R help thread "Re: [R] Use pcls in "mgcv" package to achieve 
constrained cubic spline")

best,
Simon

On 16/04/13 22:36, Andrew Crane-Droesch wrote:
>>   Dear List,
>>
>> I've just tried to specify a GAM without an intercept -- I've got one
>> of the (rare) cases where it is appropriate for E(y) -> 0 as X ->0.
>> Naively running a GAM with the "-1" appended to the formula and the
>> calling "predict.gam", I see that the model isn't behaving as expected.
>>
>> I don't understand why this would be.  Google turns up this old R help
>> thread: http://r.789695.n4.nabble.com/GAM-without-intercept-td4645786.html
>>
>> Simon writes:
>>
>>      *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.
>>
>> Why?  I haven't read Simon's book in great detail, though I have read
>> Ruppert et al.'s Semiparametric Regression.  I don't see a reason why
>> a penalized spline model shouldn't equal the intercept (or zero) when
>> all of the regressors equals zero.
>>
>> Is anyone able to help with a bit of intuition?  Or relevant passages
>> from a good description of why this would be the case?
>>
>> Furthermore, why does the "-1" formula specification work if it
>> doesn't work "as intended" by for example lm?
>>
>> Many thanks,
>> Andrew
>>
>>
>>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>


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



More information about the R-help mailing list