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@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.