Home / DOE / Charts / Interaction Plots / Math Details
Math Details¶
This page gives the values an interaction plot draws and how each one is formed: where the points sit, what number each point carries under each of the two sources, how the smooth curve between them is built, and how the value axis is chosen.
One engine builds Interaction Plots, Main Effects Plots and the Thumbnail Plot. Everything below is that engine asked for a chart of two different factors. The differences between the three are collected in the last section.
Notation¶
| Term | Description |
|---|---|
| \(A\) | the factor on the horizontal axis |
| \(B\) | the factor whose levels give the separate lines |
| \((u, v)\) | one setting of the pair \((A, B)\) that appears in the design's runs; a value for a quantitative factor, a level for a categorical one |
| \(R_{uv}\), \(n_{uv}\) | the runs at that setting, and how many of them there are |
| \(y_r\) | the response measured on run \(r\) |
| \(\bar{y}_{uv}\) | the value plotted at \((u, v)\) from a design sheet |
| \(G_{uv}\) | the replicate groups the runs of \(R_{uv}\) fall into |
| \(G^{+}_{uv}\) | those groups of \(G_{uv}\) that hold two or more runs, the only ones that produce a standard deviation |
| \(R_{uvg}\), \(n_{uvg}\) | the runs of replicate group \(g\) within \(R_{uv}\), and how many of them there are |
| \(\bar{y}_{uvg}\) | the mean of the responses in \(R_{uvg}\) |
| \(s_{uvg}\) | the sample standard deviation of the responses in \(R_{uvg}\) |
| \(\bar{s}_{uv}\) | the standard deviation plotted at \((u, v)\) from a design sheet |
| \(t_k\) | the set point typed or picked for factor \(k\) |
| \(\mathbf{z}\), \(z_k\) | the vector of factor settings handed to the prediction equation, and its entry for factor \(k\) |
| \(\hat{y}\) | the value plotted from a regression sheet: a fitted response on the response level, a fitted standard deviation on the standard deviation level |
| \(c_j\), \(b_j\) | the coded value and the coefficient of model term \(j\) |
| \(x_{\min}\), \(x_{\max}\) | the smallest and the largest horizontal position on one line |
| \(N\) | the number of points in a drawn curve, fixed at \(100\) |
| \(y_{\min}\), \(y_{\max}\) | the smallest and the largest value plotted anywhere in one report |
| \(\Delta\) | the tick spacing of the value axis |
| \(r\) | the rounded range the value axis is built from |
| \(y_{\text{low}}\), \(y_{\text{high}}\) | the two ends of the value axis |
| \(n\) | the number of ticked factors |
Where the points sit¶
The horizontal positions come from the design sheet under either source. The engine first reads the runs and collects every distinct setting of the pair \((A, B)\) that appears among them, in the order the runs present them. Only then, and only when the source is a regression sheet, does it replace each point's value with a prediction. So a chart never shows a combination of \(A\) and \(B\) that the experiment did not visit, whichever source it was built from, and a combination that was not run has no point rather than a predicted one.
The points are then sorted by \(u\), and by \(v\) where \(u\) ties, so the horizontal axis reads left to right. The lines are ordered by \(v\): by the level order for a categorical \(B\), by the value for a quantitative one. Within a line the points are ordered by horizontal position, and where \(A\) is quantitative any point with no value is moved to the end. Where \(A\) is categorical the order is the level order alone, so a valueless point keeps its place in the run of levels rather than moving.
When \(A\) is categorical and a line is missing one of its levels, that line is padded with a valueless point at the missing level, so every line of the chart carries the same number of points.
A value read from a design sheet¶
The response level. The point at \((u, v)\) is the mean of the responses of the runs at that setting:
The average is taken over every run at that setting, whatever the remaining factors were doing in those runs.
The standard deviation level. The runs at \((u, v)\) are first split into their replicate groups. Each group of two or more runs gives one sample standard deviation:
and the point is the mean of the standard deviations that were produced, which is one per group of two or more runs:
The divisor counts only the groups that produced a standard deviation. A group holding a single run produces none, and it is left out of the average altogether: it adds nothing to the sum and it is not counted in the divisor either. So a setting with three replicate groups, one of them a single run, averages two standard deviations and divides by two, not by three.
A setting where no group holds two or more runs has nothing to report, and its point is left blank rather than set to zero.
A value predicted from a regression sheet¶
The engine builds one vector of factor settings and hands it to the prediction equation. The entries for the two plotted factors are the point's own position; every other entry is that factor's set point:
The set points of \(A\) and \(B\) are overwritten before every prediction, so they are never read on this chart. Their rows stay on the dialog and stay editable, and what is typed in them has no effect here.
They do still act on the other charts of the same grid. The vector is copied afresh for each chart and only that chart's own two entries are replaced, so with three or more ticked factors \(A\) is swept on the chart that plots it and held at its set point on every chart that does not. One box can therefore move most of the sheet and leave a few charts alone.
Each entry is then coded, and the coded values are combined with the coefficients already on the regression sheet:
Every quantitative factor is put on a common scale before the regression runs. One expression does it, whichever coding is in force, using a centre \(m_c\) and a scale \(s_c\) that the coding chooses:
A categorical factor is never coded this way. Its coded value is \(1\), and the level it sits at selects which coefficient is used instead.
An interaction's coded value is the product of the coded values of the factors in it.
A prediction is the sum, over every term in the model, of that term's coded value times its coefficient:
where \(c_j\) is the coded value of term \(j\) at the settings you asked about and \(b_j\) is its coefficient from the regression table. The constant term has \(c_j = 1\), so its coefficient enters as itself.
A term that is absent from the regression table, or switched off for the level being predicted, contributes \(b_j = 0\).
For a binary output the same sum is formed and passed through the logistic function:
For a binary output the same sum is formed first, then passed through the logistic function to give a probability:
That is the probability of the first level. The probability of the second is \(1 - p\).
For a nominal output there is one sum per level:
For a nominal output with \(L\) non-reference levels there is one sum per level, \(\eta_k = \sum_j c_j b_{jk}\), and the probability of level \(k\) is
The \(1\) in the denominator is the reference level, whose \(e^{\eta}\) is \(1\) by construction. So the reference level's own probability is
and the probabilities across all levels sum to \(1\).
Which coefficients are used follows the level you ticked. On a quantitative output the response level reads the response model's coefficients and the standard deviation level reads the standard deviation model's, so on that level every \(\hat{y}\) above is a predicted standard deviation. The set-point vector, the coding and the sum are the same either way.
When the two sources agree¶
The two sources put their points at the same horizontal positions, so the two charts can be laid side by side. Whether the values on them are the same number depends on where the held factors have been put, and there is one arrangement in which they agree exactly.
On a balanced design, with every held factor left at the default set point, the midpoint of its range, the two agree exactly at every point. At the midpoint a held quantitative factor codes to zero, so its own term and every interaction it appears in drop out of the sum, and what is left is the mean of the runs in that cell.
Move one held factor off its midpoint and the two part company, by an amount that depends on the coefficients of the terms that factor appears in. The agreement holds at one particular set of settings rather than in general, so a design-source chart and a regression-source chart of the same pair are comparable only when you know where the held factors were put.
The smooth curve¶
When the source is a regression sheet and \(A\) is quantitative, each line carries a second series in addition to its points at the settings that were run. The series holds \(N = 100\) points spread across that line's own range of horizontal positions:
Each \(x_i\) carries the prediction with \(A\) at \(x_i\), \(B\) at that line's own level, and every held factor at its set point, formed exactly as the section above describes. The code does not evaluate that expression. It adds the step to a running position and clamps the result to \(x_{\max}\) after each addition, so reproducing these numbers exactly means adding the step ninety nine times rather than multiplying it, and the two can part in the last bits. The clamp is also what stops accumulated rounding carrying the last point past the end of the range.
A line with only one horizontal position is left without a curve, since there is no range to spread points across. A categorical \(A\) gets no curve either, because there is nothing between two levels to draw through.
The curve is built for every output type, not only for a fitted probability. It is what lets a square term, a logistic bend, or any other curvature of the fitted model show, where straight segments drawn between the settings that were run would hide it.
The value axis¶
Every chart of one report contributes its plotted values to a pool, and the axis is computed once from that pool, so the charts on one sheet share one value axis and their heights can be read against each other. An interaction plot report holds only charts of two different factors, so there is one pool and one axis. Curve points count toward \(y_{\min}\) and \(y_{\max}\) alongside the points at the run settings; points with no value are skipped.
The axis ends are chosen by rounding to a nice number. Write
where \(e\) is the base ten exponent of \(r\), \(\phi\) is its leading fraction, and \(f\) is a nice fraction read from \(\phi\) by one of two tables. Rounding to the nearest takes \(f = 1, 2, 5, 10\) as \(\phi\) falls below \(1.5\), below \(3\), below \(7\), or higher; rounding up takes \(f = 1, 2, 5, 10\) as \(\phi\) is at most \(1\), at most \(2\), at most \(5\), or higher. The range is rounded up and the tick spacing to the nearest:
Three guards follow. A range below \(10^{-5}\) is replaced by the largest power of ten not exceeding the larger of \(\lvert y_{\min} \rvert\) and \(\lvert y_{\max} \rvert\), and failing that by \(10^{-5}\), so a flat set of values still gets an axis. An end that rounding moved inside the data is pulled back to the data, so the axis can never cut off a plotted point. And if the two ends come out equal, each of them is moved by \(r/2\), the low end down and the high end up, so the axis ends up spanning \(r\) rather than \(r/2\).
The same construction gives the horizontal axis ends when \(A\) is quantitative, from the smallest and the largest horizontal position instead of from the values.
The number of decimal places on the value axis labels comes from the points at the run settings, the curve points not counting toward it: the most any one of them needs, or one place when every one of them is identical.
Cells that are not drawn¶
A cell is written as NA rather than a chart in two cases: when either of its factors is nested inside another factor, and when not one of its points carries a value. The second covers a standard deviation chart from a design sheet whose settings hold no replicate group of two or more runs.
How the three charts differ¶
The engine is one class and these are its three shapes.
- Interaction Plots builds a chart for each ordered pair of two different ticked factors and none for a factor against itself, so \(n\) ticked factors give \(n(n-1)\) charts. The diagonal cells of the grid carry the factor names rather than charts. The One specific pair layout builds the one chart named by the two pickers.
- Main Effects Plots builds only charts of a factor against itself, one per ticked factor.
- Thumbnail Plot builds both kinds, \(n\) of the first and \(n(n-1)\) of the second, filling all \(n^2\) cells, and keeps two separate value axes for them.
Shared Math Details used here¶
This chart uses shared formulas defined once in Shared Math Details. See those pages for the exact definitions.
| Shared concept | Used here for | Reference |
|---|---|---|
| Prediction equation | the plotted value when the source is a regression sheet | Prediction Equation |
| Design coding | turning a horizontal position or a set point into the coded value the prediction uses | Design Coding |
See Also¶
References¶
- Montgomery, D. C. (2013). Design and Analysis of Experiments, 8th edition. Wiley.
- Heckbert, P. S. (1990). Nice Numbers for Graph Labels. In A. S. Glassner (Ed.), Graphics Gems. Academic Press.