All 14 questions UPSC has asked on analysis of variance in the Statistics Optional (Paper I, Linear Inference and Multivariate Analysis) from 1995 to 2024, solved step by step – latest first.
Try them yourself first: the same questions, without solutions, are on our Linear Inference and Multivariate Analysis topic-wise PYQs page.
How we check these solutions
These are our own solutions, prepared with AI help. UPSC does not publish official answers. Every solution is checked a second way before it goes up, and says how:
- ✓ Checked by computer the numbers were worked out again independently in code (Python with NumPy/SciPy) and matched.
- ✓ Proof checked step by step for “prove that” and “examine whether” questions, every step was checked against the definitions and the standard theorems.
- ✓ Derivation checked step by step for derivations and approximations, every step was checked, and the result was also tested numerically.
- ✓ Answer checked step by step for descriptive questions, every point was checked against the standard theory.
Spotted a mistake or a neater method? Tell us in the comments below or through Report an error.
Jump to a question (year · question number):
2024 · 8c 2023 · 6b(i) 2022 · 6a 2017 · 8a 2012 · 6b 2006 · 8a 2005 · 5b 2003 · 6c 2001 · 6iii 1998 · 9c 1998 · 10a 1996 · 10c 1995 · 9a 1995 · 9b
Write down the model used in the analysis of a two-way classification with interactions, stating the assumptions. What are the hypotheses tested in this scenario? Obtain the expression for the sum of squares and complete the ANOVA.
Solution
Model. Factor A has levels, factor B has levels, and each of the cells has observations (, so that interaction can be separated from error):
- is the general mean, the effect of the -th level of A, the effect of the -th level of B, and the interaction of A and B.
Assumptions.
- The effects are fixed, with , , for every and for every .
- The errors are independent : normality, independence and a common variance.
- The effects are additive in the sense of the model above.
Hypotheses tested.
Least squares estimates. Minimising under the side conditions gives
Splitting the total sum of squares. Write Square and sum over . Every cross-product vanishes, because each bracket sums to zero over the index it does not share with the other. So
For hand calculation, with the grand total, , , the row, column and cell totals and :
Expected mean squares. Under each null hypothesis the corresponding mean square also estimates , and by Cochran’s theorem the sums of squares are independent variables. So each ratio below has an distribution under its own .
ANOVA table.
| Source | df | SS | MS | F |
|---|---|---|---|---|
| Factor A | ||||
| Factor B | ||||
| Interaction AB | ||||
| Error | ||||
| Total |
Reject at level if , and similarly for B and AB. We test the interaction first: if it is significant, the main effects should be interpreted cell by cell rather than averaged over the other factor.
✓ Derivation checked step by step Every step was checked: the least squares estimates under the usual side conditions, the orthogonal split of the total sum of squares, and the expected mean squares used for the F tests.
Describe the complete analysis of two-way classified data with multiple (but equal) observations per cell, clearly stating the assumptions used. Also state two examples where such type of analysis is used.
Solution
Data and model. Two factors are applied together: A at levels and B at levels, with (equal) observations in every cell. The model is
Assumptions.
- The observations are independent, and with the same in every cell.
- Fixed effects with and the interactions summing to zero over each row and each column.
- Equal numbers per cell, so that the factors are orthogonal and the sums of squares split exactly.
Analysis.
- Compute the grand total , , and the raw sum of squares .
- Form the two-way table of cell totals , with row totals and column totals .
- Compute
- Set up the table:
| Source | df | SS | MS | F |
|---|---|---|---|---|
| A | ||||
| B | ||||
| AB | ||||
| Error | ||||
| Total |
- Test the interaction first. If is not significant, test A and B against ; some workers pool with to get more error degrees of freedom. If the interaction is significant, compare the levels of one factor separately at each level of the other, using the cell means with standard error .
- Where a main effect is significant, compare level means with the critical difference for A (or for B).
Two examples where this analysis is used.
- Agriculture: yields of several wheat varieties (factor A) under several fertiliser doses (factor B), with plots per combination. The interaction tells us whether the best variety depends on the dose.
- Industry: the strength of a product made on several machines (A) by several operators (B), with items per machine–operator pair. It tells us whether some operators do better on particular machines.
Other examples are teaching methods × schools in education, and drug × dose in clinical trials.
✓ Answer checked step by step Every step was checked: the model, the orthogonal split of the sum of squares, the degrees of freedom and the F ratios, as in the standard two-way analysis with replication.
In a set of two-way classified data according to levels of factor A and levels of factor B, there is one observation in each cell. Show that the total number of error contrasts is .
Solution
Setting. The model is with (levels of A) and (levels of B), one observation per cell, so observations.
An error contrast is a linear function whose expectation is zero whatever the values of . We must count the linearly independent ones.
Condition. This is zero for all parameter values if and only if (The condition then follows.)
Counting. The vector has entries and must satisfy row conditions and column conditions. These conditions are not independent: adding all row conditions gives , which is also the sum of all column conditions. Apart from that one relation they are independent, so there are independent restrictions. Hence the number of linearly independent error contrasts is
A direct basis. Choose any freely for and : that is free values. The last column then follows from the row conditions, the last row from the column conditions, and the corner cell is consistent because both routes give . So the free choices give exactly independent contrasts, for example
Another view. The rank of the design is (one for , estimable contrasts of , of ). The error space is the orthogonal complement, of dimension . These are exactly the error degrees of freedom in the two-way ANOVA with one observation per cell.
✓ Proof checked step by step We checked the counting argument, and checked numerically that the residual space for a 4 × 3 table has dimension 6 = (4 − 1)(3 − 1).
Three sides of an equilateral triangle were measured by 5 persons with the following results:
| Sides \ Persons | A | B | C | D | E |
| 5.44 | 5.41 | 5.43 | 5.42 | 5.43 | |
| 5.43 | 5.41 | 5.42 | 5.43 | 5.44 | |
| 5.45 | 5.42 | 5.43 | 5.43 | 5.44 |
Is there any significant difference between (i) measurements by the persons and (ii) the sides of the triangle?
Solution
Set-up. This is a two-way classification with one observation per cell: 3 sides (rows) × 5 persons (columns). To simplify, code ; this changes all sums of squares by the factor but leaves every F ratio unchanged.
| Side Person | A | B | C | D | E | Total |
|---|---|---|---|---|---|---|
| 4 | 1 | 3 | 2 | 3 | 13 | |
| 3 | 1 | 2 | 3 | 4 | 13 | |
| 5 | 2 | 3 | 3 | 4 | 17 | |
| Total | 12 | 4 | 8 | 8 | 11 |
Model. , with the side effect and the person effect, .
Hypotheses: : no difference between persons (); : no difference between sides ().
Sums of squares. , , .
ANOVA table (coded units).
| Source | df | SS | MS | F | |
|---|---|---|---|---|---|
| Sides | 2 | 2.133 | 1.067 | 3.37 | 4.46 |
| Persons | 4 | 13.067 | 3.267 | 10.32 | 3.84 |
| Error | 8 | 2.533 | 0.317 | ||
| Total | 14 | 17.733 |
Conclusions (5% level).
- Persons: , so the measurements made by the five persons differ significantly (). Person B in particular reads lower than the others.
- Sides: , so there is no significant difference between the three sides (). This agrees with the triangle being equilateral.
✓ Checked by computer We re-ran the whole ANOVA in Python: SS sides 2.133, persons 13.067, error 2.533 (on the coded scale); F = 3.37 for sides and 10.32 for persons, against 4.46 and 3.84.
Write down the model used for one way analysis of variance. The lifetimes (in hours) of samples taken from three different brands of batteries gave the following: , , , , , , , and . Test the hypothesis that there is no difference in lifetimes for the three brands. Also write down the ANOVA .
Solution
Model for one-way ANOVA. where is the general mean, is the effect of the -th class (here, brand) with , and the are independent .
We test (no difference in mean lifetime) against : not all equal.
Grand mean. :
Between-brand SS.
Within-brand SS. This is given directly:
ANOVA table.
| Source | df | SS | MS | F |
|---|---|---|---|---|
| Between brands | 2 | 1140 | 570.0 | 4.275 |
| Within brands (error) | 12 | 1600 | 133.3 | |
| Total | 14 | 2740 |
Decision. . We reject at the 5% level: the three brands differ significantly in mean lifetime. The first brand (mean 40 hours) is clearly the weakest.
✓ Checked by computer We recomputed in Python: grand mean 52, between SS 1140, within SS 1600, F = 4.275 against 3.89 (p ≈ 0.040).
Discuss the two-way analysis of variance model giving its analysis and ANOVA table.
Solution
Data. A two-way layout: factor A (rows) at levels, factor B (columns) at levels, one observation per cell. (The case with observations per cell, which adds an interaction line, is in Q1.)
Model. The effects are assumed additive: there is no interaction, which cannot be estimated with one observation per cell.
Least squares. Minimising gives the normal equations where , and are the row, column and grand totals. With the side conditions:
Split of the sum of squares. Squaring and summing, the cross-products vanish (each term sums to zero over the index it lacks), so
Expected mean squares. By Cochran’s theorem, , and are independent chi-squares (central under the respective nulls).
ANOVA table.
| Source | df | SS | MS | F |
|---|---|---|---|---|
| A (rows) | ||||
| B (columns) | ||||
| Error | ||||
| Total |
with . We reject when exceeds the upper point of , and similarly.
✓ Derivation checked step by step Every step was checked: the least squares estimates, the orthogonal split of the total sum of squares and the expected mean squares.
Describe Tukey’s test for non-additivity for a two-way layout with one observation per cell.
Solution
Problem. With one observation per cell, the two-way model uses the interaction degrees of freedom as error. If the factors in fact interact, the “error” is inflated and the tests lose power. Tukey (1949) gave a test for one particular, common type of non-additivity using just one degree of freedom.
Idea. Suppose the interaction is a multiple of the product of the main effects: This happens, for instance, when the effects are really multiplicative, so that a log or power transformation would make them additive. We test .
Computation. Let rows and columns, and .
- Compute
- The sum of squares for non-additivity, on 1 df, is
- The usual residual sum of squares (on df) is split into and a remainder:
- Under (additivity), and independently, so
Why this works. is the regression sum of squares when the residuals are regressed on the products . Conditionally on the row and column means, those products are fixed and lie in the interaction space, so the usual regression argument gives the distribution and its independence from the remainder.
ANOVA layout.
| Source | df | SS |
|---|---|---|
| Rows | ||
| Columns | ||
| Non-additivity | 1 | |
| Remainder | ||
| Total |
Use. A significant suggests the data should be transformed (for example , or logs) before the additive analysis, or that the interaction should be modelled.
✓ Derivation checked step by step Every step was checked: Tukey’s one-degree-of-freedom sum of squares, its independence from the remaining error, and the resulting F test.
Explain the concept of one-way classified data. Write the linear model for it Obtain the least square estimate of the parameters involved in it.
Solution
One-way classified data. The observations are grouped according to one factor (one criterion of classification) into classes, for example yields of varieties of a crop, or marks of students taught by methods. Class has observations, . The aim is to compare the class means.
Linear model. where is the general mean, the effect of class , and the are independent . In matrix form with . has rank , not (its first column is the sum of the others), so we need one side condition, usually .
Least squares. Minimise The equations in the second line add up to the first, so only are independent. Using :
So the fitted value for class is the class mean . The estimable quantities, such as and the contrasts with , do not depend on the side condition chosen; for example .
Error variance. The residual sum of squares is on df, and is unbiased for . It is used to test with , where .
✓ Derivation checked step by step Every step was checked: the normal equations and the least squares estimates under the side condition, which reproduce the class means.
Describe an appropriate test for equality of means of several populations on the basis of independent samples drawn from them.
Solution
Problem. We have independent samples of sizes from normal populations with a common variance. We test For this is the two-sample test; for the right test is the one-way analysis of variance.
Notation. , is the mean of sample , the overall mean.
Split of the total variation. that is, , total = between samples + within samples. The cross-product vanishes because .
Distributions.
- Whatever the means, (it is the sum of independent within-sample sums of squares, with df each).
- Under , , independent of (the sample means are independent of the sample variances for normal samples).
- In general , with .
Test. Large values of indicate unequal means, because the numerator then tends to exceed while the denominator does not. We reject at level if .
| Source | df | SS | MS | F |
|---|---|---|---|---|
| Between samples | ||||
| Within samples | ||||
| Total |
Remarks.
- This test is the likelihood ratio test for .
- Before it, check the common-variance assumption, for example with Bartlett’s test. If the normality assumption is doubtful, use the Kruskal–Wallis rank test.
- If is rejected, compare pairs with the critical difference , or with Tukey’s or Scheffé’s method.
✓ Derivation checked step by step Every step was checked: the split of the total sum of squares, the chi-square distributions and the F statistic for the one-way analysis of variance.
In the case of two-way classified data with unequal number of observations per cell derive the expectation of the MS components of the ANOVA table.
Solution
Model. Rows (A) , columns (B) , with observations in cell and no interaction: Write , , , and , , for the row, column and grand totals.
With unequal the rows and columns are not orthogonal, so the ANOVA uses the method of fitting constants:
A key result. If is a quadratic form in the observations, with and , then When is a projection matrix (symmetric and idempotent), = the degrees of freedom.
(1) Error. , where projects onto the column space of the full design (rank ). Since ,
(2) Columns, ignoring rows. , a projection of rank . So where and . Even when this expectation contains row effects, which is why cannot be used to test B unless the rows are eliminated.
(3) Rows, eliminating columns. , a projection of rank . The column effects lie in the space of , so they drop out: where is the matrix of the reduced normal equations for after and are eliminated: Thus , which is zero exactly when holds.
The same argument with the roles reversed gives , and the unadjusted row SS has
ANOVA table.
| Source | df | SS | E(MS) |
|---|---|---|---|
| Columns (ignoring rows) | |||
| Rows (eliminating columns) | |||
| Error | |||
| Total |
With equal , , so and we recover the familiar results of Q14.
✓ Derivation checked step by step We checked the derivation, and checked by simulation for a 3 × 3 layout with unequal cell sizes that the expectation of the unadjusted row sum of squares matches the formula (13.01 simulated against 12.95).
Define contrasts, orthogonal contrasts and show that SS due to n observations is equal to the total SS due to the orthogonal contrasts.
Solution
Definitions. Let be observations (or treatment totals).
- A linear contrast is with .
- Two contrasts and are orthogonal if . When the are independent with common variance , orthogonal contrasts are uncorrelated (independent under normality), since .
- The sum of squares due to a contrast is , on 1 df.
Result. If are mutually orthogonal contrasts, then (Including the “total” , with , gives , the raw SS of the observations.)
Proof. Normalise each contrast: , so . Put . Since each sums to zero, , and the are mutually orthogonal unit vectors. So are orthonormal vectors in , and the matrix with these rows is orthogonal: .
Then satisfies , that is, The first term is , the correction factor. Hence
Meaning. The df of the total (corrected) sum of squares can be split into independent single-df components, one for each orthogonal contrast. This is how, for example, treatment sums of squares in factorial experiments are split into main effects and interactions.
Example. For , the contrasts and are orthogonal, and
✓ Proof checked step by step We checked the proof, and checked in Python with Helmert contrasts for n = 5 that the sum of the contrast sums of squares equals the total sum of squares.
Write down the model of a complete three-way classified data with equal number of observations per cell. Write down the corresponding ANOVA table.
Solution
Model. Factors A, B, C at , , levels, with observations in every cell: with , , , . All effects are fixed and sum to zero over each of their subscripts, and .
Sums of squares (with and the various marginal totals ):
- , and similarly and .
- , and similarly and .
- .
- (within cells), and .
ANOVA table.
| Source | df | MS | E(MS) | F |
|---|---|---|---|---|
| A | ||||
| B | ||||
| C | ||||
| AB | ||||
| AC | ||||
| BC | ||||
| ABC | ||||
| Error | ||||
| Total |
The degrees of freedom add up: for the cells, plus within cells, giving .
Each is compared with on its own df and . As usual, the highest-order interaction is examined first. (With there is no within-cell error, and is used as error, assuming the three-factor interaction is negligible.)
✓ Derivation checked step by step Every step was checked: the model with all interactions, the degrees of freedom (which add to abcr − 1) and the expected mean squares used for the F ratios.
Describe the model and the analysis of variance of a complete two-way classified data with equal () number of observations per cell. State clearly what you will do if the interaction effects (i) are not significant (ii) are significant.
Solution
Model. A at levels, B at levels, observations per cell: with fixed effects summing to zero over each subscript and .
Analysis of variance. With cell totals , row totals , column totals , grand total and :
| Source | df | SS | MS | E(MS) | F |
|---|---|---|---|---|---|
| A | |||||
| B | |||||
| AB | |||||
| Error | |||||
| Total |
The interaction is tested first, with on and df.
(i) Interaction not significant. The factors act additively: the difference between two levels of A is the same at every level of B.
- Test the main effects with and .
- If the interaction is clearly negligible (some use the rule ), pool it with error, on df, to get a more precise error estimate, and test A and B against .
- For a significant main effect, compare the level means using the critical difference (and for B). The best level of A is then best at every level of B.
(ii) Interaction significant. The effect of A depends on the level of B, so the main-effect tests (averaged over the other factor) can mislead and are usually not interpreted on their own.
- Study the cell means , for example with an interaction plot.
- Compare the levels of A separately at each level of B (simple effects), using the critical difference . Each simple effect can also be tested with its own SS, on df, against .
- Recommend the best combination rather than a best level of each factor.
- In a random or mixed model, a significant interaction also changes the denominator: main effects are then tested against , not .
✓ Answer checked step by step Every step was checked: the model, the sums of squares, the degrees of freedom, the expected mean squares, and the follow-up procedures for significant and non-significant interaction.
In the case of two-way classified data with one observation per cell derive the expectations of the MS components of the ANOVA table.
Solution
Model. One observation per cell, rows and columns :
Means of the model: , , .
We use the fact that for independent ’s with variance , the expected sum of squared deviations of means, each of observations, about their mean is .
Rows. Expanding, the cross term has expectation zero, so
Columns. In the same way,
Error. The residual is free of the parameters: Then and the identity gives
ANOVA table with expected mean squares.
| Source | df | MS | E(MS) |
|---|---|---|---|
| Rows | |||
| Columns | |||
| Error | |||
| Total |
So and are the natural test statistics: each numerator has expectation exactly when its null hypothesis holds.
Random effects. If the row and column effects are random, and , the same argument gives , and .
✓ Derivation checked step by step We checked the derivation, and checked by simulation for a 4 × 5 layout that the mean squares average 5.19, 1.90 and 1.00 against the theoretical 5.17, 1.90 and 1.00.
More on Linear Inference and Multivariate Analysis
- All Statistics PYQ solutions, topic by topic
- Linear Inference and Multivariate Analysis topic-wise PYQs (questions only, for practice)
- Statistics PYQ analysis: which units carry the marks year by year
- Year-wise question papers
- Statistics booklist
Questions: UPSC Civil Services (Main) Examination, Statistics Paper I, 1995–2024. Solutions: Optional Province. Found an error? Tell us.

