MENTOR ME CAREERS

Regression Equation of X on Y: Formula & Worked Example

Last updated on November 3rd, 2026 at 05:29 pm

The regression equation of X on Y estimates X from a known value of Y. Write it as X̂ = a + bxyY, where X̂ is the fitted value, a is the intercept and bxy is the slope. In other words, X is the response and Y is the predictor. Therefore, decide that direction before you calculate anything.

regression equation of x on y

What does regression of X on Y mean?

In short, “X on Y” means that you use Y to estimate X. However, the letters do not determine which variable must be the outcome. Instead, the question determines the response. For example, if an exercise asks you to estimate X for Y = 4, fit the line that predicts X.

For example, let X represent monthly sales and Y represent advertising spend. In this exercise, you observe spend and estimate sales. Also, both use lakh rupees. In contrast, another study could choose different letters or ask a different question.

Similarly, this direction matters in software. For instance, a tool that defaults to predicting Y from X will solve a different problem unless you place your response and predictor in the correct fields. Duke University’s regression FAQ explains why the direction changes the fitted line.

Regression equation of X on Y: formula

For simple ordinary least squares with an intercept:

X̂ − X̄ = bxy(Y − Ȳ)

bxy = Σ[(Xi − X̄)(Yi − Ȳ)] ÷ Σ(Yi − Ȳ)²

Next, calculate a = X̄ − bxyȲ. Similarly, the slope is r × sX/sY when r and the standard deviations come from the same paired observations.

  • X̄ and Ȳ: the sample means of X and Y.
  • Σ: add the indicated values across all paired observations.
  • bxy: change in fitted X for a one-unit increase in Y.
  • a: fitted X at Y = 0, which may fall outside the observed range.

In particular, notice the denominator: it uses the variation in Y. In contrast, swapping in the variation of X would produce the slope for the opposite prediction direction.

Regression equation of X on Y: solved numerical example

First, use these five fictional observations. They form a small teaching exercise, not evidence that advertising alone determines sales.

ObservationY: spend (₹ lakh)X: sales (₹ lakh)Y − 3X − 40Product of deviations(Y − 3)²
1120−2−20404
2240−1001
335001000
44401001
5550210204
Total15200006010

Step 1: calculate both means

Ȳ = 15 ÷ 5 = 3. X̄ = 200 ÷ 5 = 40. Also, keep each observation paired: sorting one column alone would destroy the relationship.

Step 2: calculate the slope

Next, the sum of cross-products is 60. The sum of squared Y deviations is 10. Therefore, bxy = 60 ÷ 10 = 6.

Step 3: calculate the intercept

a = 40 − (6 × 3) = 22. Thus, the regression equation of X on Y is X̂ = 22 + 6Y. It passes through the mean point: at Y = 3, fitted X is 40.

Step 4: estimate X for Y = 4

X̂ = 22 + (6 × 4) = 46. The model estimates sales of ₹46 lakh for spend of ₹4 lakh in this fictional sample. The observed fourth sales value is ₹40 lakh. However, a fitted value is not a promise or a replacement for the recorded observation.

Regression equation of X on Y: check residuals

To check the regression equation of X on Y, calculate each residual: observed X minus fitted X. In the fourth observation, it is 40 − 46 = −6 lakh rupees. Therefore, the negative sign tells you that observed sales fall below the fitted estimate.

YObserved XFitted XResidual
12028−8
240346
3504010
44046−6
55052−2

Together, the squared residuals total 240. For ordinary least squares with an intercept, this line minimises the sum of squared errors in the response X. On our chart, Y is horizontal and X is vertical, so those response errors appear as vertical gaps.

Residuals need investigation in real work. For example, a large one might reflect a special event, a missing driver or a data problem. However, it does not automatically prove that the observation is wrong. Harvard’s regression chapter provides wider context on fitting and interpreting these relationships.

Regression equation of X on Y in Excel

For the table below, enter predictor Y in B6:B10 and response X in C6:C10. In particular, these addresses match the downloadable practice file.

ResultExcel formulaAnswer
Slope=SLOPE(C6:C10,B6:B10)6
Intercept=INTERCEPT(C6:C10,B6:B10)22
Prediction at Y = 4=22+6*446

However, Excel calls the first SLOPE argument known_ys. For the regression equation of X on Y, that argument contains our response X. In other words, the function’s argument label does not change the statistical question. Also, check the SLOPE syntax and INTERCEPT syntax when building your own sheet.

Download the regression of X on Y practice workbook (.xlsx). First, change the amber input for new Y from 4 to 3: the predicted X should move from 46 to 40. Next, restore 4 and inspect how the residual formulas link back to the fitted line.

Regression equation of X on Y vs Y on X

Although both fitted lines pass through the paired means, they minimise different response errors. In contrast, for this dataset the opposite fit gives Ŷ = −1 + 0.1X. Then, rearranging that equation gives X = 10Y + 10. However, it does not give our fitted X-on-Y line, X̂ = 22 + 6Y.

The slope product is 6 × 0.1 = 0.6 = r², so r is approximately 0.7746 here. However, the slopes are reciprocal only in the non-degenerate perfect-correlation case, where |r| = 1. Therefore, do not obtain one regression by simply inverting the other.

QuestionResponsePredictorSlope denominator
Estimate X using YXYSum of squared Y deviations
Estimate Y using XYXSum of squared X deviations

Limits to check before using regression in finance

  • Range: our Y observations run from 1 to 5. Predicting at 20 would be a large extrapolation.
  • Meaning: the intercept of 22 refers to Y = 0, outside this sample’s observed spend range.
  • Data quality: check units, periods, missing records and paired rows before fitting.
  • Shape: inspect a scatter plot. A straight line may miss a curved relationship.
  • Uncertainty: a point estimate alone does not show the likely range of future outcomes.
  • Causation: association can reflect other factors. This five-row example cannot establish a causal effect.

Before using the regression equation of X on Y in a forecast, explain the business driver and test the model on suitable data. Our financial modelling course page outlines the broader training offer. For financial-statement interpretation alongside quantitative work, use the worked ratio-analysis exercises.

Frequently asked questions

When should I use the regression equation of X on Y?

Use it when the question asks you to estimate X from known Y. First, identify the response, then assign the formula inputs.

Can the regression coefficient be negative?

Yes. A negative coefficient means that fitted X decreases as Y increases. However, that does not make the calculation invalid. In particular, the direction must match the actual paired data and the question.

What happens when all Y values are the same?

In the regression equation of X on Y, a constant Y makes the slope denominator zero. Therefore, this slope is undefined. Therefore, you need variation in the predictor to estimate its linear relationship with the response.

Does a high R squared guarantee a good forecast?

No. In particular, fit within a sample does not guarantee performance on new data. Therefore, check the model’s design, errors, assumptions and relevance to the forecast period.

Do I need normal data to calculate the fitted line?

Calculating the regression equation of X on Y does not require normal data. However, statistical tests and intervals require further assumptions about errors and the model. Therefore, keep calculation, inference and prediction separate.

ALLEN ARAVINDAN,CFA
ALLEN ARAVINDAN,CFA

A CFA charterholder with hands-on experience across investment analysis and finance education. At MentorMeCareers, he writes and reviews content on CFA, financial modeling, and investment banking careers — grounded in real market data rather than generic advice, and shaped by what actually helps candidates and professionals succeed.