[R] Question on glm for Poisson distribution.

Spencer Graves spencer.graves at pdf.com
Thu Jul 28 06:51:40 CEST 2005


	  I can't help you much, because you did not include a simple example 
that is sufficiently complete for me to run it myself and play with the 
results.

	  I ran the example "glm.D93 <- glm(counts ~ outcome + treatment, 
family=poisson())" in the "glm" help file.  Then I looked at 
"str(glm.D93)";  "attributes(glm.D93)" might have been a better choice 
in this case, but "str" is more general and will expose things hidden 
from "attributes".  Then I looked at "glm.D93$contrasts", and found that 
the contrasts used for "outcome" and "treatment" were both 
"contr.treatment".  Then I tried "contr.treatment(outcome)" and got 
something useful.

	  If this is not adequate and you still could use help, PLEASE do read 
the posting guide! http://www.R-project.org/posting-guide.html and try 
this list again.

	  spencer graves

Ghislain Vieilledent wrote:

> Good afternoon,
> 
> I REALLY try to answer to my question as an autonomous student searching in 
> the huge pile of papers on my desk and on the Internet but I can't find out 
> the solution. 
> Would you mind giving me some help? Please.
> 
> #########################################
> 
> I'm trying to use glm with factors:
> 
> 
>>Pyr.1.glm<-glm(Pyrale~Trait,DataRav,family=poisson)
> 
> 
> If I have correctly payed attention to my cyber professor explanations I 
> have, for the variable Pyrale which I suppose Poisson-distributed, the 
> following mathematical expression:
> 
> P(Pyrale=k)=exp(-m).[(m^k)/k!]
> with log(m)=Intercept+Trait(i) (link function is log for Poisson 
> distribution)
> 
> Then I test the significativity of Trait:
> 
> 
>>anova(Pyr.1.glm,test="Chisq")
> 
> Analysis of Deviance Table
> 
> Model: poisson, link: log
> 
> Response: Pyrale
> 
> Terms added sequentially (first to last)
> 
> 
> Df Deviance Resid. Df Resid. Dev P(>|Chi|)
> NULL 19 49.813 
> Trait 3 31.281 16 18.532 7.419e-07
> 
> Which means that variable Trait is significant for determining the value of 
> P(Pyrale=k).
> 
> I tried to order the effects of the modalities of my variable Trait using:
> 
>  > summary(Pyr.1.glm)
> 
> Call:
> glm(formula = Pyrale ~ Trait, family = poisson, data = DataRav)
> 
> Deviance Residuals: 
> Min 1Q Median 3Q Max 
> -1.7117 -0.8944 -0.6237 0.6390 1.5224 
> 
> Coefficients:
> Estimate Std. Error z value Pr(>|z|) 
> (Intercept) 1.3350 0.2294 5.819 5.92e-09 ***
> TraitIns&Fong -2.9444 1.0259 -2.870 0.00410 ** 
> TraitInsecticide -2.2513 0.7434 -3.028 0.00246 ** 
> TraitTemoin -0.2364 0.3454 -0.684 0.49372 
> ---
> Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
> 
> (Dispersion parameter for poisson family taken to be 1)
> 
> Null deviance: 49.813 on 19 degrees of freedom
> Residual deviance: 18.532 on 16 degrees of freedom
> AIC: 61.85
> 
> Number of Fisher Scoring iterations: 5
> 
> ##############################################################
> 
> I have therefore two questions:
> 
> - Considering the values of estimated coefficients for Trait(i), does it 
> mean that the bigger is the coefficient, the lower is the probability 
> considering the mathematical expression (exp(-m))?
> 
> - How can I check that coefficients are significatively different one from 
> each other (as with function TukeyHSD for other models)?
> 
> 
> Thanks for you help.
> 
> Regards
> 
> Ghislain.
> 
> 
> 

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915




More information about the R-help mailing list