BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
simkinm2
Calcite | Level 5

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 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

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.

View solution in original post

5 REPLIES 5
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12

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.

Ksharp
Super User

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 ?

Ksharp
Super User
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;


simkinm2
Calcite | Level 5
This is just what I needed, thank you!
lvm
Rhodochrosite | Level 12 lvm
Rhodochrosite | Level 12
Glad it worked. You could indicate on the website that this was a Solution.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 5 replies
  • 2007 views
  • 7 likes
  • 3 in conversation