Okay, let's tackle modeling a discrete variable constrained between 0 and an unbounded upper value. This type of variable is commonly referred to as count data. Examples include the number of emails received per day, the number of defects in a manufactured item, the number of website visits, or the number of customer complaints.
🎯 Problem Setup
Let's assume:
- We observe a response (dependent) variable ( y ) such that:
( y \in {0, 1, 2, 3, ... } )
- ( y ) is non-negative and discrete.
- There is no strict upper bound, or the upper bound is practically infinite in the context of the data.
- We have predictors ( X ), and we want to predict ( y ) as a function of ( X ).
We wish to build a Bayesian model:
[
p(\theta \mid y, X) \propto p(y \mid X, \theta) \cdot p(\theta)
]
where ( \theta ) represents the model parameters.
❌ Why Not a Regular (Normal) Linear Model?
A standard linear regression model assumes:
[
y = X\beta + \epsilon, \quad \text{where } \epsilon \sim \mathcal{N}(0, \sigma^2)
]
This model is inappropriate for count data for several fundamental reasons:
- Discrete vs. Continuous: The Normal distribution is continuous, meaning it assigns probabilities to all real numbers. The outcome variable ( y ) is discrete, only taking integer values. While we could round the predictions, the underlying distributional assumption is fundamentally mismatched.
- Non-Negativity Constraint: The Normal distribution has support over the entire real line, (−∞,+∞). This means it can, and often does, predict negative values for ( y ). Since the actual count ( y ) cannot be negative (it must be y≥0), a standard Normal linear model can produce nonsensical predictions, especially when the predictors suggest a low expected count.
- Variance Assumption: The Normal distribution assumes a constant variance ( \sigma^2 ) regardless of the mean. For count data, the variance is often dependent on the mean. Typically, for count data, the variance tends to be larger than the mean (overdispersion), or sometimes equal (like in Poisson). A constant variance assumption is usually incorrect.
- Mean-Variance Relationship: The expected value ( E[y] = X\beta ) can theoretically take any real value. However, for count data, the expected value (the mean count) must be non-negative. If we directly model ( E[y] = X\beta ), ( X\beta ) could easily become negative, which is invalid for the mean of a count distribution.
✅ Appropriate Bayesian Model Choices
To model discrete, non-negative count data, we need likelihood functions defined over non-negative integers. The most common choices are the Poisson distribution and the Negative Binomial distribution.
1. Likelihood Function
A. Poisson Regression Likelihood
The Poisson distribution is a common choice for count data.
-
Probability Mass Function (PMF):
[ p(y \mid \lambda) = \frac{\lambda^y e^{-\lambda}}{y!} \quad \text{for } y \in {0, 1, 2, ...} ]
-
Parameters: It has a single parameter, ( \lambda ), which represents both the mean and the variance: E[y]=Var(y)=λ.
-
Modeling the Mean: Since ( \lambda ) must be positive (λ>0) and ( X\beta ) can range over all real numbers, we cannot directly equate ( \lambda = X\beta ). Instead, we use a to transform the linear predictor ( X\beta ) into the positive parameter space for ( \lambda ). The standard link function for count data is the :
[ \log(\lambda_i) = X_i \beta ]
This implies:
[ \lambda_i = \exp(X_i \beta) ]
The exponential function ensures that ( \lambda_i ) is always positive, regardless of the values in ( X_i \beta ). As ( X_i \beta ) increases without bound, ( \lambda_i ) also increases without bound, naturally handling the "unbounded upper value" aspect of the response.
B. Negative Binomial Regression Likelihood
The Poisson distribution assumes the variance equals the mean. However, count data often exhibits overdispersion, meaning the variance is greater than the mean. The Negative Binomial distribution is a generalization of the Poisson that accounts for this overdispersion.
- Parameterization: There are several parameterizations. A common one in regression models relates