Federico Gherardini
2004-Nov-25 13:00 UTC
[R] Error using glm with poisson family and identity link
Hi all I'm trying to use the function glm from the MASS package to do the following fit. fit <- glm(FP ~ rand, data = tab, family = poisson(link = "identity"), subset = rand >= 1) (FP is >= 0) but I get the following error Error: no valid set of coefficients has been found:please supply starting values In addition: Warning message: NaNs produced in: log(x) in contrast if I fit a model without intercept fit <- glm(FP ~ rand - 1, data = tab, family = poisson(link = "identity"), subset = rand >= 1) everything goes fine. Now my guess is that the points "naturally" have a negative intercept so the error is produced because I'm using the poisson distribution for the y and negative values are of course not admitted. Am I right? Also if this is the cause, shouldn't the function always try to do the best fit given the parameters? I mean shouldn't it fit a model with intercept 0 anyway and report it as a bad fit? Thanks Federico
Prof Brian Ripley
2004-Nov-25 15:41 UTC
[R] Error using glm with poisson family and identity link
On Thu, 25 Nov 2004, Federico Gherardini wrote:> Hi all > I'm trying to use the function glm from the MASS package to do the followingIt's in the stats package.> fit. > > fit <- glm(FP ~ rand, data = tab, family = poisson(link = "identity"), subset > = rand >= 1) > (FP is >= 0) > > but I get the following error > > Error: no valid set of coefficients has been found:please supply starting > values > In addition: Warning message: > NaNs produced in: log(x)And did you follow the advice in the error message?> in contrast if I fit a model without intercept > > fit <- glm(FP ~ rand - 1, data = tab, family = poisson(link = "identity"), > subset = rand >= 1) > > everything goes fine. > Now my guess is that the points "naturally" have a negative intercept so the > error is produced because I'm using the poisson distribution for the y and > negative values are of course not admitted. Am I right?We don't have your data, but it is plausible.> Also if this is the cause, shouldn't the function always try to do the best > fit given the parameters? I mean shouldn't it fit a model with intercept 0 > anyway and report it as a bad fit?Well, I believe functions should do what they say on the box (and the help page), and not what some user hopes they might do by mind-reading. You do have a suitable set of starting values from the second fit, so why not just follow the rather explicit advice? -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Apparently Analagous Threads
- Negative intercept in glm poisson model
- Form of the equation produced by a GLM with Poisson family and log link function
- nobs() with glm(family="poisson")
- unexpected result in glm (family=poisson) for data with an only zero response in one factor
- Compare lm() to glm(family=poisson)