This is an analysis of covariance: achievement is the response, aptitude is a quantitative covariate, and teaching method is a categorical explanatory variable. The usual normal linear model assumes independent errors with common variance .
read.table reads the data with a header row; attach makes its columns directly accessible, and the two printed vectors confirm their ordering. rep(1:3, each=7) supplies the three group labels, and factor makes them categorical. The contrast option selects treatment coding for unordered factors, with method A as the first-level reference. The polynomial option would apply to ordered factors and has no role here.
The formula using aptitude * Group includes both main effects and their interaction. Writing for the method indicators, its fitted mean has the form
Thus A, B and C have separate intercepts and slopes. There are six coefficients and residual statistical degrees of freedom. The analysis of variance table uses sequential sums of squares: adding aptitude to an intercept-only model removes from the residual sum of squares; subsequently adding the two group indicators removes ; adding the two slope interactions removes only . The remaining sum of squares is , giving mean square .
Each displayed F-test divides the added term's sum of squares by its statistical degrees of freedom and then by this full-model residual mean square. In particular the interaction test is
There is no evidence that the slopes differ, so the common-slope model is preferable among the fitted models. The small group -value concerns differences after including aptitude, whereas the first aptitude row is sequential and does not adjust for Group. It should not be interpreted as the covariate test after treatment adjustment.
The additive formula gives the parallel-lines model
It has four coefficients and residual statistical degrees of freedom. Removing the interaction raises the residual sum of squares to , but lowers the residual mean square to . The sequential aptitude and group sums of squares are unchanged. The adjusted group test is now on statistical degrees of freedom, with : after allowing for initial aptitude, the methods are not all equally effective.
summary(..., cor=F) displays the fitted coefficients, their standard errors, the individual statistics, and two-sided -values; it omits the coefficient-correlation matrix. The intercept is the fitted A mean at aptitude zero, which is outside the observed range and is mainly a parametrization device. The common slope predicts about extra achievement units per aptitude unit, holding method fixed. Its adjusted test is on statistical degrees of freedom, with about . The method coefficients are adjusted differences from A, not the B and C intercepts themselves. The three fitted lines are
The B-minus-A estimate is with standard error and ; the C-minus-A estimate is with standard error and . Both comparisons are strongly significant.
The B-minus-C comparison needs its own treatment contrast; its significance cannot be read off either comparison with A. Reconstructing the coefficient covariance from the design gives
Thus there is no detectable difference between B and C. This is consistent with pooling their effects in a further reduced model, but does not establish exact equality.
The residual standard error is . The five-number residual summary shows deviations on both sides of zero, with the largest magnitude about ; it does not by itself verify constant variance or normality. The coefficient of determination means about of the achievement variation about its overall mean is explained. The overall compares all three nonintercept coefficients with zero, on statistical degrees of freedom; its -value is . Printed coefficient -values rounded to 0.0000 are small, not literally zero.
The following original sketch shows the separate-slope model and the preferred parallel-line fit.
Figure 1.
Observed teaching scores and separate-slope versus common-slope fitted models
. Details.
At the same initial aptitude, B and C give higher predicted achievement than A, with no convincing difference between B and C. Interpreting this adjusted association as a causal teaching effect additionally relies on the experimental allocation and error assumptions.