Paired binary sample size calculation 2026-10-14
For a paired binary difference , set and . Then and . Under equal marginal probabilities the variance is . The McNemar test has approximate upper rejection boundary for the sum of differences. Requiring that the alternative mean exceed this boundary by gives the displayed planning size for a positive alternative, neglecting its very small lower-tail rejection probability. Use for a pre-specified one-sided test. The marginal probabilities alone do not determine : co-occurrence of positive outcomes must be specified or bounded. Discreteness and clustered data can change achieved statistical power.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 34 1 b Solution Created 2026-10-03 Updated 2026-10-14
Zero observed events do not mean that the underlying event probability cannot be estimated. For independent observations having a common Bernoulli distribution, the binomial likelihood with no events is , maximized at . A zero-event binomial upper confidence bound shows the remaining uncertainty: the one-sided 95% upper bound solves , givingThus the point estimate is zero, but a nonzero mortality risk is compatible with the observations. This bound is an illustration under independent equal-risk sampling; clustered data or unequal risks require their own uncertainty calculation.
The empirical unadjusted odds ratio is also defined:Its log odds ratio is , so the ordinary normal approximation for a log-odds confidence interval is unavailable. Exact likelihood-based limits can still describe uncertainty; a specified continuity correction would instead yield a finite, method-dependent point estimate.
In an unpenalized logistic regression with a separate coefficient for elective exposure, every exposed death outcome is zero. Decreasing that coefficient toward increases the exposed observations' likelihood contributions and leaves the reference observations unchanged. This is quasi-complete separation: there is no finite ordinary maximum-likelihood estimate of the exposure coefficient, even after adding background predictors. It is reasonable to say that the usual finite adjusted coefficient could not be fitted; it is too strong to say that no risk estimate or statistical information is possible. A specified penalized likelihood or Bayesian inference with proper coefficient priors can provide a finite adjusted estimate, whose dependence on the regularization must be reported.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 34 1 i Solution Created 2026-10-03 Updated 2026-10-14
A reversal this large calls for an audit, but the aggregate table cannot identify a particular error. Check the outcome and exposure coding, the reference category, the subset used in each analysis, missing-data exclusions, denominators, weights, and whether the reported coefficient actually corresponds to the intended comparison. Reversing an exposure contrast or exponentiating the wrong fitted coefficient would change the reported odds ratio. Conditioning on variables affected by delivery, or including inappropriate interactions, could also change the causal inference rather than merely improve precision.
Start by reproducing the crude odds ratio from an independent two-by-two calculation. Then fit progressively adjusted logistic regressions, recording how the coefficient and analysis population change; inspect within-clinic comparisons, sparse cells and separation. For an ordinary likelihood fit, check the fitted expected event count against the observed count and verify that changing only to cluster-robust standard errors leaves the fitted coefficients unchanged. A sandwich covariance matrix corrects uncertainty for clustered data; it does not by itself turn a crude odds ratio below one into an adjusted odds ratio above one. Adding clinic effects, using weights or changing the model can change the point estimate and must be distinguished from that variance correction.
Programming or reporting error is a possibility to check, not a conclusion proved by the reversal. Strong legitimate confounding remains another explanation.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 34 2 a Solution Created 2026-10-03 Updated 2026-10-14
Use a concurrent comparison: test the same specimens for both cocaine and mephedrone, rather than treating the historical cocaine percentage as an exactly known 2010 parameter. Assume representative sampling of privates, effectively independent specimens, stable underlying rates during the sampling period, and sufficiently accurate assays. I use a two-sided 5% test of equal positive-test probabilities, with 80% statistical power at and . This is a design to distinguish the rates at a twofold alternative; a significance test does not prove that their ratio is exactly two.
The paired design needs the joint positive-test distribution. For specimen , write and . Put andThen and . Under equal marginal rates, the two discordant outcomes have equal probabilities; conditional on the total number of discordant specimens, their split is a fair binomial distribution. This gives the McNemar test. Its large-sample version rejects for a sufficiently large absolute difference between the discordant counts, divided by their estimated standard deviation.
For planning, suppose simultaneous positives are negligible, so . Under the alternative the difference in positive counts has mean and standard deviation ; the approximate upper null rejection boundary is . Requiring 80% upper-tail rejection probability gives the paired binary sample size calculationAdd the mephedrone assay to about 5,000 existing tests, roughly ten weeks at 500 per week. An exact conditional-power calculation under the negligible-overlap model gives about at 4,707 specimens and at 5,000, so the rounding also compensates for the conservative discrete test. If positivity for the two drugs were independent within a specimen, , giving a very similar requirement of about 4,676. For the stated marginal rates, , so negligible overlap is a conservative variance choice within this approximation. Substantial co-use reduces the discordant proportion and changes the necessary size. Repeated tests on the same person, unit-level clustered data or inaccurate assays can instead reduce effective information and require more specimens.
A pre-specified one-sided 5% comparison would use in place of and require about 3,708 specimens before allowing for discreteness under the negligible-overlap assumption. These are different testing conventions. Treating the historical 1% as fixed would give a one-sample calculation, but would ignore uncertainty or changes in the actual 2010 cocaine rate.
Past exam of the mathematics course of the University of Cambridge 2014 iii Paper 33 5 b ii Solution Created 2026-10-03 Updated 2026-10-06
The first model's residual deviance is on residual degrees of freedom, a ratio of about . This is far above the scale expected from a well-fitting dispersion-one grouped binomial regression. It suggests an inadequate mean function, overdispersion, or both. The linear age and exposure restrictions may miss nonlinear associations; the generalized additive model allows those shapes to be estimated through penalized cubic regression splines rather than assumed.
The very small exposure Wald p-value in the first fit suggests an association, but does not establish that a linear logit effect is adequate. Nor does the nonsignificant linear age term exclude every possible nonlinear age effect. Allowing estimated scale also addresses the excessive residual variation, which can arise from clustered data because several births belong to the same woman. The second model's estimated scale confirms that permitting smooth means has not removed all extra variation. The reason to proceed is poor initial fit and possible nonlinear effects, with dispersion-aware inference, not merely the wish to obtain more significant tests. These observational fits alone do not establish causation by the disaster.
Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 3 e Solution Created 2026-10-03 Updated 2026-10-05
There is a genuine syntax error in the printed command: With the default Gaussian family, this generalized additive mixed model isHere across doctors, is an estimated covariance matrix, and the Gaussian errors have variance and are independent of the random effects. The formula
random=list(...) must be a separate argument, following a comma rather than a plus. The intended call ismodel2 <- gamm(npres ~ s(age, bs="cr") + s(wbc, bs="cr"), random=list(doctor=~age))~age includes a random intercept as well as a random slope; it does not force these two effects to be uncorrelated.The random intercept allows different prescribing baselines, and the random slope allows doctor-specific linear modifications to the population age curve. Conditional on these effects the observations are independent under the model, whereas two patients of the same doctor have additional covariance . This accounts for clustered data and avoids treating doctor variation as independent patient-level noise. The population smooth and doctor-specific predictions are different targets. With only four doctors, estimates of the random-effect covariance can be imprecise; the Gaussian support issue for counts also remains. The new model accounts for doctor-specific baselines and age slopes.
Past exam of the mathematics course of the University of Cambridge 2018 iii Paper 218 1 a Solution Created 2026-10-03 Updated 2026-10-05
The violated assumption is independence of random variables across observations: repeated measurements on the same rat form clustered data. A persistent rat-specific weight difference induces positive within-rat covariance, even after adjustment for time and diet. Treating all 176 measurements as independent is pseudoreplication.
For the claimed lack of identifiability in the second fit, Rat must be a categorical variable, as intended by the rat-effect interpretation. Each rat receives only one diet, so this is confounding of nested fixed factors. If is the rat-indicator column, the diet- indicator is . Thus a diet effect can be increased by and every corresponding rat effect decreased by , leaving all fitted values unchanged. With an intercept, two diet columns, fifteen rat contrasts and time, there are 19 columns but only 17 independent columns: the intercept and rat contrasts already span the diet columns, while time varies within rats. This gives rank-deficient ordinary least squares.
Past exam of the mathematics course of the University of Cambridge 2022 iii Paper 218 4 b Solution 2026-09-28
Treatment was assigned by school, so observations within one school are clustered data and plausibly correlated. A random intercept models shared unobserved school characteristics and prevents the effective amount of treatment-level information from being exaggerated by treating all students as independent.
The fitted school standard deviation is , so the estimated between-school variation is nonzero. Accounting for it raises the TV and SC standard errors from about in "lm1" to about in "lme1", reflecting that only 28 independently randomized schools identify those effects.
Past exam of the mathematics course of the University of Cambridge 2025 iii Paper 218 5 b Solution Created 2026-09-24 Updated 2026-09-25
Repeated measurements from one person can share persistent unobserved spending tendencies, violating model1's independent-error assumption and shifting that person's baseline. Model2 represents this clustered data through a common random intercept , which induces within-person covariance for .
Zero-event binomial upper confidence bound 2026-10-14
If and is observed, the maximum-likelihood estimate of is zero. A one-sided upper confidence bound solves , so . For large , , giving approximately at 95% confidence. This describes uncertainty after no observed events, rather than proving that the underlying probability is zero. It assumes independent observations with a common event probability; clustered data require a different uncertainty calculation.