Tutorials › Regression Analysis (Undergraduate) › Influence Calculations in Simple Regression

Leverage and Influential Observations · Tutorial 561 of 991

Influence Calculations in Simple Regression

Calculate and interpret several influence diagnostics by hand for a simple regression, then see how deleting a selected case changes the fitted coefficients.

Intermediate 9 min read

What You'll Learn

  • Calculate each observation’s leverage from its predictor value and the sample’s predictor spread.
  • Compute internally and externally studentized residuals for selected cases.
  • Find Cook’s distance using residual size and leverage.
  • Compare full-data regression coefficients with coefficients after deleting a case.
  • Distinguish diagnostic calculations from decisions about whether an observation should be removed.

Why Work Through Influence Calculations?

Influence diagnostics combine information about how unusual a response is and how unusual its predictor value is. Working through the calculations in a small simple regression makes that combination concrete: a case can have high leverage without a large residual, or a large residual without high leverage. Neither feature alone tells the whole story.

This tutorial uses one hypothetical dataset throughout. The calculations show what each diagnostic measures and how removing a case can change a fitted line. They are tools for investigating sensitivity, not automatic rules for deleting observations.

Model and Notation

Suppose \(n\) cases have predictor values \(x_i\) and responses \(y_i\). The simple linear regression model is

$$ Y_i=\beta_0+\beta_1x_i+\varepsilon_i,\qquad i=1,\ldots,n. $$

For the usual regression calculations, assume the errors are independent, have mean zero and constant variance \(\sigma^2\), and the mean response is linear in \(x_i\). Normal errors are additionally needed for exact small-sample \(t\)-based inference, but the diagnostic quantities below can be calculated without treating a diagnostic flag as a formal hypothesis test. The predictor values are treated as fixed for these calculations.

Write \(\hat{y}_i=\hat{\beta}_0+\hat{\beta}_1x_i\) for the fitted response and \(e_i=y_i-\hat{y}_i\) for the residual. In simple regression with an intercept, the residual degrees of freedom are \(n-2\), and the residual mean square is \(s^2=\sum e_i^2/(n-2)\). The \(s\) here estimates the error standard deviation.

Definition: The leverage \(h_{ii}\) measures how unusual case \(i\)'s predictor value is relative to the predictor values in the dataset. In simple linear regression with an intercept, $$ h_{ii}=\frac{1}{n}+\frac{(x_i-\bar{x})^2}{\sum_{j=1}^{n}(x_j-\bar{x})^2}. $$ Leverage depends on the predictor values, not on the observed responses.

The leverage values in a simple regression with an intercept sum to 2, corresponding to the two fitted coefficients, \(\hat{\beta}_0\) and \(\hat{\beta}_1\). A case far from \(\bar{x}\) has greater leverage than one near \(\bar{x}\). Leverage indicates potential to affect the fitted line; it does not by itself show that a case actually changes the fit substantially.

A Hypothetical Dataset and Its Leverages

Consider six hypothetical observations. The response is measured in arbitrary units. The values are constructed for illustration and are not from a real study.

Case\(x_i\)\(y_i\)
1010
2112
3214
4316
5418
6523

Worked Example: Calculating Leverage at the Predictor Extremes

For these six cases, \(\bar{x}=2.5\) and \(\sum(x_j-\bar{x})^2=17.5\). Case 6 has \(x_6=5\), so its leverage is

$$ h_{66}=\frac{1}{6}+\frac{(5-2.5)^2}{17.5} =\frac{1}{6}+\frac{6.25}{17.5} =\frac{11}{21}\approx 0.5238. $$

Case 1 is equally far from the predictor mean, so \(h_{11}=11/21\) as well. The other leverages are \(31/105\approx0.2952\) for cases 2 and 5, and \(19/105\approx0.1810\) for cases 3 and 4. They sum to 2, as expected. Cases 1 and 6 have the greatest leverage because their predictor values are at the extremes of this dataset.

Studentized Residuals and Cook’s Distance

A raw residual is measured in the response units, so its size is difficult to compare across settings. An internally studentized residual scales it by an estimate of its standard deviation, taking account of its leverage. For case \(i\), it is

$$ r_i=\frac{e_i}{s\sqrt{1-h_{ii}}}. $$

The factor \(\sqrt{1-h_{ii}}\) reflects that residuals at high-leverage cases tend to have smaller variance under the model. The internally studentized residual uses \(s\) calculated from the full dataset, including case \(i\).

