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" Just wondering if anyone had come across this before/ could offer any advice on where the problem might lie Many thanks, Natalie -- View this message in context: http://r.789695.n4.nabble.com/gam-error-tp2241518p2241518.html Sent from the R help mailing list archive at Nabble.com.
Data? On Thu, Jun 3, 2010 at 1:24 PM, natalieh <fbsnch@leeds.ac.uk> 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" > > Just wondering if anyone had come across this before/ could offer any > advice > on where the problem might lie > > Many thanks, > > Natalie > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/gam-error-tp2241518p2241518.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 Joris.Meys@Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]]
How many datapoints do you have? The spline smoothers assume a default of 10 degrees of freedom (i think), so If you have less datapoints than 10 I would guess that you get this error. Same would be true if you have >10 datapoints but many replicates of CoT~incline combinations. Either reduce the degrees of freedom of the smoother or gather more data ;-). I would not be too sure about the sense of fitting univariate gams....There should be not too much of a difference to just plotting CoT~incline and fitting some spline to it ( i might be wrong here!) HTH Jannis --- natalieh <fbsnch at leeds.ac.uk> schrieb am Do, 3.6.2010:> Von: natalieh <fbsnch at leeds.ac.uk> > Betreff: [R] gam error > An: r-help at r-project.org > Datum: Donnerstag, 3. Juni, 2010 11:24 Uhr > > 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" > > Just wondering if anyone had come across this before/ could > offer any advice > on where the problem might lie > > Many thanks, > > Natalie > > > > -- > View this message in context: http://r.789695.n4.nabble.com/gam-error-tp2241518p2241518.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
Data? The data are measures of energy use (continuous variable) for running on 7 inclines between -90 and +90 degrees (n=7-21). -- View this message in context: http://r.789695.n4.nabble.com/gam-error-tp2241518p2241608.html Sent from the R help mailing list archive at Nabble.com.
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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%