[R] Error using glm with poisson family and identity link

Spencer Graves spencer.graves at pdf.com
Thu Nov 25 18:22:59 CET 2004


Dear Federico: 

      Why do you use the "identity" link?  That can produce situations 
with an average of (-2) Poisson defects per unit, for example.  That's 
physical nonsense.  Also, it seems essentially to be generating your 
error message. 

      Also, have you considered the following: 

fit <- glm(FP ~ offset(log(rand)), data = tab, family = poisson, subset 
= rand >= 1)

      I haven't tried this, but it looks like this model is virtually 
equivalent to the one you wrote: 

      "FP ~ rand-1" with link = "identity" says "estimate 'b' in 
PoissonMean = b*rand". 

      "FP ~ offset(log(rand))" with link = "log" (the default) says 
"estimate 'a' in log(PoissonMean)-log(rand) = a". 

      If I haven't made an error, then log(b) = a. 

      In more general situations, if you really need the "identity" 
link, have you considered searching for good starting values, as Prof. 
Ripley suggested?  You could build up to your final model by estimating 
simpler models and obtaining trial fits using the default "log" link?  
With those results and a little thought, you should be able to obtain 
reasonable starting values. 

      hope this helps. 
      spencer graves

Prof Brian Ripley wrote:

> 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 
>> following
>
>
> It'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?
>

-- 
Spencer Graves, PhD, Senior Development Engineer
O:  (408)938-4420;  mobile:  (408)655-4567




More information about the R-help mailing list