Unlock the full potential of AI with Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!


Analyzing Ordinal Data in SAS — Poisson and Negative Binomial distribution
Latest   Machine Learning

Analyzing Ordinal Data in SAS — Poisson and Negative Binomial distribution

Last Updated on July 26, 2023 by Editorial Team

Author(s): Dr. Marc Jacobs

Originally published on Towards AI.

Analyzing Ordinal Data in SAS — Poisson and Negative Binomial distribution

This post is an extension to an introductory post on using PROC GLIMMIX in SAS. I already showed how to analyze ordinal data using the multinomial distribution, and the binary, binomial, and beta distribution. In this post, I will use the Poisson Distribution of which I have posted earlier as well. This post will extend those posts by analyzing the same dataset — diarrhea scores measured in pigs across time. Here, diarrhea is measured subjectively using an ordinal scoring system.

So, this post will be rather short and must be seen more as an extension to earlier PROC GLIMMIX posts. Below you will see a plot of count data overlaid with fitted distributions. Two of the most well-known and often used distribution are the Poisson and the Negative-Binomial of which the latter is more flexible. This is because the Negative-Binomial model is a mixture of two distributions — the Poisson and the Gamma distribution.

As you can see in the plot below, the negative binomial can fit the data better, yet will overestimate the number of zero’s. When dealing with counts, those zero’s can be troublesome which has led to the application of Zero-Inflated models, which I will not discuss here.

Count data overlaid with the Poisson and Negative Binomial Distribution

By definition count data are a rate which normally follows a Poisson distribution. Here, in this example, we counted the amount of diarrhea across the total time period. This means that, for an ordinal scale, we need to dichotomize it. Otherwise we do not have the ‘events’ necessary to model the rate.

From a Binomial to a Poisson data set-up. It stays the same!

Using the Binomial Distribution, you need to specify a nominator (Y) and a denominator (N). Using the Poisson distribution, you need to specify a nominator (Y) and an offset variable (N). The offset needs to be on the log scale. This offset is very important — it gives the rate the other metric it needs to be a rate.

This can be seen by using the table below. The choice to include no feces as no diarrhea or no missing has an effect on the rate, since the offset changes. This is normal since the denominator changes as well.

Including or not including a missing score has a big effect on the number of events.

In the introductory post, I already mentioned the danger of overdispersion which is common when using the Poisson distribution. This is because the Poisson is a single parameter distribution — the mean equals the variance.

To detect overdispersion, we need to run the model using a n approximate of the maximum likelihood. Here, I use Laplace. You can see I also include an offset variable, which, needs to be included on the model scale. That means I need to transform the data to log before including it.
Pearson Chi² / DF <1.5
Analysis using a Poisson Distribution. The residuals are off, but once again, they are not expected to be normal. The overdispersion metric is much more important, as is the assessment of the estimates and the standard errors.
The Test of Fixed Effects shows a day effect. The mean, which are proportions here, are not impressive. You are testing very much at the boundary of a proportion.

Now, lets see how a negative binomial looks at the data. Since the Poisson analysis already showed an absence of overdispersion, I know for sure that the Negative Binomial will detect the same. Hence, we can go straight to the analysis itself.

Analysis using a Negative Binomial Distribution. Although we must not expect Normality and homogeneity, the residuals do show quite some boundaries. So, we are using a model testing at boundary of the distribution.

Lets use a different dataset in which we know the data is more placed apart.

Here, we actually have underdispersion. Combined with the Residuals, I am pretty sure the data looks a lot like a Normal Distribution.
And the values. As you can see, the proportions are much higher which also explains why the residuals look so very nice. Data that shows proportions closer to 0.5 will look a lot like a Normal Distribution.

In summary, the Poisson distribution models count data. To analyze diarrhea using the Poisson distribution, you can use the dataset in the format used for the Binomial Distribution. Since the Poisson models a rate, you need to include an offset variable, which is the denominator in the equation. Using the Poisson, you always need to watch out for overdispersion. A good replacement for the Poisson distribution is the Negative Binomial distribution

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