For the Poisson variance function , the code computes the Pearson chi-squared statistic
and the Pearson dispersion estimator
The first quantity measures goodness of fit; the second estimates the dispersion parameter, which equals one in a correctly specified Poisson regression. A standard rough calculation substitutes the residual deviance for the Pearson statistic and gives
If the reported upper-tail probability is inverted numerically, the actual Pearson statistic used by the code is about , giving . Either calculation reveals severe overdispersion.
The quasi-Poisson standard errors are the Poisson standard errors multiplied by , and the Pearson estimator divides the Pearson chi-squared statistic by the residual degrees of freedom . Therefore the requested sum of squared Pearson residuals is
up to the rounding in the printed standard errors.
Fit the Poisson distribution using the estimated daily mean. For , its expected frequency is
and . Each row's contribution to the Pearson chi-squared statistic is . For example the zero-count class contributes . Summing the class contributions gives the test statistic; expected frequencies depend on the fitted model, while observed frequencies come directly from counting days.
A chi-squared test compares residuals with the random scatter predicted by a model. For independent measurements with known Gaussian standard deviations and predictions , form
If the mean model and error assumptions are correct, a full-rank linear fit of parameters gives a chi-squared distribution with statistical degrees of freedom. With a fully specified prediction and no fitted parameters, . Nonlinear fits usually make this an approximation. Independent external calibration is not the same as fitting a parameter to these test data.
Under the reference distribution, the mean statistic is and its variance is . The upper-tail p-value quantifies how unusual a discrepancy at least this large would be under the assumed model. A small value suggests model failure or incorrect uncertainties; it is not the probability that the model is true. An unusually small statistic can also reveal inflated uncertainties or correlations. A rejection threshold should be specified in advance.
For independent Poisson distribution counts, the model variance is its expected count . The Pearson chi-squared statistic is . The estimated-error alternative is common for large counts but can differ substantially when counts are small. In that regime the Poisson deviance or a direct likelihood calculation is preferable, with simulation if an accurately calibrated goodness-of-fit probability is required.
For a candidate attenuation coefficient, the one-second expected count is . The model predictions are
Use first the conservative signal-dominated range , where the count approximation is reliable and background is a small correction. Using the estimated errors from part (c), the weighted residual statistic is
It gives . Since both candidates are fixed and was calibrated independently, neither was fitted to these four counts: the approximate reference has , not three. The upper-tail probabilities are approximately and , respectively. Thus is compatible with the scatter, whereas is disfavored at the usual level in this approximate test.
A Pearson chi-squared statistic, using model variances instead of estimated observed variances, gives the same preference:
Including the fifth point also leaves the decision unchanged: the estimated-error statistics are and on five degrees of freedom, with approximate upper-tail probabilities and ; the Pearson statistics are and . Hence
The small uncertainty in contributes correlated prediction uncertainty, as in chi-squared comparison of a calibrated attenuation model, but is negligible compared with the one-second counting errors here. Choosing the test range after inspecting the observations limits a strict interpretation of its nominal significance; the numerical comparison and its stated range are the relevant evidence.
If all eight observations are inserted into the estimated-error formula, the totals are and . Their nominal eight-degree-of-freedom calibration is unreliable because the final expected counts are much smaller than one for some predictions. In fact the full-range Pearson statistics are and , exposing the late excess much more strongly. The full Poisson deviance values are and , again favoring but signaling that a background-free exponential is inadequate over the complete range. These sparse-count comparisons should not be used to claim that either unmodified model explains all eight measurements.
For independent Poisson random variables with known expected counts , the model variance is . The Pearson chi-squared statistic is therefore
There are six independently specified bins and no parameters fitted from them, giving approximately six degrees of freedom. This is far above its expected value six; the approximate chi-squared distribution tail probability is . The discrepancies are much too large for a good Poisson-noise fit. Replacing model variances by the observed-count estimates gives the alternative statistic , with the same qualitative conclusion. There is no fitted normalization to justify subtracting a degree of freedom or rescaling the model to the observed total.
Let be the observed cell counts, the row totals, the column totals and . The fitted expected frequencies under independence are . For example the three-child, one-boy cell has expected count .
The Pearson chi-squared statistic is
Under it has asymptotically a chi-squared distribution with degrees of freedom, assuming the multinomial sampling model and sufficiently large expected counts. All expected counts here are large. The distribution is an asymptotic approximation, rather than an exact finite-sample identity.
Write . For small, the cell contribution to the Poisson deviance expands as
Summing gives the Pearson chi-squared statistic as the quadratic approximation. The approximation can be inaccurate for sparse expected counts or cells with relative residuals near minus one.
Yates's correction for continuity Created 2026-10-14 Updated 2026-10-25
For a two-by-two contingency table, subtracting one half from each absolute observed-minus-expected count difference, with truncation at zero, gives the displayed corrected Pearson chi-squared statistic. Expected counts use the independence model . The subtraction compensates approximately for using a continuous chi-squared distribution for discrete counts. It can make the test conservative. The corrected statistic should be distinguished from the ordinary uncorrected Pearson chi-squared statistic.