Hello,
I have a dataset that looks like this:
data geometric;
input observation freq;
datalines;
1 2
2 0
3 1
4 3
5 4
6 7
etc......
;
I am trying to determine if my data fits a geometric distribution versus a poisson distribution.
Any help or suggestions would be greatly appreciated!
Thank you,
Michelle
There are several ways to do this. In general, you will need two runs, one for Poisson and one for geometric distribution, and then compare the -2 log-likelihoods. I demonstrate with PROC GLIMMIX, with my example code.
data a;
input x count;
datalines;
0 10
1 16
2 14
3 21
4 17
5 16
6 13
7 13
8 10
9 6
10 5
11 1
12 2
;
run;
proc glimmix data=a;
title 'Poisson';
model x = / dist=poisson s;
freq count;
run;
proc glimmix data=a;
title 'Geometric';
model x = / dist=geometric s;
freq count;
run;
proc glimmix data=a;
title 'Negative Binomial';
model x = / dist=nb s;
freq count;
run;
*another way to get geometric (neg bin with scale=1);
proc glimmix data=a;
title 'Neg.Bin. with Scale=1 (identical to Geometric)';
model x = / dist=nb s;
freq count;
parms (1) / hold=1; *hold Scale to 1 to get geometric;
run;
Note that Poisson and geometric are 1-parameter distributions, so one can directly compare the -2LL values in the output. I also show the fit of the negative binomial, which is a two-parameter distribution which reduces to the Poisson as the Scale goes to 0 (the way GLIMMIX parameterizes it). I bring it up because another special case of the negative binomial is the geometric (when the neg bin Scale = 1). So, I show how to fit this in GLIMMIX also. Note that the results are identical for dist=geometric and dist=nb with the parms (1) statement (last one).
Because negative binomial has two parameters, use AIC to compare fits of different distributions. one can also use other aspects of the fit (e.g., Pearson chi-square) for comparisons, but I won't get into that.
There are other programs that could also be used.
There are several ways to do this. In general, you will need two runs, one for Poisson and one for geometric distribution, and then compare the -2 log-likelihoods. I demonstrate with PROC GLIMMIX, with my example code.
data a;
input x count;
datalines;
0 10
1 16
2 14
3 21
4 17
5 16
6 13
7 13
8 10
9 6
10 5
11 1
12 2
;
run;
proc glimmix data=a;
title 'Poisson';
model x = / dist=poisson s;
freq count;
run;
proc glimmix data=a;
title 'Geometric';
model x = / dist=geometric s;
freq count;
run;
proc glimmix data=a;
title 'Negative Binomial';
model x = / dist=nb s;
freq count;
run;
*another way to get geometric (neg bin with scale=1);
proc glimmix data=a;
title 'Neg.Bin. with Scale=1 (identical to Geometric)';
model x = / dist=nb s;
freq count;
parms (1) / hold=1; *hold Scale to 1 to get geometric;
run;
Note that Poisson and geometric are 1-parameter distributions, so one can directly compare the -2LL values in the output. I also show the fit of the negative binomial, which is a two-parameter distribution which reduces to the Poisson as the Scale goes to 0 (the way GLIMMIX parameterizes it). I bring it up because another special case of the negative binomial is the geometric (when the neg bin Scale = 1). So, I show how to fit this in GLIMMIX also. Note that the results are identical for dist=geometric and dist=nb with the parms (1) statement (last one).
Because negative binomial has two parameters, use AIC to compare fits of different distributions. one can also use other aspects of the fit (e.g., Pearson chi-square) for comparisons, but I won't get into that.
There are other programs that could also be used.
Here are an example for Rick's blog:
http://blogs.sas.com/content/iml/2012/04/12/the-poissonness-plot-a-goodness-of-fit-diagnostic.html
http://blogs.sas.com/content/iml/2012/04/04/fitting-a-poisson-distribution-to-data-in-sas.html
I think maybe you could produce empirical quantile and theory quantile and use Chisq Distribution to compare them ?
Hmm, Interesting. RPOC GENMOD also can do that . proc genmod data=a; title 'Poisson'; model x = / dist=poisson ; freq count; run; proc genmod data=a; title 'Geometric'; model x = / dist=geometric ; freq count; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.