Use the normal linear model , with fixed full-column-rank design matrix , independent errors , and . Its log-likelihood is
For fixed , differentiating with respect to gives . Since is positive-definite, the unique least-squares estimate is
Let . The variance score equation is , giving
This is the maximum-likelihood estimator, whereas the residual standard error reported by linear-regression software is . The latter uses the unbiased residual estimate of Gaussian noise variance. These formulas assume and positive RSS; exact interpolation gives a variance-boundary degeneracy rather than an interior maximum.
In an R formula, I(...) protects ordinary arithmetic from the formula operators: the predictor is the numerical variable , rather than an instruction to remove a formula term. Predictor centering leaves fitted values and the height slope unchanged but places the intercept at a meaningful height. It often reduces the correlation between intercept and slope estimates.
With , treatment contrasts use female as the reference level in a regression factor. The fitted normal linear model is
The estimates and their standard errors are
The intercept estimates female mean weight at height 165. At that same height the male fitted mean is . Holding height fixed, the fitted male mean exceeds the female mean by 4.3294 weight units. Within either sex, one additional height unit increases fitted mean weight by 0.6211 weight units. If height is in centimetres and weight in kilograms, these interpretations use centimetres and kilograms accordingly. A standard error for the male intercept would require the covariance between and , which is not printed.
The prediction equation is . Predictions for individual students also have residual uncertainty, estimated by , beyond uncertainty in the fitted mean.
The additive model gives useful evidence for both predictors. To test for no adjusted sex effect, use against . The statistic has a Student t-distribution with 97 statistical degrees of freedom under the normal linear model and the null hypothesis. Here and . Similarly, against a nonzero common slope gives under the null hypothesis, with . Thus, at a fixed height males have a higher fitted mean weight, and within sex greater height is associated with greater weight.
The interaction model adds . Its female height slope is and its male height slope is . Test against using under the null hypothesis, or equivalently . The -value is 0.73139. The additive model is a reasonable parsimonious choice; the data give no evidence for different height slopes between sexes. This does not establish exact equality of population slopes. The additive model also has the higher adjusted coefficient of determination, 0.405 versus 0.3996, and a slightly smaller residual standard error.
Ignoring sex gives a height slope of 0.8769, appreciably above the adjusted slope 0.6211. This is omitted-variable bias in the descriptive regression: a taller group with a larger intercept makes the pooled height association steeper. Algebraically, with ,
The printed estimates imply a positive height-sex covariance. Pooled and adjusted slopes therefore describe different comparisons; the difference is not evidence that adding sex changed a physical effect of height. For predictions, retain both sex and height, check regression diagnostics, and assess performance on new students. The residual standard error near 5.7 remains substantial and the coefficient of determination near 0.42 does not promise precise individual prediction.
A regression factor is a categorical predictor represented by level indicators and contrasts. Treating year as a regression factor permits arbitrary differences between the three yearly means, reflecting conditions such as weather, rather than imposing a linear time trend.
Let be the yield for seed variety , fertiliser level , and year . A treatment-coded two-factor normal linear model with additive year effects is
with independent errors. The unrestricted coefficients are : six parameters for twelve observations. Equivalently use baseline-zero variety, fertiliser, and interaction arrays. There are no year-treatment interactions in this fit.
Dividing each sum of squares by its statistical degrees of freedom gives the completed analysis of variance:
In particular, the missing interaction statistic is . Its null hypothesis is , against : the change in mean yield from high fertiliser is the same for both varieties. Under the null hypothesis and the independent homoscedastic normal linear model, this nested-model F-test has distribution . The printed -value 0.001137 strongly rejects no interaction.
Do not drop fertiliser just because its main-effect ANOVA row has . In this balanced factorial design that row measures a fertiliser effect averaged over varieties; large opposite effects can cancel. The strongly supported interaction requires retaining its associated main effects by regression model hierarchy. Seed and year also have evidence of effects in their ANOVA rows, so this table alone gives no compelling simplification of the fitted terms.
The interaction contrast is , with standard error 0.7946. The fitted high-minus-low fertiliser effect is for variety 1 but for variety 2. The fitted variety-2-minus-variety-1 contrast is under low fertiliser and under high fertiliser. Thus variety 2 performs best under low fertiliser, while high fertiliser benefits variety 1 and reduces variety 2's fitted yield. The marginal fertiliser effect is only .
The four fitted means in the baseline year are for respectively. Add in 2005 and in 2006 to every fitted mean. The 2005 coefficient has under a test of a zero contrast with 2004; the analogous 2006 contrast has . The latter is lack of evidence for a difference, not proof that the yearly means coincide. Standard errors for the combined contrasts require the coefficient covariance matrix. The experiment is small: residual standard error is 0.6882 on only six statistical degrees of freedom. If the same fields were reused, possible within-field dependence and field allocation would need checking before treating the fitted error independence as established.
Let be the orthogonal projection onto the design column space. Linear transformations of the Gaussian errors give
The residual distribution is a singular multivariate normal supported on the orthogonal complement of that column space. Their cross-covariance is . Joint normality even makes the two vectors independent.
Order the observations as . The two normal linear models have design matrices
Removing each row mean leaves the information for the common slope equal to the sum of within-row squared fertilizer deviations. These sums are and , respectively. Therefore
The second design estimates the slope four times as precisely in variance terms.
The observed data in the second design are fitted exactly by . With , the no-fertilizer total forecast is
The future four independent errors contribute variance . Parameter-estimation uncertainty contributes , so the prediction-error variance is , not merely the variance of the estimated mean. Normally, with , the prediction interval in a normal linear model is
Here the printed data have zero residual and hence . The formal plug-in interval collapses to , exhibiting zero-residual degeneracy of regression prediction. Under the stated model with unknown positive variance, this exact fit is a probability-zero sample and the Studentized statistic is undefined at it; the collapsed expression is not evidence that future yield is certain. No positive-width numerical 95% interval can be obtained from these exact data by the usual residual-variance method without extra variance information or an explicit observation-rounding model.
Use the normal linear model
Here is the response random vector, is the known design matrix, contains the unknown regression coefficients, and is the common error variance. Conditional on , the errors have normal distributions and are independent random variables. Require for identifiability of and invertibility of . Usually is needed to estimate the error variance from the regression residuals. An intercept, when included, is represented by a column of ones in .
A natural next fit is quadratic regression, which remains a normal linear model in its unknown regression coefficients:
The new design matrix has rows and must have matrix rank three; three distinct predictor values suffice. The curved regression residual pattern suggests trying a positive quadratic term, but its sign and adequacy should be checked after fitting. Inspect the new regression residuals to see whether the systematic curvature has disappeared.
Test for both nonreference days, against at least one nonzero day fixed effect, conditional on chocolate. There are two added regression coefficients and residual statistical degrees of freedom. The nested-model F-test statistic is
Under and the normal linear model assumptions, . Its 5% upper critical value is , so do not reject the absence of day effects; the p-value is approximately . Thus the missing row has two statistical degrees of freedom, mean square , and the F-test value above. These observations do not provide evidence that including day improves the chocolate-adjusted mean model. They do not prove that every possible day effect or chocolate–day interaction term is absent.
The analysis of variance provides evidence of a chocolate effect both with day included (, p-value ) and with day omitted (, p-value ). Because every chocolate–day cell has the same replication, balanced factorial orthogonality separates the two main effects; the chocolate row is meaningful despite being entered first.
The chocolate-only fitted group means are approximately boards for A, B, C, D respectively. Thus A has the largest fitted lecturing speed and C the smallest. Relative to A, the fitted differences are boards. The printed individual Student t-tests give strong evidence for the A–C contrast (p-value ); B and D versus A have p-values and , respectively. Those latter contrasts are not significant at 5%, and the output does not test all other pairwise comparisons. Simultaneous claims would require accounting for multiple hypothesis testing.
There is little evidence of a day effect after adjusting for chocolate. A chocolate-only normal linear model is therefore a reasonable simpler summary, with residual standard deviation about boards and explained variation . This is an association under the additive statistical model; a causal claim would additionally require an appropriate assignment of chocolate and checks of the regression residuals and possible interaction terms.
With the same squared-error normalization as in Question 2, the ridge estimator solves
The unpenalized intercept in ridge regression is because the columns of are centered. Differentiating the remaining quadratic objective gives . Since , the left matrix is positive definite even when is rank-deficient. Thus the closed-form ridge regression estimator is
The second equality again uses centering. If the penalty convention is with an unnormalized squared-error term , replace by throughout; the limiting assertion is unchanged.
For the full-column-rank case, take a singular value decomposition with positive singular values . The ordinary least squares estimator, which is the slope maximum-likelihood estimator in this normal linear model, and the ridge regression estimator are respectively
Consequently principal-component shrinkage by ridge regression multiplies the least-squares coordinate in direction by . Ridge shrinks most strongly in directions with the smallest singular values. These are combinations of predictors that the data distinguish least well.
Near multicollinearity creates small singular values, and the factor in ordinary least squares greatly amplifies noise in those directions. Its coefficient variance there is , while the ridge variance is
which is smaller. The price is bias: the expectation of the ridge coordinate is times the corresponding true coefficient. This bias-variance tradeoff can substantially reduce estimation and prediction error when the poorly identified directions do not contain an excessively large signal. It is not a guarantee of improvement for every coefficient vector. Adding to every eigenvalue also improves the condition number of the normal matrix and makes numerical inversion more stable.
To handle every rank and every relation between and , put and use its spectral theorem for real symmetric matrices. Choose an orthonormal eigenbasis with eigenvalues , and put . Then
If , then , so and . Thus these terms are exactly zero for every positive ; there is no divergent component in the null space. Each remaining term converges to . By the definition of the Moore-Penrose pseudoinverse,
and therefore
This proves the vanishing-penalty ridge limit without an invertibility assumption. The limit is the minimum-norm least-squares solution: every other least-squares solution differs by a vector in , orthogonal to the displayed solution, and therefore has at least as large a Euclidean norm.
Under the usual normal linear model for independent orchard means with common error variance, the treatment ratios have null F-distributions with denominator six statistical degrees of freedom. Their upper-tail P-values are approximately
Use the unrounded ratios when evaluating these P-values. Thus none of spray, pruning or their interaction term is significant at a 5% significance level. Spray gives modest evidence if a 10% significance level was chosen in advance, but this is not strong evidence.
Failure to reject does not establish absence of treatment effects. Only two orchards per combination and six residual statistical degrees of freedom leave considerable uncertainty and potentially low statistical power. The table alone cannot give the direction or magnitude of individual effects: that requires treatment means. These model-based F-tests also rely on appropriate orchard allocation and comparable residual variation; they should not be interpreted as unconditional conclusions from the table alone.
For the normal linear model, differentiating the ordinary least squares objective gives . Full column rank makes invertible, so
The distribution follows because is a linear transformation of a multivariate normal distribution. Its expectation is , and direct multiplication gives the displayed covariance matrix.
Let , the orthogonal projection onto the design's column space. The residual sum of squares is . Since , symmetry and idempotence give . Thus
is an unbiased estimator.
For the two independent regressions choose . The first rows of the design matrix are and the last rows are . The centering conditions and distinct predictors give
It follows that
The two estimated slopes are independent normal random variables, as they depend on independent error blocks. Therefore
For these data use the pooled residual sum of squares
Its scaled value is and is independent of the slope estimates by the permitted normal-model result. Hence the standardized difference has a Student t-distribution with degrees of freedom, giving the exact 95 percent confidence interval
Here is the 0.975 quantile of that distribution. This is a confidence interval for the difference of independent regression slopes. As required by the original framework, this specialization needs . Distinct predictors alone allow , but then the fit is saturated, and there are no residual degrees of freedom to estimate the unknown variance or form this interval.
For the normal linear model, the log-likelihood is
The full column rank of the design matrix makes invertible. Differentiating in gives the normal equations . With the minimized residual sum of squares substituted, differentiation in gives
These are the maximum-likelihood estimators almost surely; almost surely when and . The linear transformation of the multivariate normal distribution yields
Define the hat matrix . The fitted values are , the regression residuals are , and . The orthogonal projection has rank and annihilates . By Cochran's theorem,
Consequently , with bias . The unbiased estimator is
Its square root, the reported residual standard error, estimates ; the assertion of unbiasedness applies to the variance, not generally to its square root.
For the paper-strength analysis, let be the measured percentage and . Both normal linear models use independent errors of common variance . Their mean functions are for lm1, and for lm2, with separately fitted coefficients. The reported residual standard errors are and , respectively.
For lm1, the estimated conditional expectation at a new percentage is
The original data mean must be used for centering the new percentage; its numerical value is not supplied in the excerpt. Because , the two columns of this design matrix are orthogonal, and . Hence the coefficient standard errors in the output give
This estimates uncertainty in the mean. Predicting an individual future batch would additionally require the new-error variance, estimated by .
To compare the nested normal linear models, test against within the quadratic model. The Student t-test statistic is
Its two-sided p-value is . Equivalently is a partial F-test statistic with null distribution . Reject the linear restriction and prefer lm2 at the 5% level. Its residual spread is much smaller; the increase in the coefficient of determination from to supports the same conclusion, although the test is the relevant complexity-adjusted comparison.
For regression diagnostics, inspect regression residuals against fitted means and hardwood percentage for omitted curvature, a scale-location plot for nonconstant variance, and a quantile-quantile plot against the normal distribution for departures from the error assumption. Check unusual observations using regression leverage and Cook's distance, and examine residuals in collection or batch order if dependence is plausible. Independence and a common variance require substantive justification as well as these plots; a small p-value for a polynomial term does not itself check the error model.