Let be the flight distance in millimetres for paper level , launch-angle level , design level and replicate , where and . The full factorial design is fitted by the normal linear model
The assumptions are independent errors with a common variance and normal distribution, and the displayed factor-combination mean structure. The corner-point constraints are
and whenever at least one index equals . Thus the eight free mean coefficients are . These treatment coding coefficients are comparisons at the other factors' reference levels, rather than necessarily averaged main effects.
To test the three-factor interaction term, compare the full model with the model retaining all main effects and all two-factor interactions. The null hypothesis is , against a nonzero value. Removing it increases the residual sum of squares by and removes one parameter. With eight residual degrees of freedom, the nested-model F-test gives
There is no evidence that this three-factor interaction is needed. This does not establish that all two-factor interactions vanish: the paper-design interaction is substantial.
The stepAIC command performs stepwise selection by the Akaike information criterion. Its upper scope is the full factorial model and its lower scope is the intercept-only model. Starting from the full model, it compares admissible additions and deletions, preserving the hierarchy of interaction terms, and chooses changes that reduce the Akaike information criterion. With the supplied scope its default search permits both directions. For these Gaussian fits the displayed criterion, up to constants common to all models, is , where counts mean coefficients. The first deletion changes it from to : the small increase in residual sum of squares is outweighed by removing a parameter. This is a greedy model selection procedure, not an exhaustive search or a sequence of fixed-level hypothesis tests. The command's arguments are described in the MASS documentation.
For the selected model, let and . Then
independently between flights. It has no angle term. The maximum-likelihood estimates of its mean coefficients are also obtained by ordinary least squares:
For example, the four fitted means are just the four paper-design cell means, each averaging four flights over the angle levels. With , the variance-covariance matrix of the coefficient estimates is . Its diagonal gives the displayed standard errors; their ratios are , with mm.
The final line of summary(model2.lm) is the joint nested-model F-test of , comparing this four-parameter model with a common mean. Its statistic is
with F-distribution under the fixed-model null and P-value . Thus the selected paper-design terms jointly improve the fit substantially. The coefficient of determination means they account for about of the observed centred variation. These nominal inferential summaries do not adjust for the preceding model selection on the same data.
Using the unrounded fitted means gives
in millimetres. Hence choose the high-performance design with the lighter paper; the fitted model leaves both launch angles tied, with expected distance about mm. A preference for one angle is not supported by this selected model. The strong paper-design interaction reverses the design comparison: the simple design is better on heavy paper, whereas the high-performance design is better on light paper. Consequently a single design effect averaged over paper types would conceal the main result. There is little evidence here for an angle effect, and considerable flight-to-flight variability remains.
Before fitting, inspect raw-distance dot plots for all eight factor combinations, and interaction plots of cell means against design, with separate lines for paper and panels for angle. With only two replicates per cell, showing individual observations is more informative than elaborate box plots. These reveal reversals, spread and possible unusual flights. Afterwards inspect a residual-versus-fitted plot, a Q-Q plot of residuals, a scale-location plot, residuals against each factor and, if recorded, flight order, and Cook's distance for influential observations. Residual patterns by angle would question its deletion, while unequal spread or departures from the normal distribution would question the error assumptions rather than merely demand another mean term.
Let be the premium at age , gender , policy , and points , for the combinations actually observed. The additive normal linear model is
Its corner-point constraints are . Thus is the reference-category mean; the other coefficients are additive contrasts. The model assumes a common variance and excludes all interactions. It has estimable mean parameters and residual degrees of freedom. The variance estimate is
Let for and . The new normal linear model allows an age-by-policy interaction:
The corner-point constraints are and . Compared with the six-parameter reduced additive model, there are two additional interaction coefficients. Its F-test gives
Thus the interaction model significantly improves the reduced additive model. Estimated premiums decrease with age. Men have an estimated premium higher than women at fixed other characteristics, and 9 points adds relative to 0, 3, or 6. Comprehensive cover costs more than third-party cover, but its increment depends on age: at 21, at 30, and at 40. These are model-based comparisons, including extrapolations into the unobserved age-gender combinations.
For a 40-year-old woman with comprehensive cover and 6 points, the gender and points contrasts vanish. The fitted premium is
The second Poisson exposure model allows each location its own baseline accident rate:
The last equality is the corner-point constraint. The common after-to-before incidence rate ratio remains . This model is appropriate because the sites can have different background risks; treating those differences as unexplained Poisson variation made the first model fit poorly, with deviance on 14 residual degrees of freedom.
Adding seven location effects to the first fitted model reduces the deviance by , which is large relative to . The supplied sequential analysis of deviance reports a slightly different location contribution because it enters locations before the period indicator. The full model is much better but its deviance on 7 degrees of freedom still gives an approximate goodness-of-fit -value . That suggests residual lack of fit or overdispersion, although sparse accident counts make the asymptotic deviance goodness-of-fit test approximate.
Write . Apart from a constant, the log-likelihood is
For each group,
Thus maximum likelihood estimation sets . The corner-point constraint identifies , giving
The baseline mean is the first group mean, rather than the grand mean, because of the chosen identifiability constraint.
Index chocolate by , day by in the three observed categories, and replicate by . The additive two-factor normal linear model is
Here is the board count, is the mean for the reference chocolate and reference day, and are chocolate and day fixed effects. With corner-point constraints, set and , where is the first level in the day factor. The printed coefficient-free output does not determine that factor ordering; the model is unchanged by a different reference category. There is no chocolate–day interaction term in this fit. The six free mean statistical parameters consist of one baseline, three chocolate contrasts and two day contrasts; the common error variance supplies a further statistical parameter.