Dear all, I have a problem with specifying the no. of knots in our function which include gam(). I last worked with this in mid September but since then I have reinstalled R and Simon Wood's library(mgcv), which he has changed since then. The statistician (and good R-coder) with whom I co-operate is now unfortunately overloaded with teaching, and I'm in the sprut of my thesis.... I therefore would be really happy for help in solving this problem. The problem is then the way we specify the no of knots in the gam, I think. This is part of our function which worked fine in mid September: require(mgcv) if(is.null(knots)) fsp <- update.formula(formula, ~ . + s(d)) else{ fsp <- substitute(form+s(d,kn|f),list(kn=knots, form=formula)) fsp <- as.formula(deparse(fsp)) } fit <- gam(fsp, data = data, ...) ## When I do not use the argument "knots" the function still works fine, but when I do, I get the error message: Error in (kinship ~ 1) + s(d, 10 | f) : non-numeric argument to binary operator I have tried changing the line with substitute() based on what is written in ?gam but I mostly get the error message Error in terms.formula(gf, specials = c("s")) Could someone please give a hint. Thanks in advance! Sincerely, Tord Sn?ll ----------------------------------------------------------------------- Tord Sn?ll Avd. f v?xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University Villav?gen 14 SE-752 36 Uppsala, Sweden Tel: 018-471 28 82 (int +46 18 471 28 82) (work) Tel: 018-25 71 33 (int +46 18 25 71 33) (home) Fax: 018-55 34 19 (int +46 18 55 34 19) (work) E-mail: Tord.Snall at ebc.uu.se Check this: http://www.vaxtbio.uu.se/resfold/snall.htm!