Past exam of the mathematics course of the University of Cambridge 2004 iii Paper 37 2 i Solution Created 2026-10-03 Updated 2026-10-14
Treat the counts as independent binomial distributions, , conditional on the known numbers of operations. The null hypothesis is that the probabilities are all equal, with no assumed numerical value. Centre 4 has no operations in this period and hence contributes likelihood one, supplying no information about its mortality probability. The empty groups in a binomial homogeneity test principle leaves 11 contributing centres and 10 test degrees of freedom.
Under the common-probability model the maximum-likelihood estimator isUse the two-column contingency table of deaths and survivors, deleting its all-zero row. The Pearson chi-squared test of homogeneity has statisticUnder the null, the large-sample reference distribution is . The expected counts are adequate for this approximation here, including at the smallest nonempty centre. Calculating givesAn alternative is the likelihood-ratio test against separate centre probabilities, with binomial devianceThe unrestricted probabilities are ; subtracting one fitted common probability leaves the same 10 degrees of freedom. Here and . Thus there is strong evidence against a common mortality probability. This omnibus test does not identify Centre 1 as the sole source of the heterogeneity. If its comparison with the remaining centres is the primary scientific question, specify a separate planned one-versus-rest comparison; inspection of many pairwise comparisons calls for consideration of multiple testing.
Past exam of the mathematics course of the University of Cambridge 2005 iii Paper 41 4 Solution Created 2026-10-03 Updated 2026-10-14
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 isLet indicate some use and indicate predisposition. The additive logistic regression specifies . Its log-likelihood, including the binomial constants, isDifferentiation 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 areThese 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.
Past exam of the mathematics course of the University of Cambridge 2017 ii Paper 4 5J a Solution Created 2026-09-24 Updated 2026-10-05
This is the appropriate command for the full contingency table. It fits a log-linear model to the nine cell counts, with logarithmic link function and no interaction:With baseline constraints on , there are five parameters. The factorized means express independence of treatment group and damage category. The maximum-likelihood estimates areAlthough the experiment fixes each row total at 30, conditioning these independent Poisson random variables on those totals produces the appropriate row-wise multinomial distribution. The Poisson trick therefore gives the correct likelihood inference for this independence log-linear model for a two-way contingency table; the margins are nuisance parameters. It tests whether treatment changes the distribution of damage, rather than modelling a binary outcome.
Past exam of the mathematics course of the University of Cambridge 2017 ii Paper 4 5J d Solution Created 2026-09-24 Updated 2026-10-05
The count weights correct the loss of frequencies for a deliberately coarsened binary response, but do not supply a third outcome category. Thus this remains inappropriate for the full contingency table. With the base R factor convention, it could fit the chosen first damage level versus the other two combined, using a logistic regression and the frequencies as weights. That is a different scientific question. The supplied log-linear model retains all three categories and their counts without this information loss.
Past exam of the mathematics course of the University of Cambridge 2018 ii Paper 3 5J Solution Created 2026-09-24 Updated 2026-10-03
Treat the cell counts as independent Poisson random variables. Under independence of Month and Hospital, the independence log-linear model for a two-way contingency table iswith no Month–Hospital interaction. Compare its Poisson deviance with the appropriate upper quantile of a chi-squared distribution. This is the likelihood-ratio test of independence in a contingency table.
The approximation assumes independent counts with correctly specified Poisson means, identifiable parameters, and sufficiently large fitted cell means for the asymptotic chi-squared law to be accurate. Equivalently, one may condition on the margins and use the corresponding multinomial sampling formulation.
For the month table there are cells and independent model parameters, so the residual degrees of freedom areSincemodel 1 does not reject Month–Hospital independence at the level.
After combining months into four quarters, the table is , givingdegrees of freedom. Nowso model 2 rejects Quarter–Hospital independence at the level.
There is no contradiction. Relabelling twelve months as four quarters aggregates the contingency table, changes the null hypothesis, and reduces the degrees of freedom. The quarter-level hospital pattern is coherent enough to cross the much lower six-degree-of-freedom threshold even though the more detailed month-level omnibus test does not. This is an instance of how aggregation can change a contingency-table independence test.
For a two-way contingency table, Pearson's statistic isHere are the observed margins and their grand total. Under the independence null, its usual large-sample reference distribution has degrees of freedom for an -by- table.
For observed counts in an by contingency table, Pearson's chi-squared test statistic for independence isUnder the null model and the usual large-expected-count conditions, its reference distribution is with degrees of freedom.
One fossil-record study is Selectivity of end-Cretaceous marine bivalve extinctions by David Jablonski and others, which compared survival of marine bivalve genera across the end-Cretaceous mass extinction against their pre-event attributes. Geographically widespread genera had lower extinction intensity than narrowly distributed ones. In the same analysis, body size, burrowing versus exposed life position, and shelf bathymetric position were not significant selectors; the apparent feeding-mode contrast was concentrated in particular groups rather than establishing a universal feeding rule.[ref]
Selectivity of end-Cretaceous marine bivalve extinctions by David Jablonski and others. Science 268, pp. 389–391, abstract: tested traits, range result and qualifications to the feeding-mode result
The logic of the test is to define the pre-event genera at risk, classify their geographic ranges using pre-event occurrences, then compare the fractions becoming extinct. Using pre-event rather than surviving ranges avoids measuring the predictor after the outcome. A two-by-two contingency table gives an elementary broad/narrow-range comparison; a logistic regression can instead retain a continuous range measure and include correlated covariates. These are explanations of the inferential design, not a claim that this paper used that exact regression specification.
A persuasive interpretation must address unequal rock exposure, collecting intensity, taxonomic revision, incomplete occurrence records and the difference between local loss and global extinction. The important result is selective survival in a real fossil dataset and the failure of several plausible alternative predictors in that setting. It is observational evidence: geographic range can correlate with unmeasured ecological properties, so the association alone does not prove a unique kill mechanism.
Pearson chi-squared statistic for contingency tables Created 2026-10-06 Updated 2026-11-05
For observed counts and positive expected counts in a contingency table, the statistic is . Under common category probabilities or statistical independence, estimate by the product of the row and column totals divided by the grand total. With large expected counts, this gives the test statistic for the Pearson chi-squared test of homogeneity or the Pearson chi-squared test of independence, with asymptotic chi-squared distribution on degrees of freedom.
Official documentation for
stats::chisq.test. It distinguishes asymptotic chi-squared distribution calibration from Monte Carlo tests, and explains fixed-margin sampling for simulated contingency table tests. A finite simulation has limited p-value resolution. Somers' D 2026-10-25
Here count concordant pairs and discordant pairs, and counts pairs tied on response but not on predictor . Somers' D divides by the number of pairs with distinct values, including pairs that the predictor separates but the response ties. Thus it is directional and generally changes when predictor and response are interchanged. For an contingency table with row predictor totals , that denominator is . The double-counting convention for concordances and discordances cancels the factor two.[ref]
https://andrisignorell.github.io/DescTools/reference/SomersDelta.html. DescTools documentation, Details: column response given row predictor and the row-total denominator
For independent Poisson cell counts in stratified two-by-two contingency tables, the model allows both margins to vary by stratum but excludes within-stratum association. Its fitted means are the displayed products of margins, because the Poisson regression score equations match those margins. Every stratum's odds ratio is one. With positive nondegenerate margins, strata give parameters and residual degrees of freedom. A common association adds one parameter; stratum-specific associations saturate the tables.
Stuart's tau-c 2026-10-25
For an contingency table of two ordinal categorical variables, write , for the sample size and for concordant pairs and discordant pairs. The coefficient isIt provides an ordinal association measure whose normalization accounts for the table dimensions. It generally differs from Kendall's tau-b and Goodman and Kruskal's gamma on a table with tied pairs. An association sign presupposes the chosen category ordering and is not a causal direction. The eponym is associated with Alan Stuart.[ref]
Ordinal association measures in the DescTools documentation. StuartTauC, Details: formula, minimum table dimension and ordinal-data requirement
Tied pair (ordinal data) 2026-10-25
Two observations tied on a variable have equal recorded values of that variable. For observations of two ordinal categorical variables, distinguish pairs tied only on the first, only on the second, or on both. Goodman and Kruskal's gamma excludes all such pairs, whereas Somers' D retains ties on the response when measuring directional predictive association. Consequently these coefficients can differ markedly for the same contingency table.
Yates's correction for continuity Created 2026-10-14 Updated 2026-11-05
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.