An externally studentized deleted residual instead estimates the error scale after omitting case \(i\). Let \(s_{(i)}\) be the residual standard deviation from that reduced fit, with \(n-3\) residual degrees of freedom. Then

$$ t_i=\frac{e_i}{s_{(i)}\sqrt{1-h_{ii}}}. $$

The two residual measures are related but not interchangeable: the external version excludes the case when estimating the error scale. Both express a residual relative to its expected scale, rather than in the original response units.

Cook’s distance summarizes how much the fitted values change when case \(i\) is deleted. For simple regression with two fitted coefficients, one common equivalent calculation is

$$ D_i=\frac{e_i^2}{2s^2}\frac{h_{ii}}{(1-h_{ii})^2}. $$

Equivalently, it is the average squared change in fitted values over the \(n\) cases, divided by \(2s^2\). A larger value indicates greater change in the fitted line relative to the estimated residual variation. Its size is a diagnostic summary, not a probability or a direct test that the case is erroneous.

Worked Example: Studentizing a Residual and Calculating Cook’s Distance

First fit the line to all six observations. The sample means are \(\bar{x}=2.5\) and \(\bar{y}=15.5\), and the centered cross-product sum is \(\sum(x_i-\bar{x})(y_i-\bar{y})=42.5\). Therefore,

$$ \hat{\beta}_1=\frac{42.5}{17.5}=\frac{17}{7},\qquad \hat{\beta}_0=15.5-\frac{17}{7}(2.5)=\frac{66}{7}. $$

The fitted line is \(\hat{y}=66/7+(17/7)x\). At case 6, \(\hat{y}_6=151/7\), so \(e_6=23-151/7=10/7\). The residual sum of squares is \(30/7\), giving

$$ s^2=\frac{30/7}{6-2}=\frac{15}{14}. $$

Since \(h_{66}=11/21\), the internally studentized residual is

$$ r_6=\frac{10/7}{\sqrt{(15/14)(1-11/21)}} =\frac{10/7}{5/7}=2.000. $$

For Cook’s distance, substitute the same residual, residual mean square, and leverage:

$$ D_6=\frac{(10/7)^2}{2(15/14)} \frac{11/21}{(1-11/21)^2} =\frac{22}{21}\approx1.048. $$

Thus, case 6 has an internally studentized residual of 2 and a Cook’s distance of about 1.048. These values describe different aspects of the case: the studentized residual scales its response discrepancy, while Cook’s distance summarizes the effect of deletion on the fit.

Coefficient Changes After Deletion

A direct way to understand influence is to compare the full-data coefficients with the coefficients obtained after removing a case. Denote the reduced-fit coefficients by \(\hat{\beta}_{0(i)}\) and \(\hat{\beta}_{1(i)}\). For a simple regression with an intercept, the slope difference has the identity

$$ \hat{\beta}_1-\hat{\beta}_{1(i)} =\frac{(x_i-\bar{x})e_i}{S_{xx}(1-h_{ii})}, \qquad S_{xx}=\sum_{j=1}^{n}(x_j-\bar{x})^2. $$

The intercept difference can be obtained from the same deletion update:

$$ \hat{\beta}_0-\hat{\beta}_{0(i)} =\frac{e_i}{1-h_{ii}} \left(\frac{1}{n}-\frac{\bar{x}(x_i-\bar{x})}{S_{xx}}\right). $$

These expressions make the ingredients visible. A large residual can increase the coefficient changes, as can a predictor value far from its mean. The denominator \(1-h_{ii}\) also shows why deletion calculations become especially sensitive as leverage approaches 1.

Justification: In simple regression, the fitted slope is \(\sum_j(x_j-\bar{x})y_j/S_{xx}\). Removing case \(i\) changes both the predictor mean and the centered cross-products; simplifying that difference using the full-fit residual \(e_i=y_i-\hat{y}_i\) gives \(\hat{\beta}_1-\hat{\beta}_{1(i)}=(x_i-\bar{x})e_i/[S_{xx}(1-h_{ii})]\). The intercept identity follows by applying the same deletion update to the intercept, or by using the fitted-mean relation \(\hat{\beta}_0=\bar{y}-\hat{\beta}_1\bar{x}\). Thus the displayed changes are full-fit minus deleted-fit coefficients, with the sign indicating the direction of change.

