Why Build a Reference Grid?
A factorial model can describe outcomes across combinations of categorical factors and values of quantitative covariates. To interpret a fitted model, it is often useful to ask: what does the model predict for each selected combination? A reference grid makes those prediction settings explicit. Each row specifies factor levels and, when relevant, fixed values of covariates; the fitted model then supplies a predicted mean for that row.
A reference grid is not a new data set of observed individuals. It is a set of settings at which predictions are requested. Some settings may match combinations seen in the data, while others may not. The grid itself does not decide how predictions across its rows should be combined. Here the focus is on constructing the settings and identifying the fitted prediction for each one.
The Model Behind Each Grid Prediction
Consider a linear model with fixed effects and a quantitative response. For observational unit \(i\), write
Here \(\mathbf{x}_i\) is the design vector determined by that unit’s factor levels and covariate values, \(\boldsymbol{\beta}\) is the vector of model coefficients, and \(\varepsilon_i\) is the error. The model specifies the conditional mean \(E(Y_i\mid\mathbf{x}_i)=\mathbf{x}_i^\mathsf{T}\boldsymbol{\beta}\). After fitting the model, the predicted mean at a grid row with design vector \(\mathbf{x}_g\) is
The vector \(\mathbf{x}_g\) is constructed just as a design vector would be for an observation with those settings. For example, it includes the appropriate indicator values for categorical factor levels, the chosen covariate value, and any products or other terms required by the model. If the model includes an interaction, the corresponding interaction term must also be evaluated at the grid row.
The usual linear-model framework assumes that the specified mean model is appropriate and that errors have mean zero, are independent across independent observational units, and have a common variance. Normal errors, \(\varepsilon_i\sim N(0,\sigma^2)\), are commonly assumed for exact small-sample inference. These assumptions concern the model and its errors, not the grid-building operation itself. A numerical prediction can be calculated from fitted coefficients, but its usefulness depends on the model being suitable for the requested settings.
Constructing the Grid and Evaluating It
Start by naming the factors and covariates in the fitted model. For each factor included in the grid, specify the levels to represent. For each quantitative covariate, specify the value or values at which predictions are wanted. Crossing the selected factor levels and covariate values produces the grid rows. Then evaluate the fitted model at each row.
List the factor levels and covariate values relevant to the question. State units for quantitative covariates.
Make one row for each selected combination. A row is a setting for prediction, not necessarily an observed individual.
Use the model’s coding and include every specified term, including interactions and transformations.
Compute \(\mathbf{x}_g^\mathsf{T}\widehat{\boldsymbol{\beta}}\) for each row, then check that the requested predictions are supported by the fitted model and data.
When a quantitative covariate is assigned one value, that value is held constant across the relevant rows. If several values are specified, the grid includes rows for each selected value. These choices should be tied to the question: a covariate setting should be interpretable and, when possible, within the range represented by the data. A grid does not automatically use the observed distribution of a covariate or represent every possible value.
Worked Example: A Two-Factor Grid With an Interaction
Suppose a hypothetical study compares two preparation methods, \(A_1\) and \(A_2\), across two settings, \(B_1\) and \(B_2\). The quantitative response is a test score in points. Assume all four combinations were observed, and the fitted model is
where each indicator is 1 when the named level is present and 0 otherwise. Assume the model’s residual checks are compatible with independent, constant-variance errors, and that the fitted mean structure is reasonable for these settings. To make the reference grid, list each level of \(A\) crossed with each level of \(B\). Substitute the indicators for each row.
| Grid row | Substitution into fitted model | Predicted score |
|---|---|---|
| \(A_1,B_1\) | \(70+4(0)+3(0)+2(0)(0)\) | 70 points |
| \(A_1,B_2\) | \(70+4(0)+3(1)+2(0)(1)\) | 73 points |
| \(A_2,B_1\) | \(70+4(1)+3(0)+2(1)(0)\) | 74 points |
| \(A_2,B_2\) | \(70+4(1)+3(1)+2(1)(1)\) | 79 points |
For example, the last row includes the interaction contribution \(2(1)(1)=2\), so its fitted prediction is \(70+4+3+2=79\) points. The grid identifies four fitted cell means, one for each factor combination. Because the model includes an interaction, its prediction for \(A_2,B_2\) is not obtained by adding only the two main-effect contributions.
Adding a Covariate to the Grid
A quantitative covariate must be assigned a value if the requested predictions are to be evaluated at a common covariate setting. For example, a model may predict a response at age 40 for each treatment group. This is different from predicting at each group’s own average age: the latter would use different covariate values in different rows. A grid makes the chosen setting visible, so the interpretation does not depend on an unstated default.
Worked Example: Treatment Predictions at a Specified Age
In a hypothetical clinical analysis, the response is a symptom score in points, and the factor \(T\) has levels Control and Active. Age is measured in years. Suppose the fitted model is
Assume the model was fitted to independent participants, its residual pattern is consistent with the stated linear mean form and roughly constant error variance, and the selected age is represented within the observed age range. We want predictions for both treatment levels at age 40 years. The grid therefore has two rows: Control at age 40 and Active at age 40. Since \(40-50=-10\), evaluate each row as follows.
Control, age 40: the treatment indicator is 0, so the interaction term is also 0. The prediction is \(30-0.2(-10)=30+2=32\) points.
Active, age 40: the treatment indicator is 1. The prediction is \(30+5-0.2(-10)+0.1(1)(-10)=30+5+2-1=36\) points.
The two entries are model predictions at the same specified age, not the observed mean scores of all Control and Active participants. The interaction is evaluated using both the treatment indicator and the age displacement from 50 years. Omitting that term would give an incorrect Active prediction for age 40.
When a Grid Row Is Not an Observed Cell
A complete reference grid may include a combination that has no observed data. This can happen in an unbalanced design or when a factor combination is absent. The model may nevertheless produce a numerical prediction if its structure connects the observed data and the requested prediction. That prediction is then supported by the model’s assumptions rather than by direct observations in that cell. A numerical output alone does not establish that the prediction is estimable or scientifically well supported.
In particular, a model that omits an interaction imposes a restriction on how factor effects combine. A prediction for an empty combination under that model relies on the absence of the omitted interaction. If a requested linear prediction is not estimable from the fitted design, the reference grid cannot make it identifiable by listing the missing combination. The design and model must support the prediction.
Worked Example: Predicting an Unobserved Combination Under an Additive Model
Suppose a hypothetical two-factor experiment has observed combinations \(A_1B_1\), \(A_2B_1\), and \(A_1B_2\), but no observations at \(A_2B_2\). The response is measured in milligrams. An additive model, with \(A_1\) and \(B_1\) as reference levels, is fitted:
Assume the additive mean structure is scientifically defensible, the observed combinations provide a connected design for estimating the model, and the usual independent, constant-variance error assumptions are reasonable. Build a four-row grid from the two levels of each factor. The three observed combinations have predictions \(12\) mg at \(A_1B_1\), \(12+3=15\) mg at \(A_2B_1\), and \(12-2=10\) mg at \(A_1B_2\). For the unobserved combination \(A_2B_2\), substitute both indicators as 1:
Thus the complete grid contains a fitted prediction of 13 mg for \(A_2B_2\). It is not an observed cell mean: no units were measured in that combination. It follows from the additive model, which assumes that the \(A\) and \(B\) effects combine without an additional \(A\)-by-\(B\) interaction. If that assumption is unsuitable, this prediction may not answer the scientific question.
A Short Justification for the Grid Calculation
The formula for a grid prediction follows directly from the model’s conditional mean. At any specified setting \(g\), the model says \(E(Y\mid\mathbf{x}_g)=\mathbf{x}_g^\mathsf{T}\boldsymbol{\beta}\). Replacing unknown coefficients by their fitted estimates gives the fitted mean at that setting:
The final equality shows why every model term must be included: each coefficient contributes in proportion to the corresponding design-vector entry. Factor indicators, covariate values, and interaction products determine those entries. Applying this calculation row by row produces the grid’s fitted cell means. The formula gives point predictions; uncertainty intervals and comparisons require additional calculations and are separate from simply constructing the grid.
Common Mistakes and Why the Grid Matters
The most common mistake is to treat a reference grid as though it were a table of raw observations. It is instead a transparent list of prediction settings. This distinction matters especially when data are unbalanced, covariates are present, or some factor combinations were not observed. Stating the grid lets a reader see exactly what the fitted values refer to and which assumptions are needed to interpret them.
- Leaving covariate values implicit. A prediction “for each treatment” is incomplete when age or another covariate is in the model. State the covariate value and its units.
- Dropping interaction terms. If a fitted model contains an interaction, calculate its contribution at every grid row where its factors or covariates make it nonzero.
- Calling a model prediction an observed mean. A fitted value for an empty cell is model-based, not a direct summary of measurements from that cell.
- Assuming every requested row is supported. A grid can list settings that are outside the data’s range or that do not correspond to estimable predictions. Check the model and design rather than relying on the existence of a number in software output.
- Confusing the grid with a rule for combining predictions. The grid identifies the predictions available for consideration; a separate target determines whether and how those predictions should be combined.
Check Your Understanding
For each question, identify the grid settings or explain what a fitted grid prediction represents.
- A model has factors with three and two levels, plus age as a covariate. How many grid rows are needed to represent every factor combination at one fixed age?
- In a model with a treatment-by-age interaction, why must the interaction term be evaluated separately for each grid row?
- A grid includes a factor combination with no observed cases, and the fitted model gives a prediction. Why should that value not be described as the observed mean for the combination?
- A researcher wants predictions for two treatments at age 55 years. What must be stated in the reference grid, and why?
- Does listing a row in a reference grid by itself establish that its prediction is estimable and well supported? Explain.