Categorical variable Created 2026-09-29 Updated 2026-10-05
A categorical variable takes values in a finite or countable set of labels. A regression model usually represents an unordered categorical predictor by indicator variables relative to a reference level in a regression factor.
Past exam of the mathematics course of the University of Cambridge 2012 iii Paper 37 1 c Solution Created 2026-10-03 Updated 2026-10-07
In an R formula,
I(...) protects ordinary arithmetic from the formula operators: the predictor is the numerical variable , rather than an instruction to remove a formula term. Predictor centering leaves fitted values and the height slope unchanged but places the intercept at a meaningful height. It often reduces the correlation between intercept and slope estimates.With , treatment contrasts use female as the reference level in a regression factor. The fitted normal linear model isThe estimates and their standard errors areThe intercept estimates female mean weight at height 165. At that same height the male fitted mean is . Holding height fixed, the fitted male mean exceeds the female mean by 4.3294 weight units. Within either sex, one additional height unit increases fitted mean weight by 0.6211 weight units. If height is in centimetres and weight in kilograms, these interpretations use centimetres and kilograms accordingly. A standard error for the male intercept would require the covariance between and , which is not printed.
The prediction equation is . Predictions for individual students also have residual uncertainty, estimated by , beyond uncertainty in the fitted mean.
Past exam of the mathematics course of the University of Cambridge 2016 iii Paper 206 4 b Solution Created 2026-10-03 Updated 2026-10-06
For independent patients, the Bernoulli logistic-regression model iswhere with nonfrail patients as the reference level in a regression factor. The fitted linear predictor isThe null model fits one intercept, so its 99 residual degrees of freedom imply 100 patients; the full model's confirms this. Unit weights correspond to individual binary responses, not grouped binomial counts.
The Akaike information criterion estimates expected relative out-of-sample discrepancy, using the maximized log-likelihood plus a complexity penalty:Here , since the Bernoulli dispersion is fixed at one. The saturated model puts probability one on each observed binary outcome and has log likelihood zero, so the binomial deviance is . ConsequentlyThere is no estimated error-variance parameter to count. The printed name “Aikake” should be read as Akaike.
Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 206 2 a Solution Created 2026-10-03 Updated 2026-10-05
For independent random variables , the full logistic regression has linear predictorLayout A is the reference level in a regression factor. The smaller model sets , leaving the same logit link and the price predictor. In either caseThe saturated statistical model allows a separate probability per observation; its maximizing probabilities are , with log-likelihood zero under . Hence the binomial deviance for either fitted model isEquivalently, write the summands as . The fitted probabilities differ between the two models, but the definition of binomial deviance is the same. A residual deviance for individual binary data need not itself have an accurate chi-squared distribution approximation; the nested-model difference used next has a different asymptotic justification.
Past exam of the mathematics course of the University of Cambridge 2018 iii Paper 218 1 b Solution Created 2026-10-03 Updated 2026-10-05
Write for rats and for repeated observations. With diet 1 as the reference level in a regression factor, the random-intercept linear mixed model iswith the two families of normal distributions independent and the covariates treated as fixed. The reported estimates areThe corresponding estimated standard deviations are and grams. Individual realized random intercepts are not parameters in this marginal model, and their predictions are not supplied by this summary. For distinct measurements on the same rat, , while the marginal variance is ; different rats are independent.
The estimated mean weight rises by grams per day, adjusting for diet and the rat's random intercept. This common slope is imposed across all diets: there is no time-by-diet interaction term, so these estimates do not compare diet-specific growth slopes. The intercept refers to time zero for diet 1 and a zero rat effect.
Past exam of the mathematics course of the University of Cambridge 2019 ii Paper 1 13J a Solution Created 2026-09-24 Updated 2026-09-29
Let be the number of ice creams in price category and score category . The fitted Poisson regression assumes that the nine counts are independent random variables withwhere the logarithmic link function is used and excellent is the reference level in a regression factor, so . Equivalently,This is the independence log-linear model for a two-way contingency table: price and score have main effects but no interaction.
Past exam of the mathematics course of the University of Cambridge 2025 ii Paper 4 13K c Solution Created 2026-09-24 Updated 2026-09-25
Changing the reference level in a regression factor from A to B does not change the statistical model, fitted probabilities, likelihood, or deviance. If the first parametrization isthen the second isNumerically,
The A-versus-B test is the same test as the former B-versus-A test, with its sign reversed, so its p-value remains . The malignancy coefficient is unchanged in this additive model, so its p-value remains . The intercept now represents site B rather than site A, so its test changes.
The
siteC coefficient also changes meaning: in fit1 it tests C versus A, whereas in fit2 it tests C versus B. Its standard error and p-value therefore need not agree. The displayed tables show that C versus A is not significant (), while C versus B is significant (). There is no contradiction: these are different pairwise hypotheses. Regression factor 2026-10-07
A regression factor is a categorical variable encoded by indicator columns or treatment contrasts in a statistical model. A factor with observed levels normally contributes statistical degrees of freedom when an intercept is present. The reference level in a regression factor has coefficient zero under treatment contrasts. Coding a year as a factor permits arbitrary year effects rather than imposing a linear trend.
Treatment coding 2026-10-06
Treatment coding sets one reference level in a regression factor to zero and represents each other level by an indicator column. With two interacting factors, a main-effect coefficient compares levels at the other factor's reference level; an interaction coefficient is a difference of these contrasts. A joint nested-model F-test can be significant even when some individual coefficient tests are not.