Description
Add a formal overdispersion test for count data. Tests H0: variance = mean (Poisson assumption) against H1: variance > mean (suggesting Negative Binomial).
Two approaches:
- Variance/mean ratio (dispersion index) with chi-squared significance test and confidence interval
- Cameron-Trivedi regression-based test — regresses (yᵢ − ȳ)² − yᵢ on yᵢ and tests whether the slope is significantly different from zero
These are essential in epidemiology and count data analysis to determine whether a Poisson or Negative Binomial model is more appropriate. All prerequisites already exist: mean/variance in kstats-core, chi-squared distribution in kstats-distributions, and TestResult in kstats-hypothesis.
Example usage
val counts = doubleArrayOf(3.0, 7.0, 4.0, 12.0, 6.0, 9.0, 2.0, 15.0)
val result = overdispersionTest(counts)
result.statistic // dispersion index (variance / mean)
result.pValue // significance against Poisson assumption
val ct = cameronTrivediTest(counts)
ct.statistic // regression t-statistic
ct.pValue // significance of overdispersion
Related to #53, #55
Description
Add a formal overdispersion test for count data. Tests H0: variance = mean (Poisson assumption) against H1: variance > mean (suggesting Negative Binomial).
Two approaches:
These are essential in epidemiology and count data analysis to determine whether a Poisson or Negative Binomial model is more appropriate. All prerequisites already exist: mean/variance in
kstats-core, chi-squared distribution inkstats-distributions, andTestResultinkstats-hypothesis.Example usage
Related to #53, #55