Combining levels of a categorical variable changes both the null hypothesis and the degrees of freedom of an independence test. Association that is coherent across the combined levels may become easier to detect because the grouped table has fewer degrees of freedom, while associations that cancel within groups may disappear. Conclusions from the original and aggregated tables therefore need not agree.
Binary categorical variable 2026-10-25
A categorical variable with two possible categories. Coding an event as one and its complement as zero makes the sample mean of that indicator variable equal to the event's sample proportion.
Confounding of nested fixed factors 2026-10-05
If each level of one categorical variable belongs to exactly one level of another, indicators for the coarser levels are sums of indicators for the finer levels. Including unrestricted fixed effects for both therefore gives a rank-deficient ordinary least squares: the separate effects lack identifiability without additional constraints.
Empirical cross-entropy 2026-10-14
For observations of a categorical variable, empirical cross-entropy is the average logarithmic loss under the reported probability mass function . Writing the empirical distribution as givesUnder independent and identically distributed observations from and a fixed model with positive probability for each possible outcome, the law of large numbers gives convergence to . A finite empirical distribution is an estimate of , rather than the true source law; unobserved outcomes need not be impossible. If the same data are used to choose , evaluating the resulting empirical cross-entropy on that data need not estimate its prediction performance on fresh observations without bias.
Mixture allocation indicator 2026-10-14
Generate a finite mixture model by drawing a categorical variable with , then drawing from the mixture component . The indicator random variables satisfy : exactly one mixture component generates each draw. The joint probability distribution obeys , and the law of total probability gives the mixture distribution after summing out .[ref]
For independent draws from this statistical model, draw a fresh for each . Drawing one shared latent variable for an entire collection is a different joint probability distribution: its individual marginal distributions can match the same mixture distribution while its observations are dependent.
Nominal categorical variable 2026-10-25
A categorical variable whose labels have no intrinsic ordering. Relabelling its categories does not change the underlying classification. An ordinal categorical variable additionally records an order; neither type automatically supplies equal numerical distances between categories.
Past exam of the mathematics course of the University of Cambridge 2002 iii Paper 39 3 Solution 2026-10-14
The response is the species categorical variable, while the four measurements are candidate predictors. The dot in the formula means all other columns of the data frame. The fitted object is a classification tree: it recursively partitions predictor space by binary threshold rules and assigns a species and class-probability vector to each terminal region. Sepal width was available but was not selected in the displayed tree.
At a node , let be the number of observations of class and . The multinomial likelihood is maximized by . The fitted class is one attaining the largest proportion, with a software convention resolving ties. The classification-tree deviance isA pure node has zero deviance. At each nonterminal node, consider candidate split points between distinct observed predictor values, and choose the split with the largest decrease . Repeating this local maximization constructs a binary decision tree; it does not solve a global optimization over all trees. Growth stops when nodes are pure or size/deviance controls prohibit further splitting. Mixed leaves with five or six observations can therefore remain. The node number has children and , and a terminal-node marker means that no further split was retained.
The probability triples are in class order , not . For example, the pure left leaf has probability vector and predicts , while the 54-observation node has counts and predicts . The root counts are , giving and a tied majority class. Its reported choice of does not indicate a more common class.
The complete derived decision rule is shown below. Each leaf includes its fitted class and the observed class counts, so both the branching logic and its remaining errors are visible. For the observed data, the printed strict inequalities leave no equality cases because the thresholds fall between measurement values. A consistent right-branch convention at equality extends the rule to new specimens.
Six-leaf iris classification tree with fitted classes and class counts at every terminal node
. Details. The six terminal nodes contain the class countsThus the training misclassification error isThe terminal classification-tree deviance is insteadThe displayed residual mean deviance divides this by , yielding approximately . This is the summary's reporting convention, not a normal-error residual mean square or an automatic chi-squared calibration with 144 statistical degrees of freedom. The two summary measures answer different questions: deviance depends on the fitted probability of each observed class, while misclassification counts only whether the majority-class prediction is correct. Both are training quantities. Cross-validation or independent test data, rather than the displayed training error, are needed to assess prediction on new specimens; cost-complexity tree pruning can select a less elaborate tree if predictive performance warrants it.
Past exam of the mathematics course of the University of Cambridge 2009 iii Paper 102 1 a Solution Created 2026-10-03 Updated 2026-10-14
The examination used separately emailed files. For this question a public Guerry data archive and its CSV mirror permit a documented reconstruction: retain the 85 records with a recorded region and select the specified columns. All six printed records match exactly, and each of the five regions has 17 departments. The numerical results below refer to that reconstruction; the remaining rows cannot be checked against the unavailable emailed file.
Treat department identifiers as labels and region as a categorical variable. The following summaries show the scale and spread of the quantitative variables:
A larger population-per-crime value means a lower crime rate, and a smaller wealth rank means greater recorded wealth. Donations are markedly right-skewed, as the large gap between mean and median and the upper tail indicate; rank is an ordinal measure rather than a monetary difference. For the ratio analysed next, the median is , the interquartile interval is , and the range is .
Regional median ratios are in C, in E, in N, in S, and in W. The regional box plots and wealth-versus-log-ratio scatter plot in the figure expose this geographical contrast and an inverse association with wealth rank. North has the highest typical property-to-person crime ratio and South the lowest in the reconstructed data. These summaries are descriptive departmental comparisons, not causal or individual-level conclusions.
Past exam of the mathematics course of the University of Cambridge 2009 iii Paper 102 4 d Solution Created 2026-10-03 Updated 2026-10-14
Use the population as exposure regardless of whether a population-size category is also a covariate. Define a demographic factor with levels for at most 20%, for %, and above 30%; define if following the suggested population dichotomy. Treat village-size codes as a categorical variable, not equally spaced areas.
A candidate multivariate Poisson generalized linear mixed model retains the random intercept and slope from part (c) and usesThis specifies the suggested village-size-by-population interaction while keeping its main effects. One may add selected time-by-covariate interactions to explain slope heterogeneity, provided information from 32 clusters supports them. Compare continuous demographic and population formulations as a sensitivity analysis: categorization loses information, and the coefficient of a size category measures association beyond the already included exposure effect.
Fit models with the same likelihood convention and conditional distribution when comparing Akaike information criteria; use joint fixed-effect likelihood-ratio tests, boundary-aware parametric bootstrap tests for random effects, residual diagnostics and village-level cross-validation to justify a parsimonious final model. Preserve interactions' main effects and report interval estimates from the final multivariate model, rather than interpreting separate univariate fits. For example, the adjusted inland-versus-coastal rate ratio is , while a medium-versus-small village ratio is ; a Wald interval for that contrast uses the full coefficient covariance matrix. Conditional time effects and standardized marginal predictions should be distinguished.
The displayed rows cannot identify this final model: population exceeds 250 in every displayed village-year, no large village is shown, and inland status is confounded with the identity of the two displayed villages. The complete 160-row file is needed for fitted effects, model selection, all-village plots and uncertainty. No numerical best model or evidence of the specified covariate associations can honestly be reported from this excerpt.
Finally, even a significant adjusted association with young-male percentage would not show that young males were involved in most incidents. This is the ecological fallacy, specifically that aggregate composition does not identify offender composition: the same village counts can be assigned to different individual age and sex groups without changing any observed aggregate predictor. Individual incident-level age, sex and involvement records are required to answer that last question. The aggregate dataset cannot establish the claimed majority involvement.
Past exam of the mathematics course of the University of Cambridge 2015 ii Paper 4 4J Solution Created 2026-09-24 Updated 2026-10-06
This is a generalized linear model with independent Bernoulli distributions for the responses and the logit link. Under treatment coding with colour one as the reference level, the linear predictor isColour is a categorical variable, not a numerical trend. Width has the same slope for every colour, since no interaction term is fitted. The parameters are estimated by maximum likelihood estimation.
The approximate Wald confidence interval for the width coefficient is , or approximately . This uses the approximate normal distribution of the maximum-likelihood estimator, rather than a confidence interval for an individual binary response.
For the requested crab, the fitted linear predictor is . Applying the inverse logit link gives . The rounded displayed coefficients need not reproduce the reported test statistics exactly.
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.
Regression factor Created 2026-10-07 Updated 2026-10-25
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.
Vaccination status 2026-10-25
A record of which vaccinations a person has received at a specified time. A binary categorical variable may collapse this into two recorded categories; the categories alone do not specify number of doses, timing, protective immunity or willingness to receive a vaccine.
