For independent groups each containing independent Bernoulli trials with common probability , the group count has a binomial distribution. If groups have count , the maximum-likelihood estimate is . Form the Pearson chi-squared statistic using . With all categories retained, an interior true parameter, and sufficiently large expected counts, its null limit is a chi-squared distribution with statistical degrees of freedom: one degree is removed by the fixed total and another by fitting . Small expected counts require care with this approximation. If categories are pooled, the fitted parameter and calibration should correspond to the pooled statistical model; simply pooling a statistic after fitting the unpooled model does not automatically give the usual chi-squared limit.
Suppose is independently calibrated and counts have predicted means under a specified candidate . For independent sufficiently large Poisson counts, the Pearson chi-squared statistic is . With no parameters fitted to these test counts, its approximate reference chi-squared distribution has one degree of freedom per observation. Fitting a continuous to the same data instead removes one residual degree of freedom. Replacing the denominators by observed counts is a common estimated-error approximation but can behave badly at small counts.
Calibration uncertainty also induces correlated prediction errors. First-order propagation of uncertainty gives
A generalized quadratic form uses this covariance matrix. For sparse counts use the Poisson deviance or the full count likelihood, with simulation if a calibrated goodness-of-fit probability is required. Choosing a range after inspecting residuals also affects formal test calibration; a physically specified signal-dominated range is preferable when applying a pure attenuation model.
Contingency coefficient 2026-10-25
The contingency coefficient transforms the Pearson chi-squared statistic as . It is an unsigned measure of statistical association, not a p-value or a direction of an ordinal relationship. Writing gives . Unlike Cramér's V, its attainable maximum depends on table dimensions, so comparisons between differently sized tables need care.
Cramér's V 2026-10-25
For an contingency table with observations and positive row and column totals, Cramér's V rescales the Pearson chi-squared statistic to a dimensionless measure of statistical association. It lies between zero and one and is unchanged by reordering category labels. It therefore describes the magnitude of dependence, without an ordinal direction. A small p-value can accompany a small in a large sample: evidence against independence and the magnitude of the departure answer different questions. The displayed quantity is the usual uncorrected sample measure.
Consider independent binomial counts under the common-probability null hypothesis, with fixed positive row sizes . Let , and assume . Conditional on , the probability mass function is the displayed multivariate hypergeometric distribution: in the joint likelihood, the factor is common to all admissible tables and cancels. The Vandermonde identity gives the denominator, so the conditional distribution is free of the unknown nuisance parameter .
For a table , its Pearson chi-squared statistic is
An exact conditional p-value sums the displayed probabilities over all tables with the same margins and . The ordering is by the Pearson chi-squared statistic, rather than by the probability of an individual table; different exact-test orderings can give different answers. Enumeration is practical when and the number of rows are small. Monte Carlo tests can approximate the same tail by sampling tables with fixed margins.[ref]
An exact arithmetic comparison is easy too. Let be the least common multiple of the row sizes. Compare the integer
since every table has the same positive denominator . This includes boundary ties without a floating-point tolerance. Conditional p-values are discrete and can be conservative; “exact” concerns their null calibration, not equality of rejection probability with every chosen significance level.
For a contingency table with Pearson chi-squared statistic and sample size , the nonnegative magnitude is sometimes reported as generalized phi. It does not encode an ordinal direction. In a two-row or two-column table it coincides with Cramér's V; in larger tables it can exceed one, so the normalization in Cramér's V matters. In a two-by-two table it is the absolute value of the Pearson correlation coefficient of binary category indicators; a signed binary phi requires a stated coding convention.
For independent strata, each containing an contingency table, test independence of the two table variables within every stratum. Under adequate expected counts and the usual multinomial distribution sampling assumptions, each stratum's Pearson chi-squared statistic has asymptotic chi-squared distribution with statistical degrees of freedom. Their sum has asymptotic chi-squared distribution with statistical degrees of freedom, by the additivity of independent chi-squared distributions. This is a test of conditional independence, not of equality of a common effect across strata; the latter needs an interaction contrast or another specified homogeneity test.
There are descriptive ethnic differences in the distribution of technology distrust, but the omnibus evidence is borderline and the unsigned association is small. The printed Pearson test just rejects independence at 5%, while the likelihood-ratio test does not; neither establishes a strong ethnic pattern or a causal effect.
Read the body percentages within each ethnic group. Strong disagreement with the distrust statement occurs among 24.68% of Asian respondents, 10.53% of Black respondents and 13.34% of White respondents. Agreement occurs among 27.27%, 21.05% and 29.37%, respectively. Neutral responses are 20.78%, 26.32% and 19.68%. Thus Asian respondents are especially likely to be in the strongly-disagree category, while Black respondents have the largest neutral share. The mode for Black and White respondents is Disagree; Asian respondents have a tie between Disagree and Agree at 21 observations each. The small group totals, 77 and 57, mean that a few observations can materially change the minority-group percentages.
The Pearson chi-squared test of independence has , statistical degrees of freedom and . Under its sampling assumptions, this is a nominal rejection at a prespecified 5% significance level, but not at 1%. The minimum expected frequency is about 7.766, so this particular table has no expected cell below five. The alternative likelihood-ratio test of independence in a contingency table gives and , printed as 0.074. These are different test statistics, not contradictory versions of the same calculation. Their different threshold decisions show that the evidence is close enough to the conventional boundary to warrant qualification rather than selection of the more favourable label.
The generalized phi coefficient is about 0.071, the contingency coefficient about 0.071 and Cramér's V about 0.051. They indicate a small overall unsigned association. This does not erase the particular descriptive percentage differences, and a small p-value is not a measure of their substantive size. Conversely, failure of the likelihood-ratio test to reject at 5% is not evidence that every ethnic group has exactly the same population response distribution.
Ethnicity is a nominal categorical variable, with no natural rank Asian–Black–White. Therefore the printed Goodman and Kruskal's gamma of 0.079, Somers' D of 0.058, Kendall's tau-b of 0.022 and Stuart's tau-c of 0.009 have no invariant substantive ordinal interpretation here. Permuting the ethnicity labels can change the ordinal pair comparisons without changing the underlying observations or their nominal association. These values are not evidence for an ethnic hierarchy; Cramér's V and the actual within-group percentages are appropriate summaries for this question.[ref]
Both directional values of Goodman and Kruskal's lambda are zero. Knowing ethnicity does not improve the number of correct modal predictions of technology response: Disagree remains a modal category within every ethnic group, including the Asian tie. In the reverse direction, White is the most frequent ethnicity within every technology-response column, so knowing technology does not improve modal ethnicity predictions either. Zero lambda therefore coexists with unequal conditional distributions and a nonzero Pearson chi-squared statistic; modal prediction discards changes that do not change the most frequent category. The supported conclusion is a small, weakly evidenced nominal association, with its descriptive pattern and uncertainty stated explicitly.
Within the 1424 complete records displayed here, employed respondents report more frequent use on average in the ordinal sense of positive pairwise association. The overall independence test is significant, but its sample association magnitude is modest and the result is observational. Some printed ordinal summaries are internally inconsistent.
Compare row percentages because employment groups have different sizes. Never-use is reported by of the non-employed group and of the employed group. Daily use is versus ; more-than-daily use is versus . Combining the last two categories gives versus , an employed-minus-non-employed difference of about 11.26 percentage points. That threshold comparison is a descriptive summary of the six-category table, not a replacement for the original omnibus test or a newly declared prespecified endpoint. It does not assign equal spacing to the six frequency categories.
Here the row counts, column counts and grand total are additive. Under the null hypothesis of employment–use independence, a contingency table has statistical degrees of freedom. The Pearson chi-squared statistic recomputed from the cells is , agreeing with the printed value, and its p-value is about . The likelihood-ratio test statistic gives . Both reject independence at the conventional 5% and 1% significance levels under the sampling assumptions. The minimum expected frequency, about , gives no sparse-cell warning for this table. The tests compare whole category distributions; they do not by themselves identify one category as the source of the association or establish its causal direction.
Cramér's V is . The generalized phi coefficient coincides with it for this two-row table, while the contingency coefficient is about . These are modest magnitudes; a small p-value does not make the relationship large or useful for individual prediction. The employment–use association could change after conditioning on age or other covariates, and the sample excludes cases without recorded use. Relative to the employment margins in Figure 1, the omitted complete-case counts are non-employed and employed, or about and of those groups. Different missing fractions alone do not identify the missing-data mechanism, but they rule out treating complete records as automatically representative of everyone.
The count-based Goodman and Kruskal's gamma is
With the employment categories ordered non-employed then employed and use ordered from never to more than daily, this positive value means concordant pairs outnumber discordant pairs among pairs untied on both variables. It is not a 16.9% increase in a person's use and is not a causal effect. Reversing one ordering reverses its sign. Excluding ties can make gamma appreciably larger than tie-adjusted measures.
For use as response and employment as predictor, the cells give Somers' D about , Kendall's tau-b about and Stuart's tau-c about . The printed Somers value and tau-b should not be presented as verified calculations: the table prints second-variable-only ties, whereas its cells give . The other four pair classes agree with the cells; the printed five classes sum to , not . The source does not establish an alternative tie convention that repairs those ordinary identities. The direction remains a weak positive association under either description, but the exact measures require coherent pair counts.
Modal prediction provides another perspective. Without employment information, predicting the globally most frequent use category, never, makes errors. Predicting a separate modal use category in each employment group makes errors. Thus Goodman and Kruskal's lambda for use given employment is : about a 1.97% reduction in modal-classification errors. For employment given use the corresponding reduction is . These identify the targets explicitly; the source's row-dependent/column-dependent labels should not be used to reverse the target interpretation. The two small numbers show why an independence test can be significant while coarse modal prediction improves very little. The supported overall finding is a modest positive association among observed respondents, requiring conditional analysis and a missing-data qualification before broader claims.
The displayed percentages use row denominators. The relevant comparison is therefore the conditional probability of each response within each recorded gender group, rather than the gender composition within a response category.
For the male group, strongly agree and agree. For the female group, the corresponding percentages are and . Combining the two agreement categories gives
The female group has more neutral responses, versus , and a higher combined disagreement percentage, versus . Thus the observed distributions differ in more than a single cell.
The Pearson chi-squared test assesses the null hypothesis of independence in the complete contingency table. Under that null, the expected frequency in a cell is its row total times its column total divided by 2,135. Recalculation gives
The reported p-value, approximately , gives very strong evidence against independence under the test's sampling assumptions. The minimum expected frequency is about , so sparse expected cells are not a problem here. The test concerns the full five-category distribution, not just the combined agreement comparison.
Cramér's V summarizes the magnitude without imposing an ordering on the gender labels:
The small p-value does not imply a nearly deterministic relationship. For example, the column-dependent Goodman and Kruskal's lambda is only about : choosing the modal response separately within the two groups reduces prediction errors from 1,546 to 1,506, a relative reduction of .
The positive Goodman and Kruskal's gamma must be interpreted using the table's chosen ordering. The agreement categories run toward less willingness, and gender has no intrinsic ordinal direction. A sign attached to an arbitrary group coding cannot replace the substantive comparison of conditional probabilities.
The NaN displayed for the likelihood-ratio calculation is not a valid p-value and is not evidence of no association. The Pearson chi-squared statistic can be independently recomputed from the positive cell counts. None of these calculations identifies a causal effect; the table has not controlled for income or other possible confounders.
For each income band, compare the response distribution within the two gender groups. The table below combines agree and strongly agree only to make one comparable contrast visible. The Pearson chi-squared statistic and its p-value still use all five original response categories, with four statistical degrees of freedom in every band. Income labels are thousands of USD per year; finite upper bounds are excluded.
Income bandMale agreementFemale agreementDifference in percentage pointsCramér's V
Under 10k11738.64%34.25%4.393.4330.48810.171
10k–20k21235.90%35.07%0.825.4570.24350.160
20k–30k24552.17%39.22%12.965.8930.20730.155
30k–40k27854.90%37.50%17.4010.1170.038510.191
40k–50k17854.74%38.55%16.186.6870.15340.194
50k and above110571.16%50.21%20.9563.7650.240
In the lowest-income band, combined agreement differs by only about percentage points. The full distributions still differ descriptively: strong disagreement is in the male group and in the female group. The omnibus Pearson chi-squared test does not reject independence at 5%, but that decision does not prove equal distributions.
In the 10k–20k band, combined agreement is almost the same. Nevertheless, strong agreement is higher in the female group, versus , while the less intense agreement category is higher in the male group, versus . Collapsing the categories hides that distinction. The full-distribution p-value is approximately .
In the 20k–30k band, combined agreement is higher in the male group by about percentage points. Strong agreement alone is versus . The observed difference is therefore larger than in the two lowest bands, despite its full-table p-value remaining above 5%.
In the 30k–40k band, combined agreement differs by about percentage points, with fewer male neutral responses, versus . The full-table p-value of is nominally significant at 5%. In the 40k–50k band, the combined agreement gap is a similar percentage points, but the full-table p-value is . These labels are not a direct comparison between the two effects: significant and nonsignificant results need not differ significantly.
In the highest-income band, strong agreement is in the male group and in the female group. Combined agreement differs by about percentage points. This band has both the largest sample size and the largest Cramér's V of the six tables, with a very small p-value. Its particularly strong evidence reflects both precision and an observed difference in the distribution.
All six minimum expected frequencies exceed five: approximately , , , , and . Thus sparse expected counts do not provide a reason to reject the usual chi-squared distribution approximation here. If the six hypothesis tests form one exploratory family, a Bonferroni correction would use for each test; only the highest-income result crosses that threshold. This qualifies the unadjusted 30k–40k result without turning its observed contrast into zero.
In the elaboration model, the larger agreement gaps in the middle and upper bands provide a descriptive pattern of specification: the conditional contrast varies with income. This is not a Simpson's paradox reversal, because the combined agreement difference has the same sign in every band. Nor is the larger high-income effect size established simply by comparing its p-value with the other p-values. A formal claim of effect modification requires a stated scale and an appropriate comparison of the effects.
The pooled comparison also mixes different income compositions. The highest-income band contains of the male group but of the female group. Average each group's six agreement proportions over the same pooled income weights using standardization with common weights. This gives
The crude difference was percentage points, so common weighting attenuates it by about percentage points but leaves a substantial descriptive contrast. With average-group rather than pooled-person weights, the symmetric decomposition of a stratified mean difference instead gives an exact split into approximately percentage points from conditional contrasts and percentage points from composition. These are different explicitly defined descriptive summaries, not estimates of a causally mediated share.
Figure 1. . Original calculations from the printed aggregate counts. The outcome combines agree and strongly agree; the two gender labels are those recorded in the paper. Error bars are individual approximate 95% Wilson intervals, not simultaneous intervals or a formal test of between-band effect modification. The right panel uses the same pooled income frequencies for both groups. No individual observations were reconstructed. Details.
An antecedent income variable could be considered in a confounding explanation, whereas an income variable on an assumed causal pathway would enter an interpretation through causal mediation. The conditional tables do not distinguish these causal structures. They also do not identify whether any adjustment introduces collider bias. The supported conclusion is income-dependent descriptive association plus a measurable composition difference, with causal interpretation left conditional on additional assumptions.
These are row percentages, so the comparisons estimate the conditional probability of recorded vaccination within each NHS trust category. The percentages increase across the ordered trust categories as
The extreme-category difference is approximately 49.31 percentage points, rather than a 49.31% relative increase. The ordinal categorical variable records an order; the categories do not establish equal numerical trust increments.
Under the null hypothesis of independence, the expected count in a cell is its row total times its column total divided by 748. The Pearson chi-squared statistic compares observed and expected counts through
There are statistical degrees of freedom, giving . The minimum expected count is approximately 5.015, so the usual expected-count concern is much less acute here than in the income strata. The table gives strong evidence of a statistical association. The likelihood-ratio test of independence in a contingency table agrees: its statistic is approximately 81.361 on four statistical degrees of freedom, with a very small p-value. The displayed 0.000 is rounding, not a zero probability.
For magnitude, Cramér's V is
It describes the size of the departure from independence without using the category order or giving a direction. Calling it “moderate” is only a rough contextual description; the actual percentage differences are easier to interpret.
The ordered coefficients describe a positive direction. Goodman and Kruskal's gamma uses only concordant pairs and discordant pairs:
It excludes tied pairs, which are frequent when the response has only two categories. It is therefore not a claim that 54.7% of respondents were vaccinated because of their trust. The directional Somers' D for vaccination as response includes pairs tied on that response in its denominator:
The smaller value reflects the retained ties; it does not contradict the positive statistical association.
The small column-dependent Goodman and Kruskal's lambda has a useful prediction interpretation. Without trust information, always predicting the more frequent vaccinated category gives 121 mistakes. Predicting the majority category separately in each trust row gives mistakes. Hence
Trust reduces this particular modal-prediction error by only about 4.13%, despite the strong evidence against independence. Most rows retain the same majority category. Evidence of association, its ordinal direction and improvement in a chosen prediction rule are different questions. None establishes that changing trust would change an individual's vaccination status.
The association remains positive within each income group, although its estimated size is smaller in the higher-income groups. The two extreme trust categories give the following conditional vaccination percentages and differences:
Annual household incomeLowest trustHighest trustDifference in percentage points
Below £20,00036.36%89.60%53.24
£20,000–£40,00050.00%93.10%43.10
£40,000 and above66.67%91.14%24.47
In the lowest-income group, the intervening percentages are 42.86%, 44.12% and 82.54%, so the increase is monotone. Its Pearson chi-squared statistic is approximately 62.520 on four statistical degrees of freedom, with the printed asymptotic . Cramér's V is approximately 0.441, Goodman and Kruskal's gamma is approximately 0.626 and the column-dependent Somers' D is approximately 0.259. The column-dependent Goodman and Kruskal's lambda is approximately 0.158: trust improves the modal prediction more here than in the pooled table.
In the middle-income group, the intervening vaccination percentages are 61.54%, 81.82% and 92.04%. The printed Pearson chi-squared statistic is approximately 24.033 on four statistical degrees of freedom, with asymptotic . Cramér's V is approximately 0.298, Goodman and Kruskal's gamma approximately 0.454 and column-dependent Somers' D approximately 0.100. Column-dependent Goodman and Kruskal's lambda is zero: vaccinated respondents are the majority in every row, so the modal prediction never changes. A zero lambda does not mean independence.
In the highest-income group, the intermediate vaccination percentages are 71.43%, 76.92% and 94.55%; the final category falls slightly to 91.14%. Thus the observed pattern is broadly positive rather than strictly monotone. The printed Pearson chi-squared statistic is approximately 8.199 on four statistical degrees of freedom, with asymptotic . It does not reject independence at 5%. The corresponding Cramér's V is approximately 0.229, Goodman and Kruskal's gamma approximately 0.281 and column-dependent Somers' D approximately 0.058. The column-dependent Goodman and Kruskal's lambda is again zero.
Small counts limit the asymptotic tests, especially in the middle- and highest-income tables. Their minimum expected counts are approximately 0.644 and 0.306, with respectively 30% and 40% of cells below five. The lowest-income table has one expected count below five, with minimum approximately 3.315. These diagnostics concern expected counts under independence, not just the observed row sizes.
The supplied counts are sufficient to make an exact conditional Pearson test for a binary contingency table, without needing individual records or assuming a chi-squared distribution approximation. Conditioning on the row totals and total unvaccinated count removes the common unknown binomial probability. For each admissible table, sum its multivariate hypergeometric distribution probability when its Pearson chi-squared statistic is at least the observed one. Complete enumeration gives:
Income groupEnumerated tablesExact conditional p-value
Lowest507150
Middle22379
Highest2585
These are new exact conditional calculations, rather than the paper's printed asymptotic p-values. They confirm evidence of association in the first two groups and nonrejection at 5% in the third, while showing the numerical effect of sparse cells. The tail is ordered by the Pearson chi-squared statistic; an exact test with a different ordering need not have the same p-value. Fixed-margin Monte Carlo tests approximate this same Pearson-ordered tail when enumeration is impractical.[ref]
The original count-based figure below includes pointwise approximate 95% Wilson intervals. The very wide intervals for sparsely populated trust categories make the uncertainty visible; they are not simultaneous intervals or a formal test of differences between income groups.
Figure 1.
Recorded vaccination by NHS trust within household-income groups, with pointwise Wilson intervals
. Original plot from the supplied table counts. Connected categories show their order without assuming equal numerical trust increments. The intervals concern conditional proportions, and the figure does not identify causal effects. Details.
In the elaboration model, the positive direction is replicated after conditioning on income: income does not fully explain away the observed trust–vaccination relationship. The decreasing estimated contrasts and ordered coefficients suggest possible specification by income, or effect modification on an explicitly chosen scale. They do not establish it. Different p-values can arise from different sample sizes and standard errors; significant and nonsignificant results need not differ significantly. A formal statistical interaction test or a confidence interval for differences between comparable contrasts would address that question.[ref]
Nor do these conditional tables prove that income is a causal confounder or causal mediator. Those labels require assumptions about causal order, relevant confounding and how variables were measured. This is an observational study of recorded vaccination status, not a randomized change in trust or a test of vaccine effectiveness.
Each row of the contingency table is a conditional distribution of the safety category among respondents with that experience status. Thus the relevant comparison uses row percentages, rather than interpreting the larger number of respondents with some bad experiences as itself an effect on safety.
The sample proportions reporting feeling very safe are without bad experiences and with some bad experiences: the latter is lower by about percentage points. Feeling fairly safe rises from to , a difference of about percentage points. Feeling unsafe changes only from to , about percentage points. The main descriptive shift is therefore from very safe toward fairly safe, rather than a large increase in the unsafe category.
Pearson's chi-squared test tests the null hypothesis that experience status and safety category are independent. If that were true, the expected cell count would be its row total times column total divided by . The Pearson chi-squared statistic sums squared observed-minus-expected count differences divided by their expected counts. Here
The expected counts are comfortably large, with minimum approximately , so the ordinary large-sample chi-squared distribution approximation is appropriate under the sampling assumptions. There is evidence against independence even at the significance level. The reported likelihood-ratio result gives the same conclusion.
Magnitude is a separate question. Cramér's V gives
which describes a weak statistical association. It does not mean that of safety is explained. Nor does the p-value measure the size of that association.
For ordinal direction, order the experience categories as none, some, and the safety categories from very safe toward unsafe. Goodman and Kruskal's gamma compares concordant pairs with discordant pairs after excluding tied pairs:
Its small positive sign then corresponds to a weak tendency toward less safety among respondents with bad experiences. The sign would reverse if exactly one category ordering were reversed. Because this contingency table has many ties, the response-direction Somers' D, which retains response ties among pairs with different predictor values, is smaller:
These coefficients describe ordered association; the omnibus Pearson's chi-squared test tests any departure from independence and does not supply a separate p-value for gamma.
The column-dependent Goodman and Kruskal's lambda makes the weak predictive improvement tangible. Predicting the overall most frequent safety category makes errors in this table. Using a separate most frequent category within each experience row makes , giving , only about a reduction in those classification errors.
The sample supports a statistically detectable but weak association, chiefly a reduced sample proportion feeling very safe. This observational study does not establish that bad experiences cause the change: reverse direction, reporting differences or confounding could also contribute. The numerical p-value also presumes the sampling and complete-case assumptions appropriate to the observations used.
For independent Poisson counts, the log-likelihood at mean vector is
The saturated model maximizes each cell separately at , including the boundary value zero. If is the fitted mean under the log-linear regression, twice the saturated-minus-fitted log-likelihood is the full Poisson deviance
with understood by continuity. The fitted intercept has score function , since differentiating the logarithmic mean with respect to that intercept gives one. Its maximum-likelihood equation therefore gives . This is why Poisson deviance simplifies when an intercept is fitted:
Without the fitted unpenalized intercept, one cannot generally discard the two linear terms. The individual logarithmic terms in the simplified sum need not each be positive; nonnegativity belongs to the full deviance, or to the full cell contributions before cancellation.
For the approximation, write and expand . When relative residuals are small,
Consequently the quadratic Pearson approximation to the Poisson deviance is
the Pearson chi-squared statistic for unit Poisson dispersion. Adequate expected counts and small relative residuals are what make the quadratic approximation useful; it is not an exact identity and can be poor for sparse cells, especially a zero count with positive fitted mean. Any further chi-squared goodness-of-fit reference needs its own large-count regularity assumptions.
read.table(...,header=T) reads four grouped rows with column names. The displayed outcome counts give the observed risks in the indicated factor order. rbind in the first test pools over predisposition: the two rows represent no cannabis use and some use, with event/non-event counts and . Thus the pooled risks are and . This test concerns the marginal statistical association between use and outcome, not an association adjusted for predisposition.
Under independence, expected counts in the two-by-two contingency table are . The ordinary Pearson chi-squared statistic is . The printed is reproduced by the default two-by-two Yates continuity correction:
All absolute differences here exceed one half. Comparison with a chi-squared distribution on one statistical degree of freedom gives . There is strong evidence of marginal association. The simplified output omits the usual continuity-correction wording, but its numerical value shows which statistic was used.
attach makes the data columns available by name, and tot=with+without obtains group sizes . The grouped binomial regression fits , with response and prior weights . These weights tell R the binomial denominator; treating the four proportions as four equally precise individual observations would be wrong. The default logit link is
Let indicate some use and indicate predisposition. The additive logistic regression specifies . Its log-likelihood, including the binomial constants, is
Differentiation gives score equations and Fisher information matrix , where . Fisher scoring solves these equations, and the inverse fitted Fisher information matrix gives the reported approximate coefficient variances. The number of scoring iterations records numerical convergence, not degrees of freedom or statistical evidence.
The intercept corresponds to no use and no predisposition and gives baseline fitted risk . The additive coefficients imply common adjusted odds ratios:
They multiply the odds, not the risks. The Wald tests divide the estimates by their standard errors and use a standard normal distribution; both predictors have small two-sided p-values. Approximate confidence intervals for these odds ratios are and , obtained by exponentiating the log-scale intervals. The intercept test against zero asks whether the reference risk equals one half, and is not a test of either exposure association. The binomial dispersion is assumed to be one because ; the output does not demonstrate independence or rule out extra-binomial variation.
There are four grouped probabilities and three fitted coefficients, leaving one residual degree of freedom. The fitted risks are approximately . The binomial deviance compares this fit with the four unrestricted observed proportions:
The deviance goodness-of-fit test against has p-value . The common-odds-ratio fit is not rejected at , although the doubly exposed group's observed risk exceeds its fitted risk appreciably and suggests possible interaction.
The second formula adds . Its four coefficients fit all four probabilities, making a saturated statistical model with zero grouped residual degrees of freedom. The near-zero deviance is roundoff from exact interpolation; it supplies no remaining grouped lack-of-fit test. Unlike Q1's unreplicated Gaussian fit, however, these grouped responses represent many independent Bernoulli trials, and their binomial variances are specified by their sizes and probabilities. Coefficient standard errors remain available from binomial information without estimating dispersion from the zero residual degrees of freedom.
Indeed, let be the fitted cell logit link value. The saturated coefficients are
These calculations yield the printed estimates. The delta method gives , and independent groups make the variance of the sum of all eight reciprocal counts. Its square root is , reproducing the printed standard error.
The saturated logistic regression describes the conditional odds ratios as follows:
Thus the main coefficients now concern effects at the other factor's reference level. Logistic interaction as a ratio of odds ratios gives , with approximate confidence interval . The interaction Wald test has , while the nested likelihood-ratio test uses deviance difference on one statistical degree of freedom and has . The data suggest a larger odds association in predisposed subjects, but do not establish this interaction at the conventional level. This conclusion is specific to the odds scale; absolute-risk differences can vary even with no logit-scale interaction.
The Akaike information criterion is . The additive fit has and AIC ; the interaction fit has and AIC . The extra coefficient improves twice the log-likelihood by but incurs penalty , so AIC falls by only . It weakly favors the larger fit rather than decisively establishing an interaction, and AIC is not a p-value.
The marginal odds ratio and the fitted conditional odds ratios are different quantities. Predisposition is associated with both use frequency and outcome, so confounding is a substantive possibility; noncollapsibility of the odds ratio also means marginal and conditional odds ratios need not agree. This is an observational association analysis with only one adjustment factor. It does not by itself establish a causal effect, exclude other confounding, or validate the assumed independent binomial sampling.
Let denote the maximized log-likelihood in the saturated model, with one fitted mean per observation. With known dispersion, define the deviance of a fitted model as ; for an exponential-dispersion convention that scales deviance by the dispersion , divide that scaled quantity by in the following test.
Let be the fitted deviances under the null and full models. Their difference is the likelihood-ratio test statistic
Under the regular identifiable interior null hypothesis, Wilks theorem gives the limiting distribution. Reject for an observed difference above its chosen upper-tail critical value. This concerns the difference of fitted model deviances, not simply the full-model deviance compared with zero.
For a Poisson regression, the means are and . Saturation sets , taking the limiting value at . Consequently the Poisson deviance is
with . The intercept score implies at a finite fit, although retaining that term makes the individual deviance contributions clear.
For with small, expand . The linear term cancels and the result is . Therefore
the Pearson chi-squared statistic. The approximation requires adequately large fitted counts and small relative residuals; it is not an identity for sparse observations.
Assuming independent digits under Benford law, put and . The count vector has a multinomial distribution, with expected counts . Suitable predictive discrepancy statistics include the Pearson chi-squared statistic and multinomial deviance:
The zero-count terms of have limiting value zero. A Monte Carlo method gives a direct null comparison even when expected counts are small.
For example, an original R implementation is:
benford_check <- function(y, B = 9999L) {
  p <- log10(1 + 1/(1:9))
  n <- sum(y)
  expected <- n*p
  observed <- sum((y - expected)^2/expected)
  replicas <- rmultinom(B, size = n, prob = p)
  simulated <- colSums((replicas - expected)^2/expected)
  (1 + sum(simulated >= observed))/(B + 1)
}
Each column returned by rmultinom is a replicated count vector. R recycles the nine expected counts down each column. The add-one ratio is a Monte Carlo test estimate. In WinBUGS, alternatively generate a replicated dmulti vector using fixed , compute its discrepancy and monitor exceedance of the observed value. The null does not estimate unknown digit probabilities. Dependence or selection in the accounts would require an appropriate simulation model.
For observed proportions and fitted proportions , the binomial deviance is
A second-order Taylor expansion around gives
the generalized Pearson chi-squared statistic. Under the fitted binomial model this is approximately . The observed deviance is , whose upper-tail probability is about . Since this exceeds , there is no significant evidence of overdispersion.
The researcher computed the Pearson chi-squared statistic
and compared it with a distribution, using residual degrees of freedom. Under an adequate large-sample Poisson regression, should be roughly the residual degrees of freedom. The reported tail probability rounds numerically to zero and gives strong evidence of overdispersion.
Possible causes include unobserved heterogeneity or omitted covariates, dependence among respondents, excess zeros, or an incorrect mean function. The conclusion that the Poisson variance assumption fails is well supported, although this test alone does not identify the cause or establish that the Quasi-Poisson regression variance is correct.
The reported Pearson dispersion estimator is , so
up to rounding.