[R] gam(mgcv) starting values

Simon Wood simon at stats.gla.ac.uk
Mon Feb 14 14:00:53 CET 2005

My guess is that your model is predicting a negative mean for some of your 
data. Since this is not possible for a Gamma r.v. the deviance calculation 
returns something non finite, which triggers the error message. This is 
possible because you have used an identity link. Is it not possible to use 
a log link?

If you have to use an identity link then I'd first check that 

y ~ M1 + M3 + M4 + M5 + M6 + M7+ sex + M1*M3 + age

works. If it does, then you could try starting with a very large min.sp 
argument when fitting the model with s(age), and slowly reducing it until 
the the estimated smoothing parameter is non-zero --- if this works then 
you've succeeded in finding the best fit model without any E(y) becoming 
negative in the process, but if it doesn't it probably means either that 
the model structure is wrong, or some E(y) really is very close to zero.

I doubt that altering starting values is likely to help here (the starting 
values won't make any E(y)<=0, after all).


> Simon Wood simon at stats.gla.ac.uk        www.stats.gla.ac.uk/~simon/
>>  Department of Statistics, University of Glasgow, Glasgow, G12 8QQ
>>>   Direct telephone: (0)141 330 4530          Fax: (0)141 330 4814


> Hi all!
> I've got some problems with the function gam (library mgcv). For some models I
> get the error message :
> Error: no valid set of coefficients has been found:please supply starting
> values
> In addition: Warning message:
> NaNs produced in: log(x)
> This is a shortened code I used:
> gam(y ~ M1 + M3 + M4 + M5 + M6 + sex + M1*M3 + s(age),
> family=Gamma(link ="identity"),
> weights=days)
> If I add for example an additional variable, say M7, the error-message
> occures. If I add M7 in combination with for example M8 it works.
> Does somebody know, how to supply starting values or how to handle this
> problem.
> I didn't suxceed by adding
> control=gam.control(spIterType="outer"),
> or by
> sp=137722.1
> Thank you very much,
> Björn
> ______________________________________________
> R-help at 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

More information about the R-help mailing list