Programming the statistical procedures from SAS

Determining goodness of fit to geometric distribution

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Determining goodness of fit to geometric distribution

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 

 

 


Accepted Solutions
Solution
‎07-22-2016 01:12 PM
Valued Guide
Valued Guide
Posts: 684

Re: Determining goodness of fit to geometric distribution

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


All Replies
Solution
‎07-22-2016 01:12 PM
Valued Guide
Valued Guide
Posts: 684

Re: Determining goodness of fit to geometric distribution

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.

Super User
Posts: 9,775

Re: Determining goodness of fit to geometric distribution

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 ?

Super User
Posts: 9,775

Re: Determining goodness of fit to geometric distribution

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;


Occasional Contributor
Posts: 15

Re: Determining goodness of fit to geometric distribution

This is just what I needed, thank you!
Valued Guide
Valued Guide
Posts: 684

Re: Determining goodness of fit to geometric distribution

Glad it worked. You could indicate on the website that this was a Solution.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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