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.