Tutorials › Regression Analysis (Undergraduate) › Substituting Predictor Values to Calculate a Fit

Building and Reading Model Terms · Tutorial 127 of 991

Substituting Predictor Values to Calculate a Fit

Practice evaluating an additive regression equation at a specified set of predictor values and reporting the fitted outcome with appropriate units.

Intermediate 8 min read

What You'll Learn

  • Identify the outcome, numeric predictors, and coefficients in an additive regression equation.
  • Substitute predictor values using the units and scale specified by the equation.
  • Evaluate the equation carefully and report the fitted outcome with its units.
  • Distinguish a fitted value from an observed outcome for an individual.
  • Recognize why using inconsistent units or an inapplicable equation can produce a misleading fit.

From an Equation to a Fitted Outcome

A regression equation can summarize how an outcome is represented in terms of several predictors. Once the equation and a set of predictor values are specified, a direct calculation gives the fitted outcome for that predictor profile. This calculation is useful when a question asks, for example, what outcome the equation predicts for a particular combination of age and body mass index, or for a particular combination of study time and attendance.

The calculation is algebraic: use the supplied value for each predictor in the corresponding place in the equation, then evaluate the expression. Care is needed because predictor units and values must match the equation, and the result is a fitted outcome, not a guarantee of what an individual’s observed outcome will be.

The Additive Equation and Its Fitted Value

Definition: An additive regression model with \(k\) numeric predictors represents an outcome \(Y\) as $$ Y_i=\beta_0+\beta_1X_{i1}+\beta_2X_{i2}+\cdots+\beta_kX_{ik}+\epsilon_i. $$ Here \(i\) identifies an observation, \(\beta_0\) is the intercept, \(\beta_j\) is the coefficient for predictor \(j\), and \(\epsilon_i\) is the unexplained part of the outcome. The additive form includes a separate term for each predictor and no products between predictors. The corresponding fitted equation uses estimated coefficients: $$ \hat{y}=\hat{\beta}_0+\hat{\beta}_1x_1+\hat{\beta}_2x_2+\cdots+\hat{\beta}_kx_k. $$ For specified predictor values \(x_1,\ldots,x_k\), the value \(\hat{y}\) is the fitted outcome from the equation.

The fitted equation is evaluated at a particular combination of predictor values. Its coefficients and predictor values must use the same units and coding as in the equation: if age was entered in years, substitute years rather than months; if a score was entered on a 0-to-100 scale, do not substitute a proportion between 0 and 1. The final fitted value is in the outcome’s units.

The equation is additive in its specified form: the predictors appear as separate terms added together. This means the calculation uses the equation as given, rather than adding an extra product or other term. The model’s fitted value is commonly used as an estimate of the conditional mean outcome for observations with that predictor profile. It is not the observed outcome for a particular person or object; an observed outcome can differ from its fitted value.

There are two related but distinct questions to keep in mind. How do we calculate the fitted value? Substitute values into the equation and do the arithmetic. How useful is that fitted value as a description or prediction? That depends on whether the equation is appropriate for the setting and whether the supplied values are within a range where its use is reasonable. Arithmetic alone cannot establish those conditions.

A Reliable Substitution Procedure

1
Identify the outcome and predictors.
Read the equation and identify which quantity is being fitted, the predictors it contains, and the units attached to each.
2
Match each value to its predictor.
Write down the specified values beside the correct predictor names. Check units and scales before substituting.
3
Substitute into the full equation.
Replace each predictor symbol with its supplied value, keeping every coefficient, sign, and term in place.
4
Evaluate and report.
Show the arithmetic, retain sensible precision during the calculation, and state the fitted outcome with its units.

In general, for two predictors, the calculation is

$$ \hat{y}=\hat{\beta}_0+\hat{\beta}_1x_1+\hat{\beta}_2x_2. $$

The values \(x_1\) and \(x_2\) are the requested predictor values, not coefficient estimates. The intercept is included unless the equation explicitly omits it. A useful check is to count the terms in the substituted expression: it should contain the intercept and one term for every predictor shown in the equation.

Worked Example: Fitted Exam Score for a Student Profile

Suppose a hypothetical additive regression equation fits exam score, measured in points, using weekly study hours and attendance percentage. The equation and predictor values are

$$ \widehat{\text{score}}=42+2.5(\text{study hours})+0.30(\text{attendance percentage}). $$

Calculate the fitted exam score for a student who studies 8 hours per week and has 90% attendance. The coefficient for attendance is defined per percentage point, so the value to substitute is 90, not 0.90. The study value is in hours, as required by the equation.

Substitute both specified values:

$$ \widehat{\text{score}}=42+2.5(8)+0.30(90). $$

Evaluate the terms and add:

$$ \widehat{\text{score}}=42+20+27=89. $$

The fitted exam score is 89 points. It is the outcome fitted by this equation for the stated predictor values. It does not establish that this student’s observed score will be exactly 89 points.

More Substitution Examples

Worked Example: Fitted Blood Pressure at Specified Values

Consider a hypothetical additive equation for systolic blood pressure, measured in millimeters of mercury (mmHg), using age in years and body mass index (BMI) in BMI units:

$$ \widehat{\text{blood pressure}}=88+0.65(\text{age})+1.1(\text{BMI}). $$

Find the fitted value for an age of 50 years and a BMI of 26. These values match the units used in the equation.

$$ \begin{aligned} \widehat{\text{blood pressure}}&=88+0.65(50)+1.1(26)\\ &=88+32.5+28.6\\ &=149.1\text{ mmHg}. \end{aligned} $$

The fitted blood pressure is 149.1 mmHg. This is the equation’s fitted value for those predictor values; it is not a measurement of the person’s actual blood pressure. The calculation also does not, by itself, justify a causal statement about changing age or BMI.

Worked Example: Fitted Energy Use With Two Predictors

Suppose a hypothetical additive equation fits energy use for a production batch in kilowatt-hours (kWh). Its predictors are machine runtime, in hours, and batch size, in units:

$$ \widehat{\text{energy use}}=12+3.8(\text{runtime})+0.12(\text{batch size}). $$

For a runtime of 5.5 hours and a batch size of 40 units, the values lie within the illustrative ranges for which this equation is intended to be used: 2 to 8 hours and 10 to 60 units. Substitute them in their matching terms:

$$ \begin{aligned} \widehat{\text{energy use}}&=12+3.8(5.5)+0.12(40)\\ &=12+20.9+4.8\\ &=37.7\text{ kWh}. \end{aligned} $$

The fitted energy use is 37.7 kWh. The intercept and both predictor terms are included because all three appear in the equation. The range check does not prove the equation is a good model, but it avoids applying it to a profile far outside its stated intended range.

Why Substitution Gives the Fitted Value

The fitted equation is the rule that assigns an outcome value to each predictor profile. A profile with predictor values \(x_1,\ldots,x_k\) is represented by inserting those values into the corresponding positions. For two predictors, if the fitted rule is

$$ \hat{y}(x_1,x_2)=\hat{\beta}_0+\hat{\beta}_1x_1+\hat{\beta}_2x_2, $$

then evaluating the rule at the requested profile \((a,b)\) means replacing \(x_1\) with \(a\) and \(x_2\) with \(b\):

$$ \hat{y}(a,b)=\hat{\beta}_0+\hat{\beta}_1a+\hat{\beta}_2b. $$

This is the same operation as evaluating any algebraic expression at specified inputs. It also explains why matching values to predictors matters: swapping \(a\) and \(b\) changes which coefficient multiplies each value, and generally changes the fitted result.

The model equation describes an outcome with an error term, while the fitted equation gives the value calculated from the estimated intercept and slopes. Under the usual conditional-mean interpretation, the error has conditional mean zero for each predictor profile, so the model’s conditional mean is represented by the non-error part of the equation. Substitution evaluates that fitted expression; it does not calculate or remove the unexplained error for a particular observation.

No probability calculation is needed simply to evaluate the fitted equation. Assumptions about the distribution or spread of errors are relevant to other tasks, such as inference or quantifying uncertainty, but they are not additional arithmetic steps in finding \(\hat{y}\). To treat the result as informative, however, the equation must be appropriate for the situation, values must use its stated definitions and scales, and the profile should not be an unreasonable extrapolation.

Common Mistakes and a Key Distinction

A frequent error is to substitute values in the wrong scale or omit a term. For example, if attendance is recorded in percentage points, substituting \(0.90\) for 90 changes the attendance part of the fitted value by a factor of 100. Likewise, leaving out the intercept or using the age value in months when the equation expects years changes the calculation.

  • Wrong reasoning: “The equation has a term for 90% attendance, so I should enter 0.90 because 90% is 0.90 as a proportion.”
  • Correction: Check how the predictor was represented in the equation. If it uses percentage points, substitute 90; use 0.90 only if the equation’s predictor is defined as a proportion from 0 to 1.
  • Wrong reasoning: “The fitted score is 89, so the individual’s observed score must be 89.”
  • Correction: The fitted value comes from the equation. An observed outcome may differ because the model includes an error term.

A fitted outcome is also not a coefficient. A coefficient is one of the numbers in the equation; \(\hat{y}\) is the value obtained after all the specified predictor values have been substituted and the expression evaluated. Keeping these distinct helps prevent a number from the equation being reported as though it were the requested fitted outcome.

Key takeaway: To calculate a fitted outcome, match every supplied predictor value to its equation term, preserve the stated units and scale, include all terms in the equation, and evaluate the expression. Report the result in outcome units and describe it as fitted, not as a guaranteed observed value.

Check Your Understanding

Use the equation and check your reasoning for each question.

  1. For \(\hat{y}=10+2x_1+0.5x_2\), calculate the fitted value at \(x_1=4\) and \(x_2=6\). Show the substituted equation and arithmetic.
  2. An equation uses attendance in percentage points. Should 85% be entered as 85 or 0.85? What information determines the answer?
  3. Explain why a fitted value of 120 units does not imply that an individual observation must equal 120 units.
  4. Suppose a fitted equation includes an intercept and three predictors. How many terms should appear in the substituted expression, and which should be included?
  5. Why can exchanging the values of two predictors change the fitted outcome, even when the same two numbers are used?