EM for zero-inflated negative binomial regression Created 2026-10-05 Updated 2026-10-14
For known size and , the expectation-maximization algorithm gives structural-zero responsibility for positive counts and for zero counts. This is Bayes' theorem. Maximizing the expected complete-data log-likelihood gives and a weighted negative binomial regression with weights . The objective separates into a Bernoulli mixing term and a weighted count term, which proves the update.
Past exam of the mathematics course of the University of Cambridge 2008 iii Paper 46 1 c Solution Created 2026-10-03 Updated 2026-10-14
The solid Poisson regression profile and dashed negative binomial regression profile peak at essentially the same . The dashed profile is slightly wider and has heavier shoulders: it gives larger relative likelihood to values farther from the common maximizer. Thus the estimated mean ratio is stable, while the negative binomial model expresses slightly greater uncertainty.
The Poisson distribution constrains variance to equal the mean. A common negative binomial parametrization instead has , with additional shape ; it permits overdispersion due, for example, to unexplained between-physician heterogeneity. Profiling this extra parameter lets the data support greater count variability and usually reduces information about the mean contrast. In this two-group model, the fitted group means remain the sample means for fixed , which explains the nearly identical maximizers. The small separation of the profiles indicates a modest effect here, not overwhelming evidence for strong overdispersion. The comparison concerns the original PDF figure; no figure is reproduced.
Past exam of the mathematics course of the University of Cambridge 2009 iii Paper 102 3 b Solution Created 2026-10-03 Updated 2026-10-14
Let be passenger count and use a Poisson regression with log mean, initially treating the response as a working daily count:Center and scale the continuous predictors before fitting, and compare a small set of defensible reduced models rather than saturating twenty observations. Household counts should not be called household proportions without a household denominator; population-scaled counts are alternative intensity covariates. Bus miles can be an estimated elasticity term rather than an offset, since proportionality of passenger numbers to bus miles has not been established.
For actual counts, the log-likelihood score is , with . Fitting by iteratively reweighted least squares uses weights and working response . Compare nested means by a likelihood-ratio test only if the Poisson variance assumption is plausible; check the Poisson deviance, Pearson dispersion , residuals, leverage and sensitivity to influential providers. Consider Quasi-Poisson regression or negative binomial regression if variance exceeds the mean.
The recorded response is actually a daily average, so Poisson working models for averaged counts need special care. If a provider was observed for days and total passengers were , fit with offset . If only the average and no observation duration are available, a Poisson mean model can still be explored, but its likelihood and standard errors are not automatically justified by integer-looking averages.
A one-unit increase in an untransformed predictor has fitted multiplicative mean effect ; a bus-mile elasticity gives a doubling effect . No numerical coefficient estimates or selected twenty-provider model are identifiable from the printed excerpt. The full provider file and, ideally, the averaging periods are needed to execute these model comparisons.
Past exam of the mathematics course of the University of Cambridge 2014 iii Paper 33 4 c Solution 2026-10-06
The residual deviance is on residual degrees of freedom. Under a suitable Poisson deviance goodness-of-fit test approximation it is compared with , whose supplied 95th percentile is . Since is much larger, the chosen Poisson model does not provide a satisfactory absolute fit, despite being preferred among the three candidates.
The ratio suggests substantial overdispersion or mean-model misspecification. It is a deviance ratio, not the exact Pearson dispersion estimator, which cannot be computed from the excerpt. Check residual patterns, nonlinear effects, unusual rivers and dependence. A Quasi-Poisson regression could adjust uncertainty under an estimated dispersion, and a negative binomial regression could model extra count variation; a more adequate mean model may also be needed. The nominal Poisson tests in part (a) should be interpreted in light of this failure, rather than treated as a validated final analysis.
Past exam of the mathematics course of the University of Cambridge 2015 iii Paper 35 1 d Solution Created 2026-10-03 Updated 2026-10-06
Multiple imputation by chained equations specifies one conditional distribution for each incomplete variable. In general, let be the incomplete variables, the fully observed predictors, and the parameters of a model . The notation means all variables except . The models should respect each variable's support and contain the terms needed by the planned analysis.
First choose suitable models and initialise only the missing entries with admissible provisional values. One sweep updates in turn. At update , fit its model to records whose is observed, using the latest filled-in predictors. DrawThe first draw represents parameter uncertainty through a Bayesian posterior; the second represents residual uncertainty through a posterior predictive distribution. Replace the missing entries with these draws, leaving every genuinely observed entry fixed. Repeat whole sweeps until the chain has settled, assessing traces, mixing and plausibility. Obtain completed datasets from independently initialised chains, or sufficiently separated draws after convergence. Both parameter and missing-value uncertainty must be propagated; repeated deterministic prediction is not multiple imputation.
Here use a logistic regression for conditional on , age and sex. For , use an appropriate discrete count model conditional on , age and sex, such as a suitably checked negative binomial regression, allowing enough flexibility for skewness and nonlinear effects. Include interactions or transformations needed by the analysis in the imputation models. If condom use is structurally undefined for a record, preserve that applicability rule rather than treating it as ordinary missing data.
Impute the eligible survey information before discarding records solely because the observed is absent. In each completed dataset select its own records and fit the requested logistic regression. This allows a record with missing to contribute to the target group in some imputations and not others. Models must respect any known eligibility restrictions; if eligibility was independently known, use that information.
For a scalar regression coefficient, let be its estimate and its estimated variance in completed dataset . Rubin's rules giveThe standard error is . Use the corresponding multiple-imputation confidence interval, rather than treating one completed dataset as fully observed. For vector coefficients replace the squared differences by outer products and by the covariance matrix. This combines within-imputation and between-imputation uncertainty.
Past exam of the mathematics course of the University of Cambridge 2016 iii Paper 206 3 d Solution Created 2026-10-03 Updated 2026-10-06
Use negative binomial regression with a logarithmic mean link, for exampleIn the mean-size parametrization,The extra parameter allows overdispersion that grows quadratically with the mean, unlike the proportional variance of Quasi-Poisson regression.
library(MASS)
species_nb <- glm.nb(nspecies ~ altitude, link = log)The printed assertion needs qualification: a negative-binomial model with fixed size is a generalized linear model. For known , its probability mass function isWith natural parameter , it has exponential family formwith dispersion one. A logarithmic link is permitted even though it is not the canonical link function. This is the fixed-size negative binomial generalized linear model.
What prevents a single ordinary fixed-family GLM fit in
glm.nb is joint estimation of the unknown size : it changes the cumulant, carrier, and variance function, rather than merely multiplying a fixed variance function by a scalar dispersion. The routine alternates a GLM fit at fixed with size-parameter likelihood updates. Thus the intended distinction is between that enlarged fitting problem and a single fixed-family GLM, not a claim that negative-binomial regression can never be a GLM. The package documentation explicitly supports both conventions: stat.ethz.ch/R-manual/R-patched/library/MASS/html/glm.nb.html and stat.ethz.ch/R-manual/R-patched/library/MASS/html/negative.binomial.html. Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 1 c Solution Created 2026-10-03 Updated 2026-10-05
The negative binomial regression assumes independent random variables conditional on their recorded days, withThe logarithmic link function applies to the conditional expectation, not to the observed count. The displayed maximum-likelihood estimates areand the dispersion parameter for the fitted family is one. Thus the fitted variance is , practically the Poisson distribution variance at these means.
Increasing the day by one multiplies the conditional expectation by , a decrease of about . Comparing days 365 and 1 gives . The negative slope has Wald statistic approximately , so under the stated model assumptions there is very strong evidence of a decreasing conditional mean:This is an association with calendar day, not a causal effect established by the regression. The printed negative-binomial residual deviance is on residual degrees of freedom, which is a reason to investigate the adequacy of the assumed count model and dependence structure. In particular, the small reported slope standard error cannot make a misspecified model reliable.
Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 1 d Solution Created 2026-10-03 Updated 2026-10-05
Introduce a latent Bernoulli distribution indicator , with denoting a structural zero and . Conditional on , retain the negative binomial regression with and . This gives a zero-inflated negative binomial model:A participant who fishes may still catch zero, so an observed zero does not reveal the latent class. This distinguishes zero inflation from a hurdle model, which truncates the count component at zero. The marginal expectation becomes , and the law of total variance givesA constant is a parsimonious starting model. If there is evidence that nonparticipation changes with day or other recorded predictors, use logistic regression for instead. Conditional independence of visitors remains an assumption; extra zeros alone do not establish its validity.
Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 1 f Solution Created 2026-10-05 Updated 2026-10-14
For EM for zero-inflated negative binomial regression, at iteration apply Bayes' theorem to each zero in the zero-inflated negative binomial model. The E step computes the conditional expectation of its latent indicator:Treating these values as fixed, the M step maximizes the expected complete-data log-likelihood. Its two parameter blocks separate:The second block is a weighted negative binomial regression with fixed size . Writing and , its parameter-dependent objective isIts score function and negative Hessian matrix areThe objective is concave, so a finite maximizer, when it exists, can be found by Newton method or iteratively reweighted least squares. The latter uses working response and weights . This is not an unweighted regression on only the positive counts: zeros retain fractional weight in the count component.
Start with and finite coefficients, alternate the two steps, and monitor the observed log-likelihood. Exact maximization makes the expectation-maximization algorithm nondecreasing in that likelihood, although the mixture may have multiple stationary points. All-zero data can lead to boundary fits and poor identification; multiple initializations and explicit checks for boundary parameters are useful.
Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 3 d Solution Created 2026-10-03 Updated 2026-10-05
Because no family is specified, the command fits a Gaussian identity-link generalized additive model:The are centered penalized regression splines with cubic regression bases; centering separates them from the intercept. The age curve in the original figure falls to a minimum near age 25, then rises markedly, particularly from about 40 onwards. Its effective degrees of freedom are , reflecting curvature. The white-cell curve has effective degrees of freedom one and is nearly flat with a slight positive slope; the pointwise uncertainty bands are consistent with no substantial effect. These plots display centered partial mean contributions, not numbers of prescriptions by themselves.
A simpler mean model keeps the age regression spline and replaces the white-cell smooth by a linear term. A separate issue is that the response is a nonnegative count: a Poisson regression with logarithmic link function respects that support and positivity of the mean. A reasonable candidate isIf diagnostics show overdispersion, one can fitusing a negative binomial regression. Alternatively, if a Gaussian approximation is adequate, the minimal simplification is
model1p <- gam(npres ~ s(age, bs="cr") + wbc, family=poisson(link="log"))
gam.check(model1p)model1nb <- gam(npres ~ s(age, bs="cr") + wbc, family=nb(link="log"))gam(npres ~ s(age, bs="cr") + wbc). These are candidates to compare by diagnostics and validation, rather than guaranteed improvements from the partial plots alone. Retain the curved age effect; consider a linear or removable white-cell effect, and assess an appropriate count family. Refit before interpreting the old curves on a new link scale. Past exam of the mathematics course of the University of Cambridge 2017 ii Paper 4 12J d Solution Created 2026-09-24 Updated 2026-10-05
Under fit.2, observations in each period are independent Poisson random variables with a common mean, so each sample variance should fluctuate around its sample mean. The plot instead has variances roughly 130–300 for means roughly 80–120, well above the line variance equals mean. This is overdispersion.
Day-to-day traffic variation can produce a Poisson mixture: a random daily intensity increases the marginal variance and can correlate observations from the same day. A useful replacement is a negative binomial regression, with variance , or a Poisson generalized linear mixed model with a day random intercept. A day-factor effect can also be included if inference is restricted to the observed days. A Quasi-Poisson regression estimates a dispersion multiplier for uncertainty, but does not itself explain the shared-day dependence and has no ordinary likelihood-based AIC. The means can retain the period-factor or selected jump structure.
Past exam of the mathematics course of the University of Cambridge 2021 iii Paper 218 3 b Solution 2026-09-28
Overdispersion means that conditional variance exceeds the Poisson mean. Under a correctly specified Poisson model, the Pearson statistic is approximately chi-squared with residual degrees of freedom. Hereso a one-sided five-percent test rejects. The displayed model-based confidence interval is too narrow. A quasi-Poisson fit can multiply standard errors by ; negative binomial regression or a random-effects count model can model the extra variation directly.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 1 c Solution Created 2026-09-24 Updated 2026-09-25
The Pearson goodness-of-fit test has null hypothesis that the independent counts follow the fitted Poisson regression, in particular , against the alternative that the model does not fit; in this setting the scientifically relevant direction is overdispersion, . Under the null, is approximately chi-squared distribution with degrees of freedom. Its tiny -value decisively rejects the Poisson variance assumption.
The negative binomial regression keeps the logarithmic mean model but allows . It improves the residual deviance from to , close to its residual degrees of freedom, and lowers the Akaike information criterion from to . Both comparisons strongly favour the negative-binomial fit, although its dose coefficient remains statistically insignificant.
Past exam of the mathematics course of the University of Cambridge 2025 iii Paper 218 1 d Solution Created 2026-09-24 Updated 2026-10-03
The third fit is a negative binomial regression. The Poisson model is obtained at the boundary where the negative-binomial overdispersion tends to zero, so the likelihood-ratio test has the asymptotic null distribution . Since model3 has one additional parameter,The supplied output gives , and hence the boundary-corrected p-value is