Re: [R] gam error

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
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 smooth.construct.tp.smooth.spec(object, 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:

str(obj)

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

HTH G

> 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] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
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.
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive