Dear Mr. Oksanen, First of all thanks for your reply. I have solved this problem in this way. My data consists of some categorical(CAT..) predictors and also some numerical variables(NUM..) have only {0,1} 0r {0,1,2,3} values. For applying GAM i just didnot consider their splines. I had came to this decision because when i tested the same data on S-PLUS, i got an error regarding the applicability of s(...) function on the predictors less than 4 different values. I dont know whether gam() of S-PLUS and gam() of mgcv(R) are same or not. anyway, thanks for your kind reply.
bye Jari Oksanen wrote: > > spime <sabya23 <at> gmail.com> writes: > >> >> >> Hi all, >> >> I need some solution in the following problem. The following error >> appears >> when i use "mgcv" package for implementing GAM. But the same formula >> works >> fine in "gam" package. >> >> > model.gam <- gam(formula = RES ~ >> > CAT01+s(NUM01,5)+CAT02+CAT03+s(NUM02,5)+CAT04+ >> + CAT05+s(NUM03,5)+CAT06+CAT07+s(NUM04,5)+CAT08+s(NUM05,5)+CAT09+ >> + CAT10+s(NUM06,5)+CAT11+NUM07+CAT12+CAT13, >> + family = binomial(link = logit), data = train.data,na.action = >> na.exclude, >> + control = list(epsilon = 0.001,bf.epsilon = 0.001, maxit = 50, >> + bf.maxit = 10, trace = F)) >> >> Error in terms.formula(reformulate(term[i])) : >> invalid model formula in ExtractVars >> > It seems that nobody answered this (in public). > > It seems that function s() in mgcv is defined as: > > s(..., k = -1, fx = FALSE, bs = "tp", m = 0, by = NA) > > (Like you see reading its help ?s). The function definition starts with > "...", > and after three dots you cannot use positional arguments, but you must > give the > full argument name. Try replacing s(NUM01, 5) with s(NUM01, k=5). See also > help > in mgcv (?s pointing to ?choose.k) for interpreting argument 'k' which is > not > directly degrees of freedom. > > There may be other problems, but this probably fixes tha one you reported > above. > > cheers, jari oksanen > >> And after deleting df's >> >> model.gam <- gam(formula = RES ~ >> CAT01+s(NUM01)+CAT02+CAT03+s(NUM02)+CAT04+ >> + CAT05+s(NUM03)+CAT06+CAT07+s(NUM04)+CAT08+s(NUM05)+CAT09+ >> + CAT10+s(NUM06)+CAT11+NUM07+CAT12+CAT13, >> + family = binomial(link = logit), data = train.data) >> >> Error in smooth.construct.tp.smooth.spec(object, data, knots) : >> A term has fewer unique covariate combinations than specified >> maximum degrees of freedom >> >> Can anybody show me some light in this case!!! >> >> Thanks in advance. > > ______________________________________________ > R-help@stat.math.ethz.ch 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. > > -- View this message in context: http://www.nabble.com/Error-using-mgcv-package-tf3900783.html#a11075667 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@stat.math.ethz.ch 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.