Put , which is a positive-definite matrix by the full column-rank assumption. The ordinary least squares estimator is
For ridge regression use the criterion . Differentiating gives
If instead the squared-error term is normalized by , replace in this formula and the calculations below by . Only the scale of the tuning parameter changes.
As usual for this linear regression model, use zero-mean errors; more generally suffices. Since the columns are centred, , so the random centring term disappears from both estimators. Thus
Let . The bias and covariance matrix of the ridge regression estimator are
The bias-variance decomposition of mean squared error therefore represents directional risk by the quadratic forms
Their difference has the useful factorization
To check it, multiply on both sides by : the resulting matrix is .
The Cauchy-Schwarz inequality gives in the Loewner order. Therefore the middle matrix is positive-definite whenever . For example,
works, independently of the eigenvalues of . Since is invertible, the risk difference is strictly positive for every nonzero , in particular simultaneously for every unit . This proves uniform directional risk improvement by ridge regression. For the normalized-loss convention, take the displayed choice divided by .
For the final assertion, fix any and choose a unit eigenvector of with eigenvalue . Put and . Directly,
Choosing
makes the squared bias alone greater than , proving the required strict inequality. Thus unbounded directional risk of fixed ridge shrinkage is compatible with the existence of a beneficial signal-dependent small penalty: no fixed positive penalty uniformly improves risk over all possible signals.
The mean assumption matters if the printed covariance condition is read in isolation. With , , , and , the columns and response are still centred and , but the ordinary least squares risk is . Writing , the ridge regression risk is for every . Hence the standard zero-mean regression-error convention, or its stated orthogonality version, is necessary for the first risk comparison; covariance alone is insufficient.
The ordinary least squares objective has gradient . The normal equation therefore gives
The Gram matrix is a positive-definite matrix because has full column rank. More explicitly, for any ,
since . This proves that the displayed solution is the unique global minimum.
The fitted values are , where the hat matrix is
The inverse of the symmetric matrix is symmetric, so . Multiplication gives . Thus is the orthogonal projection onto the column space of the design matrix.
The regression residual vector is with . Consequently , , and the residual sum of squares is
By fitted-residual orthogonality, . Using , the cross-covariance matrix is
Both vectors are jointly normal, so they are also independent by independence of uncorrelated jointly normal variables. The zero covariance calculation itself only needs the common error variance and lack of error correlations.
For the first wind fit, let be wind velocity and electrical output. The simple linear regression is , with independent . It has two fitted mean parameters and residual degrees of freedom. The missing analysis of variance entries are therefore velocity degrees of freedom , velocity mean square , and residual degrees of freedom . The residual mean square is , and , consistent with the printed value after rounding.
Because the model includes a regression intercept, the coefficient of determination is the explained sum of squares divided by the total centered sum of squares:
A large coefficient of determination does not rule out a wrong mean function. In the PDF's first residual-versus-fitted plot, residuals are negative at both ends and positive in the middle. This curved pattern agrees with the visibly flattening output-versus-velocity relationship and motivates a polynomial regression with a quadratic term.
The second wind model is , again with independent common-variance normal errors. Its fitted mean is . The line marked (A) is a two-sided Student t-test of against , conditional on retaining the intercept and linear term. Under the null hypothesis,
Its two-sided p-value is . This is far below , so reject a purely linear mean in favour of the quadratic fit. Equivalently, the extra-term nested-model F-test has and null law .
The third fit is a reciprocal-predictor regression, , with estimated mean . It has two mean parameters rather than the quadratic model's three. Its residual standard error is smaller, versus , and its coefficient of determination is larger, versus . The corresponding residual sums of squares are approximately and . The reciprocal fit is preferable on both these fit measures and parsimony. The two models are not nested, so an ordinary extra-term F-test between them is inappropriate. On the common normal-error likelihood, the difference also favours the third model.
Neither lower residual sum of squares nor a higher coefficient of determination establishes adequate assumptions. The quadratic residual-versus-fitted plot removes the original pronounced curvature; the reciprocal plot also has no comparably obvious mean trend. The low-output residuals appear somewhat more spread out, so check scale-location plots and residuals against velocity for heteroscedasticity. Q-Q plots assess normality; residuals against observation order assess serial dependence; regression leverage and Cook's distance identify influential observations. Further cross-validation, replicate observations at comparable velocities, and prediction errors would help choose between their extrapolation behaviours. Both fitted shapes should be judged principally over the observed positive-velocity range.
Use an unpenalized intercept in ridge regression. For centered predictor columns, the ridge regression optimization is
Differentiating with respect to gives . Put . Differentiation with respect to gives the ridge normal equation
Consequently the closed-form ridge regression estimator is
Because , the numerator may also be written . For the inverse exists even with multicollinearity or deficient column rank; at a unique ordinary least squares coefficient vector requires full rank. The quadratic penalty stabilizes nearly singular directions but generally does not set individual coefficients exactly to zero.
For uncentered original predictors, use , apply the displayed estimator to , and recover . Any internal scaling used by lm.ridge must be undone to report coefficients on the original predictor scale. Multiplying the objective by a constant changes the numerical penalty convention unless is rescaled as well.
The statistician first models the age- and gender-dependent mean by linear regression. Its fitted value is . At fixed gender, a year of age is associated with a decrease of BMI units; the group coded gender has a fitted mean units above the group coded at the same age. This question does not state which gender receives which code. The intercept refers to age zero in the reference group, outside a typical adult-patient range, so its substantive interpretation is limited. Both slope Student t-tests have small p-values, and the overall F-test supports an age/gender-dependent mean. The coefficient of determination is only , leaving considerable individual variation to investigate.
The residual diagnostics check whether mean adjustment is plausible and whether a single normal error law is adequate. The residual-versus-fitted plot has no strong curved mean trend, although its smooth curve is not perfectly flat. The scale-location plot suggests some decline in spread as fitted BMI increases, so common residual variance is a working approximation rather than an established fact. The normal Q-Q plot has systematic departures, notably shorter tails than the normal reference, suggesting the residual law is not exactly normal. The regression leverage plot does not display an obviously extreme leverage point, but the marked observations and Cook's distance should still be checked for influence. Independence between patients cannot be diagnosed from these four plots alone.
Next the statistician extracts the regression residuals and fits an intercept-only normal model as a baseline residual distribution. With an intercept in the original ordinary least squares model, the residuals sum to zero by the normal equation; the near-zero fitted residual mean and its are therefore automatic, not new evidence of good fit. The standard error in this refit uses degrees of freedom, whereas the original uses after estimating three regression coefficients. The reported log-likelihood for the single-normal residual model is .
The histogram suggests a shape worth exploring beyond one normal density, with broad shoulders and some asymmetry, without showing unambiguous separated clusters. The statistician fits two- and three-component finite Gaussian mixtures with a common variance by the expectation-maximization algorithm, starting from separated means and positive weights. Successive likelihoods increase and the displayed final iterations stabilize, as expected from EM likelihood monotonicity. This is evidence of numerical convergence from those starts, not proof of a global maximum.
The two-component fit assigns weights , residual means and common variance . The three-component fit assigns weights , residual means and common variance . The code correctly passes the square roots of those variances to dnorm and overlays the resulting weighted densities. Both curves broadly follow the histogram and are very similar. In particular, a two-component mixture need not have two distinct visible modes.
These fits explore residual mixture clustering: groups differ in BMI relative to the same age/gender-adjusted mean, rather than simply in raw BMI. Membership can be summarized by the fitted mixture responsibilities, retaining uncertainty instead of asserting a certain label for each patient. The common-variance assumption is economical, but should be checked; the common regression slope assumption and constancy of mixture proportions across age and gender are also substantive. A residual mixture alone does not establish genuine biological subpopulations; a flexible continuous distribution, missing predictors, nonlinear mean effects or heteroscedasticity could explain a similar marginal shape.
There is also a two-stage residual mixture fitting limitation. Fitted regression residuals are not exactly independent identically distributed observations: even under a normal regression, their covariance matrix is , and estimating the mean adjustment introduces uncertainty. With subjects and three initial regression coefficients, treating them as independent is a useful approximation for exploring shape, but ordinary mixture likelihoods omit the first-stage uncertainty. A joint mixture regression with shared slopes, or a suitable bootstrap of the whole analysis, would give a firmer basis for parameter uncertainty and cluster selection. Examine component membership versus age/gender and repeat the algorithm from multiple starts before making substantive clustering claims.
The useful autoregressive model is for the squares, not for signed observations. Put and
Then
The errors form a martingale difference sequence relative to the noise history, because the current standardized noise is independent of the past. When the fourth moment is finite they have finite variance and are uncorrelated across distinct times, although their conditional variance depends on the regressor. In centered form, .
For ordinary least squares, use the response-regressor pairs , , . With their separate means and , minimize . If the regressor sum of squares is positive, the estimators are
The two means use the matched pairs; replacing them indiscriminately by a single full-sample mean is not the exact least-squares formula. The noise-series representation supplies an ergodic stationary process. If , finite regressor second moments and the error's zero conditional expectation justify the usual population regression and statistical consistency argument. The observations still define a finite-sample least-squares fit outside that moment range, but the ordinary finite-variance justification must not be claimed there. If parameter constraints are required, minimize the same criterion subject to and , rather than assert that unconstrained estimates automatically satisfy them.
The command fits the simple linear regression
using ordinary least squares. The fitted conditional mean is a straight line in time. The regression residuals are mainly positive at the beginning and end and negative in the middle, so the mean function needs curvature.
A direct improvement is polynomial regression of degree two:
fit2 <- lm(Counts ~ Time + I(Time^2), data = geiger)
anova(fit1, fit2)
The nested-model F-test tests against a nonzero quadratic coefficient. If measurements were used, its statistic is
A small reported -value supports the quadratic term. The new regression residuals should then be checked for remaining systematic structure, changing variance and temporal dependence, because the F-test assumes independent errors of common variance. Radioactive decay also motivates an exponential mean, but the displayed curvature already justifies this simple nested comparison.
The Gaussian likelihood has log-likelihood, apart from no omitted parameter-dependent terms,
For fixed , maximizing it is ordinary least squares. Differentiating with respect to gives the normal equation . Full column rank makes the quadratic strictly convex, so
At this value, differentiating with respect to gives , so
For positive RSS this is the global likelihood maximum in . RSS is positive almost surely under the model since ; an exactly zero observed RSS instead gives a boundary supremum as .
As a linear image of a multivariate normal vector, the coefficient estimate satisfies
Indeed, , and direct matrix multiplication gives its covariance matrix.
Assume the known covariance matrix is positive definite. The Gaussian likelihood, up to constants, is
Its gradient is . The negative Hessian matrix is positive definite because has full column rank. Thus the unique maximum-likelihood estimator is the generalized least squares estimator
It is unbiased, and multiplication of its linear coefficient matrix by gives
In fact . Equivalently, a whitening transformation premultiplies and by , after which ordinary least squares applies. There is no extra factor when is the complete known covariance; such a factor appears if only a shape matrix is known and .
Assume initially that the design points are distinct and ordered on . The cubic smoothing spline minimizes
over functions with an absolutely continuous first derivative and square-integrable second derivative. Dividing the residual term by simply changes the scaling assigned to . The minimum roughness property of the natural cubic spline interpolant reduces the problem to natural cubic splines with knots at the design points: among functions with any prescribed fitted values, that interpolant has the smallest integrated squared curvature. The minimizer is therefore a natural cubic smoothing spline, with natural second-derivative boundary conditions and linear tails when extended.
Choose a full basis for this natural-spline space. Put and . Writing changes the objective to
Differentiation gives . Although the curvature penalty has an affine nullspace, the full basis at distinct design points makes the combined matrix positive definite. Hence
Equivalently, use the cardinal basis that interpolates the observations, making and . These are smoothing matrices, symmetric but generally not idempotent. Their effective degrees of freedom are . As the fit interpolates; as it approaches ordinary least squares on the affine functions. With replicated predictors, use a design matrix for distinct knots and observation weights; the basis form remains valid when identifiable.
Useful choices include Leave-one-out cross-validation, generalized cross-validation, and estimation of smoothness by restricted maximum likelihood through a mixed-model representation. For fixed , the leave-one-out residual identity for a linear smoother gives
Minimize these over a suitable range. Choose smoothing by predictive performance or a variance-component likelihood, not by arbitrarily forcing a visually appealing curve.
Use the usual normalization that is mean-zero unit-variance white noise orthogonal to the past, and extend periodically in . A nondegenerate causal periodic autoregressive model of order one requires . Write , with season indices understood modulo .
For , multiply the recursion by and use orthogonality of the current innovation to the past. The periodic Yule-Walker equations are
At lag zero, expansion of the squared recursion gives
In particular, , so an equivalent variance equation is . Negative lags are obtained from the given symmetry .
Replacing covariances by their sample versions gives
Take the nonnegative scale and require a positive estimated predecessor variance. Using matched seasonal sample covariance matrices makes the quantity under the square root nonnegative by Cauchy-Schwarz inequality; with unmatched covariance estimates one can instead fit seasonal ordinary least squares and use the nonnegative residual variance. Statistical consistency of the covariance estimates gives statistical consistency of these plug-in estimators. If the driving noise variance were not normalized to , the equations would identify , not the two scales separately.
The Gauss-Markov theorem states that with full-column-rank design, mean-zero errors and covariance , the ordinary least squares estimator is the best linear unbiased estimator: its covariance is no larger than any other such estimator's in the Loewner order. Normality is unnecessary for that theorem.
In the given normal linear model, maximizing the likelihood function is equivalent to minimizing . The normal equations and full rank give
For a direct variance comparison, write . Unbiasedness for every requires . Set and , so . The cross covariance terms vanish because . Therefore
This proves the requested comparison for every contrast without relying only on the theorem's name.
Choose knots independently of the eventual validation responses, and let be a natural cubic spline basis as in part (a). A regression spline writes . Define the design matrix . Under the stated normal linear model, maximum likelihood estimation for is the same as ordinary least squares:
Differentiation gives the normal equations . If the design has full column rank,
If it does not, a Moore-Penrose inverse gives the fitted values, but not every coefficient or off-sample prediction is identifiable. Merely choosing distinct knots does not guarantee full rank for an arbitrary set of observed predictor values.
More knots allow greater curvature and reduce approximation bias at the cost of larger estimation variance. Too many or poorly located knots can cause unstable fits. Equally spaced knots are simple; empirical predictor quantiles put more flexibility where observations are dense; subject knowledge can concentrate knots near likely changes. Both the number and positions can be compared using cross-validation or an appropriate penalized model-selection criterion. Adaptive knot selection must be included within validation, since treating a data-selected basis as prespecified understates its flexibility. Boundary knots should cover the region where inference is intended, and natural linear tails do not by themselves justify far-out extrapolation.
For , minimize the smoothing spline objective over the Sobolev space of functions with square-integrable second derivative on the observed interval:
The roughness penalty measures curvature; its null space consists of affine functions. To see why the minimizer is a natural cubic spline, let be the natural spline interpolating the values of any competitor at its distinct observation locations, and put . Integration by parts twice on each knot interval gives : on each interval, vanishes at the knots, is continuous, and vanishes at the outer endpoints. Hence
while both functions have the same residual sum of squares. This proves the reduction to a finite-dimensional spline space.
For distinct and , use its -dimensional basis, write , and define the positive semidefinite matrix
The penalized least squares problem is , so
Use linear continuation outside the observation interval. The fitted-value matrix is ; its trace gives the effective degrees of freedom. As decreases to zero, the natural spline approaches interpolation, with trace ; as it grows without bound, the fit approaches ordinary least squares on , with trace two. For the criterion alone does not determine values between observations; the natural interpolant is the limiting convention. Repeated observation locations are combined by using distinct knots and their multiplicities as weights, rather than pretending the spline design has independent interpolation values.
Ignoring the bounded second-order remainder, this is the linear regression model
The ordinary least squares estimate through the known zero intercept is
because . This is the randomized symmetric finite-difference derivative estimator.
Use the shape-rate convention for the Gamma distribution. Define
The zero null space assumption makes a positive-definite matrix, and is the unique ordinary least squares solution. The Gaussian likelihood contributes , which must be retained because is unknown. Multiplying it by the improper prior and the Gamma distribution gives the normal-gamma posterior with a flat prior:
Here the constant density of the improper prior cancels on normalization. Put
The normal equation makes the residual orthogonal to the range of . The orthogonal decomposition by a closed subspace into that range and its orthogonal complement gives
Integration over by the Gaussian integral, followed by integration over using the Gamma distribution, yields
Thus the posterior distribution is proper, despite the improper prior; here follows from the zero null space assumption.
Completing the square in and collecting the powers of give the two conditional distributions:
Explicitly their probability density functions are
For a joint maximum a posteriori estimate relative to , first fix . The unique maximizing is . The remaining log density is plus a constant. Consequently, if ,
The stated assumptions do not always imply . If , the supremum occurs as but is not attained on ; if , the density is unbounded there. In either case there is no joint maximum a posteriori estimate in the stated parameter space. Calling zero a boundary mode does not make it an admissible positive precision.
If “MAP estimators” instead means separate modes of the marginal distributions, integration gives
Thus the marginal maximum a posteriori estimate of is always , and that of is when , with the same nonattainment at zero when . Joint and marginal maximization are different operations; the usual joint interpretation gives the preceding boxed pair.
The Gaussian likelihood is proportional to
so maximum likelihood estimation is equivalent to ordinary least squares. If and has rank , then is invertible and the normal equations give
If , then and . A least-squares minimizer always exists, but it is not unique: by rank-deficient ordinary least squares, the complete set is
an affine subspace of dimension . Thus there are uncountably infinitely many likelihood maximizers. In the generic full-row-rank case their dimension is .
Because has full column rank, is invertible. The ordinary least squares estimator is
It satisfies the normal equations
so the residual is orthogonal to the column space of . For any ,
The two terms are orthogonal, and the Pythagorean theorem in an inner-product space gives
Thus minimizes the least-squares objective.
For the normal linear model, the Gaussian likelihood gives
Maximization over gives the ordinary least squares estimator , and maximization over the variance gives
At this value the quadratic term in is . There are regression coefficients and one variance parameter, so substitution into the Akaike information criterion yields
The ordinary least squares equations for model 2 are
For the Gamma generalized linear model, and , so its score equation under the logarithmic link is
When is close to ,
by the first-order Taylor expansion of the exponential function. The Gamma score equations then become the model-2 normal equations, so their coefficient estimates are close.