# [R] comparing poisson distributions

Greg Snow Greg.Snow at imail.org
Thu Dec 20 22:53:18 CET 2007

```The other one I should have mentioned:

5.1:  Use the glm function with family = poisson.  The counts are the y
variable and the x variable is either 0/1 or a 2 level factor indicating
which group the values come from.  The p-value for the slope of x tests
for a difference in the 2 groups.

5.2 if this is just to make someone happy who always wants a p-value,
but doesn't understand it and will never actually use it, then use
runif.

5.3 ...

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111

> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Greg Snow
> Sent: Thursday, December 20, 2007 1:20 PM
> To: Mark Gosink; r-help at r-project.org
> Subject: Re: [R] comparing poisson distributions
>
> There are a few different options that you can try depending
>
> 1.  For large lambda the poisson can be approximated by a
> normal, for large n (even for small lambda) the mean is
> approximately normal due to the central limit theorem.  So if
> your lambda and n are large enough in combination then you
> could just do a standard 2 sample t-test (t.test
> function) and use the approximate p-value from there.
>
> 2.  Fit 2 models by maximum likelihood, one in which both
> lambdas are equal and one in which they can differ (fitdistr
> from MASS may help, or look at optim and friends), then do a
> likelihood ratio test on the differences (-2 * likelihood
> diff is approx chisquared(1) under the null).
>
> 3.  Do a permutation test:  find the difference in the
> means/medians/(other stat of interest) between the 2 samples,
> then permute the samples randomly (create 2 samples of the
> same sizes from the original data values, but with random
> assignment as to which group a value goes into) and find the
> same difference, repeate a bunch of times (like 1998) and
> combine all the differences found into a vector, plot the
> histogram of the values and look at where the original
> difference fits into the distribution.  The number of values
> that are as or more extreeme than the original value is your p-value.
>
> 4.  Create logical bins for values (e.g. 0-1, 2-3, 4-6, 7+)
> and count how many from each group fall in each bin, use
> prop.test or chisq.test to see if the proportions differ.
>
> 5.  Probably some others that don't come to mind right now.
>
> Hope this helps,
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow at imail.org
> (801) 408-8111
>
>
>
> > -----Original Message-----
> > From: r-help-bounces at r-project.org
> > [mailto:r-help-bounces at r-project.org] On Behalf Of Mark Gosink
> > Sent: Tuesday, December 18, 2007 12:31 PM
> > To: r-help at r-project.org
> > Subject: [R] comparing poisson distributions
> >
> > Hello all,
> >
> >             I would like to compare two sets of count data
> which form
> > Poisson distributions. I'd like to generate some sort of p-value of
> > the likely-hood that the distributions are the same. Thanks
> >
> >
> >
> > Cheers,
> >
> > Mark
> >
> >
> >
> > Mark Gosink, Ph.D.
> >
> > Head of Computational Biology
> > Scripps Florida
> > 5353 Parkside Drive - RFA
> > Jupiter, FL  33458
> > tel: 561-799-8921
> > fax: 561-799-8952
> > gosink at scripps.edu
> >
> >
> >
> >
> > 	[[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help