Worked Example: Comparing the Full and Deleted Regression Lines

For case 6, \(x_6-\bar{x}=2.5\), \(e_6=10/7\), \(S_{xx}=17.5\), and \(1-h_{66}=10/21\). The full-minus-deleted slope difference is

$$ \hat{\beta}_1-\hat{\beta}_{1(6)} =\frac{(2.5)(10/7)}{(17.5)(10/21)} =\frac{3}{7}\approx0.4286. $$

Since the full-data slope is \(17/7\), the slope after deleting case 6 is \(17/7-3/7=2\). For the intercept,

$$ \hat{\beta}_0-\hat{\beta}_{0(6)} =\frac{10/7}{10/21} \left(\frac{1}{6}-\frac{(2.5)(2.5)}{17.5}\right) =3\left(\frac{1}{6}-\frac{5}{14}\right) =-\frac{4}{7}. $$

The full-data intercept is \(66/7\), so the deleted-fit intercept is \(66/7+4/7=10\). The reduced line is therefore \(\hat{y}_{(6)}=10+2x\). In this constructed dataset, the first five observations lie exactly on that line; including case 6 changes both the slope and intercept.

The coefficients have response units per predictor unit for the slope, and response units for the intercept. Here deletion changes the slope by \(3/7\) response units per predictor unit and the intercept by \(4/7\) response units from the full fit to the reduced fit.

Worked Example: External Studentization for the Same Case

The deletion identity for the residual sum of squares is

$$ SSE_{(i)}=SSE-\frac{e_i^2}{1-h_{ii}}. $$

For case 6, the full residual sum of squares is \(30/7\), and \(e_6^2/(1-h_{66})=(100/49)/(10/21)=30/7\). Thus \(SSE_{(6)}=0\) would seem to follow, but this conflicts with the actual reduced fit residuals: this calculation warrants checking the arithmetic. In fact, \(100/49\div(10/21)=210/49=30/7\), while the full \(SSE=30/7\); however, the first five points are exactly on a line, so their reduced SSE is indeed zero. The deleted-fit error estimate is zero, and an externally studentized residual is undefined for this case.

Reading the Calculations Carefully

The previous example highlights why a deleted residual scale needs care: when the remaining observations fit a line perfectly, \(s_{(i)}=0\), so the externally studentized deleted residual cannot be calculated as a finite value. A formula can be evaluated only when its ingredients are defined. This example also illustrates that an internally studentized residual and a coefficient change answer different questions, even when calculated for the same observation.

In practice, calculate values from the same full-data fit and keep track of which scale is being used. Leverage depends only on \(x\); residuals depend on \(x\) and \(y\); Cook’s distance combines residual size and leverage; coefficient changes report how a particular fitted coefficient shifts after deletion. Report the predictor and response units when describing the fitted coefficients, and state that a diagnostic concerns the model fit rather than establishing a cause for the observed response.

Common Mistake

Wrong reasoning: “Case 6 has high leverage, so it must be influential and should be removed.” High leverage alone measures unusualness in the predictor, not the case’s actual effect on the fitted line. A high-leverage observation can lie close to the fitted pattern and make little difference, while a case with a less extreme predictor value can have a substantial residual.

Correction: Consider leverage together with residual size and a measure of fit change, such as Cook’s distance or the coefficient changes. Then investigate the observation’s context and the purpose and assumptions of the model before deciding how to proceed. A flagged diagnostic is a prompt for scrutiny, not a deletion instruction.

Key takeaway: In simple regression, leverage is determined by the predictor values; studentized residuals scale response discrepancies; Cook’s distance summarizes changes in fitted values; and deleted-fit coefficient differences show changes in the line’s intercept and slope. Each calculation provides a different view of sensitivity.

Check Your Understanding

Use the definitions and calculations in this tutorial to answer the following.

  1. Why can two observations with identical predictor values have the same leverage but different residuals?
  2. In simple regression with an intercept, what is the sum of the leverage values, and what does that sum correspond to?
  3. Explain the difference between the error-scale estimate used in an internally studentized residual and the one used in an externally studentized deleted residual.
  4. What does a positive value of \(\hat{\beta}_1-\hat{\beta}_{1(i)}\) tell you about the full-data and deleted-fit slopes?
  5. Why is it incorrect to treat a large influence diagnostic as proof that an observation is a data error?