Re: [R] gam error

From: Gavin Simpson <>
Date: Thu, 03 Jun 2010 14:10:59 +0100

On Thu, 2010-06-03 at 04:24 -0700, natalieh wrote:
> Hi all,
> I'm trying to use a gam (mgcv package) to analyse some data with a roughly U
> shaped curve. My model is very simple with just one explanatory variable:
> m1<-gam(CoT~s(incline))
> However I just keep getting the error message
> "Error in, dk$data, dk$knots) :
> A term has fewer unique covariate combinations than specified maximum
> degrees of freedom"

What this means is that you have fewer unique values for 'incline' than you have knots in the spline. I forget now what the default (k = -1) in function s() means, but it will be there in the help.

To set an upper limit, you could try:

K <- length(unique(incline)) - 1
m1 <- gam(CoT ~ s(incline, k = K))

Furthermore, you could try:


where 'obj' is/are your R data objects to check that R and you have the same impression of what your data actually.


> Just wondering if anyone had come across this before/ could offer any advice
> on where the problem might lie
> Many thanks,
> Natalie

 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e]
 Gower Street, London          [w]
 UK. WC1E 6BT.                 [w]

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 03 Jun 2010 - 13:10:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Jun 2010 - 13:10:27 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive