Tutorials › Introduction to Statistics › Choosing Explanatory and Response Variables

Least-Squares Regression Lines · Tutorial 251 of 996

Choosing Explanatory and Response Variables

Choose variable roles to match the question being asked, and see why reversing the prediction target generally changes the fitted regression line.

Beginner 10 min read

What You'll Learn

  • Identify explanatory and response variables from a study question.
  • Distinguish prediction direction from causation.
  • Calculate regression lines for both choices of direction.
  • Explain why reversing the variables does not usually give the inverse line.
  • Recognize when two regression lines are exact inverses.

Start With the Question

A regression line is used to describe or predict one variable from another. Before fitting or using one, decide which variable is the explanatory variable and which is the response variable. The choice comes from the question being asked: what information will be used to predict, explain, or summarize what outcome?

For example, a researcher might ask how a student's study time is related to a quiz score, or might ask whether quiz scores can help predict study time. The same paired measurements can address both questions, but the prediction target changes. Consequently, the regression line changes too.

Definition: In a regression analysis, the explanatory variable is the variable used as the input or predictor, conventionally denoted \(x\). The response variable is the outcome to be predicted or described, conventionally denoted \(y\). The least-squares regression line for predicting the response from the explanatory variable is written \(\hat{y}=a+bx\), where \(\hat{y}\) is a predicted response.

The roles are not determined just by which measurement was collected first, or by which variable is easier to measure. They should reflect the study question and the intended use of the line. In standard simple linear regression, both variables are quantitative. Their pairing matters: each \(x\) value must belong to the same individual or unit as its corresponding \(y\) value.

Roles Depend on the Prediction Target

Suppose a data set records daily outdoor temperature and a building's daily electricity use. If the question is “How does electricity use tend to vary with temperature?”, temperature is explanatory and electricity use is the response. If the question is instead “Can electricity use help predict the outdoor temperature?”, electricity use is explanatory and temperature is the response. The observations have not changed; the direction of prediction has.

Choosing an explanatory variable does not establish that it causes the response. A variable can be useful for prediction without being a cause. Even when a study question is phrased in terms of an effect, the design and evidence—not the labels \(x\) and \(y\)—determine whether a causal conclusion is justified.

Worked Example: Letting the Question Set the Roles

A hypothetical school records weekly study hours and scores on a quiz for each of 30 students. Consider three questions about these paired measurements.

Question 1: “What quiz score would be predicted for a student who studied a specified number of hours?” Study hours are the explanatory variable \(x\), and quiz score is the response \(y\). The intended regression line predicts scores from study hours.

Question 2: “What study time would be predicted for a student with a specified quiz score?” Quiz score is now \(x\), and study hours are \(y\). A different regression line is needed because study time is now the prediction target.

Question 3: “Are study time and quiz score associated?” This asks about a relationship without specifying a prediction direction. Correlation is symmetric, but a regression line is directional. To use regression, the question must specify which variable is to be predicted.

These choices do not show that studying causes a score change. The hypothetical records could reflect other influences, such as prior preparation or course attendance. The role labels organize a prediction; they do not settle a causal claim.

Why Reversing the Roles Changes the Line

For paired quantitative observations \((x_i,y_i)\), the least-squares line predicting \(y\) from \(x\) has the form \(\hat{y}=a+bx\). Its slope is chosen to fit the response values using the explanatory values. If the roles are reversed, the fitted line instead predicts \(x\) from \(y\), written \(\hat{x}=c+dy\). In general, this is a separately fitted line, not the algebraic inverse of the first.

The distinction can be shown using the sample correlation \(r\), the sample standard deviations \(s_x\) and \(s_y\), and the standard slope formulas for simple least-squares regression. The slope predicting \(y\) from \(x\) is \(b=r(s_y/s_x)\); the slope predicting \(x\) from \(y\) is \(d=r(s_x/s_y)\). These formulas give a concise justification for why the two fitted directions are related but not generally interchangeable.

$$ bd = \left(r\frac{s_y}{s_x}\right) \left(r\frac{s_x}{s_y}\right) = r^2 $$

If the first line were simply the exact inverse of the second, their slopes would have product 1. But the product of the actual regression slopes is \(r^2\). Unless the observations lie exactly on a straight line, \(|r|<1\), so \(r^2<1\). Thus the fitted lines generally are not inverses. When the relationship is perfectly linear, \(|r|=1\), the product is 1 and the two fitted lines are exact inverses (provided the slope is nonzero).

Both fitted lines pass through the point \((\bar{x},\bar{y})\), but sharing that point does not make them the same line. Reversing the roles changes which variable's deviations from its mean are used to fit the predictions. That difference is why predicting scores from study hours is not equivalent to solving the scores-on-hours equation for hours.

Worked Fits in Both Directions

The following examples calculate both directions from paired data. To calculate the slope of \(y\) predicted from \(x\), use the sum of products of deviations divided by the sum of squared deviations in \(x\). For the reverse line, divide that same sum of products by the sum of squared deviations in \(y\). The intercept in each direction is chosen so its line passes through the sample means.

Worked Example: Predicting Quiz Score or Study Time

Suppose four hypothetical students report \(1, 2, 3,\) and \(4\) hours of study, with quiz scores of \(50, 55, 65,\) and \(70\) points. Find the regression line for predicting score from study hours, then the line for predicting study hours from score.

The means are \(\bar{x}=2.5\) hours and \(\bar{y}=60\) points. The deviations from the means are \(x_i-\bar{x}=(-1.5,-0.5,0.5,1.5)\) hours and \(y_i-\bar{y}=(-10,-5,5,10)\) points. Therefore,

$$ \sum (x_i-\bar{x})(y_i-\bar{y})=35, \qquad \sum (x_i-\bar{x})^2=5, \qquad \sum (y_i-\bar{y})^2=250. $$

For predicting score from study hours, the slope is \(35/5=7\) points per hour. The intercept is \(\bar{y}-b\bar{x}=60-(7)(2.5)=42.5\) points. The fitted line is

$$ \widehat{\text{score}}=42.5+7(\text{study hours}). $$

For predicting study hours from score, the slope is \(35/250=0.14\) hours per point. The intercept is \(\bar{x}-d\bar{y}=2.5-(0.14)(60)=-5.9\) hours. Thus the reverse fitted line is

$$ \widehat{\text{study hours}}=-5.9+0.14(\text{score}). $$

The first line answers a score-prediction question; the second answers a study-time-prediction question. Their slopes are not reciprocals: \(7(0.14)=0.98\), not 1. The example's association is strong, but these four observations do not lie exactly on a straight line, so the two fitted lines are not exact inverses.

Worked Example: Reversing Temperature and Energy Use

A hypothetical building has four paired daily measurements: outdoor temperatures of \(10, 15, 20,\) and \(25\) degrees Celsius and electricity use of \(30, 25, 23,\) and \(18\) kilowatt-hours. Suppose the immediate question is how to predict electricity use from temperature.

Let temperature be \(x\) and electricity use be \(y\). The means are \(\bar{x}=17.5\) degrees Celsius and \(\bar{y}=24\) kilowatt-hours. The deviation lists are \((-7.5,-2.5,2.5,7.5)\) degrees and \((6,1,-1,-6)\) kilowatt-hours. Their products sum to \(-95\) degree-kilowatt-hours, while the squared temperature deviations sum to \(125\) degrees squared. Therefore, the slope for predicting electricity use is \(-95/125=-0.76\) kilowatt-hours per degree Celsius. The intercept is \(24-(-0.76)(17.5)=37.3\) kilowatt-hours, giving

$$ \widehat{\text{electricity use}} = 37.3-0.76(\text{temperature}). $$

Now reverse the prediction target. The squared electricity-use deviations sum to \(6^2+1^2+(-1)^2+(-6)^2=74\) kilowatt-hours squared. The slope for predicting temperature from electricity use is \(-95/74\approx-1.284\) degrees Celsius per kilowatt-hour. Its intercept is \(17.5-(-1.284)(24)\approx48.31\) degrees Celsius, so the reverse line is approximately

$$ \widehat{\text{temperature}} = 48.31-1.284(\text{electricity use}). $$

The paired observations are the same, but the lines are different because each line is fitted to predict a different variable. Either direction might be useful for a specified purpose; the study question determines which fitted line addresses that purpose.

Choosing Roles Carefully

A practical way to decide the roles is to state the question as a prediction sentence: “Use ___ to predict ___.” The first blank is the explanatory variable and the second is the response. Then check that the paired data, units, and fitted line correspond to that sentence. If the question does not identify a prediction target, a regression direction has not yet been chosen.

1
State the target.
Write down which variable the analysis is meant to predict or describe as an outcome.
2
Name the predictor.
The other variable is the explanatory variable used as input to the prediction.
3
Match the line to the question.
Use the line that predicts the response from the explanatory variable. Reversing the target requires fitting the other direction.
4
Keep the interpretation in context.
Report what is being predicted, name the explanatory measurement, and retain the units. Do not turn a prediction direction into a claim of cause.

Common Mistake: Treating the Reverse Line as an Inverse

A common error is to fit a line predicting \(y\) from \(x\), rearrange its equation to solve for \(x\), and call the result the regression line predicting \(x\) from \(y\). This assumes the fitted line predicts every observed \(y\) value exactly. Usually it does not; the reverse regression is fitted separately to minimize prediction errors in \(x\), rather than errors in \(y\).

For example, the quiz-score line above rearranges to \(\text{study hours}=(\text{score}-42.5)/7\), with slope \(1/7\approx0.1429\) hours per point. But the separately fitted reverse slope is \(0.14\) hours per point. They differ because the first equation is an algebraic rearrangement, not a new least-squares fit. In this particular small example the numbers are close, but closeness does not make the procedures equivalent.

Key takeaway: Correlation treats two quantitative variables symmetrically; regression assigns them directional roles. Choose the explanatory and response variables from the question, and fit a new line whenever the prediction target is reversed. Neither choice alone implies causation.

Check Your Understanding

For each question, identify the explanatory variable and the response variable, and explain what determines the direction.

  1. A clinic records patients' ages and waiting times. For predicting waiting time from age, which variable is explanatory and which is the response?
  2. In a study of weekly exercise time and resting heart rate, what changes if the question switches from predicting heart rate to predicting exercise time?
  3. Why is solving a regression equation algebraically for \(x\) generally not the same as fitting the regression of \(x\) on \(y\)?
  4. If two variables have correlation \(r=0.6\), what is the product of the slopes of the two regression lines? Are the lines exact inverses?
  5. Does labeling a medication dose as explanatory establish that it caused a change in a health outcome? Explain.