PracHub
QuestionsLearningGuidesInterview Prep
|Home/Machine Learning/Two Sigma

Slopes of y-on-x vs x-on-y Regression: Relationship and When They Are Equal

Last updated: Jul 2, 2026

Quick Overview

This question evaluates understanding of simple OLS linear regression estimators, moment-based expressions for slopes, the relationship between y-on-x and x-on-y fitted slopes, and how correlation and variable scaling influence coefficient values.

  • hard
  • Two Sigma
  • Machine Learning
  • Data Scientist

Slopes of y-on-x vs x-on-y Regression: Relationship and When They Are Equal

Company: Two Sigma

Role: Data Scientist

Category: Machine Learning

Difficulty: hard

Interview Round: Technical Screen

You fit two simple ordinary least squares (OLS) regressions, each with an intercept, on the same paired dataset $(x_i, y_i)$ for $i = 1, \dots, n$: 1. Regress $y$ on $x$: $\;y = \alpha_1 + \beta_{y|x}\, x + \varepsilon$ 2. Regress $x$ on $y$: $\;x = \alpha_2 + \beta_{x|y}\, y + \eta$ The interviewer wants you to reason about how the two fitted slopes relate to each other, and what it takes for them to be equal. ### Constraints & Assumptions - Both fits are plain OLS with an intercept and a single predictor. - The data are not degenerate: $n \ge 3$, and the sample variances of $x$ and $y$ are strictly positive. - "Coefficients" refers to the slope estimates $\hat\beta_{y|x}$ and $\hat\beta_{x|y}$. - You may transform the data (e.g., rescale variables) when asked how to make the slopes equal. ### Clarifying Questions to Ask - Are both fits ordinary least squares, or is a symmetric method (e.g., orthogonal / total least squares) intended? - Should I treat the data as raw, or can I assume it has already been centered or standardized? - Do you care about the intercepts as well, or only the slopes? - When you ask how to make the coefficients equal, may I transform the variables, or must a condition hold on the raw data? ### Part 1 Derive both slope estimates in terms of sample moments. What is the relationship between $\hat\beta_{y|x}$ and $\hat\beta_{x|y}$? In particular, what is their product, and why is $\hat\beta_{x|y}$ generally *not* equal to $1/\hat\beta_{y|x}$, even though the second regression looks like the first one "solved for $x$"? ```hint Write both slopes with sample moments For simple OLS, the slope is the covariance over the variance of the predictor: $\hat\beta_{y|x} = \widehat{\mathrm{Cov}}(x,y)/\widehat{\mathrm{Var}}(x)$. Write the analogous expression for the reverse regression and compare the two. ``` ```hint Bring in the correlation Express each slope as the sample correlation $r$ times a ratio of standard deviations. Multiplying the two expressions makes the relationship pop out — and connects it to a familiar goodness-of-fit quantity. ``` #### What This Part Should Cover ```premium-lock What This Part Should Cover ``` ### Part 2 Under what condition on the data are the two slopes exactly equal? How would you transform the data so that the two regressions are guaranteed to produce the same slope, and what is the value of that common slope? ```hint Set the two expressions equal Using the moment forms from Part 1, equate them and see what must be true of the sample variances of $x$ and $y$ (watch for the degenerate zero-covariance case). ``` ```hint A standard preprocessing step does it Think about what happens to both slopes if you z-score each variable. What do the standard-deviation ratios become, and what quantity is each slope then equal to? ``` #### What This Part Should Cover ```premium-lock What This Part Should Cover ``` ### What a Strong Answer Covers ```premium-lock What a Strong Answer Covers ``` ### Follow-up Questions - Suppose both $x$ and $y$ are noisy measurements of the same underlying quantity. Is either OLS slope an unbiased estimate of the true relationship? What symmetric alternatives exist, and what do they assume? - In the $(x, y)$ plane, how do the two fitted *lines* (not just slopes) relate geometrically? When do they coincide? - What happens to each of the two slopes if you add independent noise to $x$ only, leaving $y$ unchanged?

Quick Answer: This question evaluates understanding of simple OLS linear regression estimators, moment-based expressions for slopes, the relationship between y-on-x and x-on-y fitted slopes, and how correlation and variable scaling influence coefficient values.

Related Interview Questions

  • Analyze Temperatures and Update Regression - Two Sigma (medium)
  • How would you forecast bike demand? - Two Sigma (hard)
  • Predict Bike Dock Demand - Two Sigma (hard)
  • Predict bike demand and avoid overfitting - Two Sigma (hard)
  • How detect duplicate card records? - Two Sigma (medium)
|Home/Machine Learning/Two Sigma

Slopes of y-on-x vs x-on-y Regression: Relationship and When They Are Equal

Two Sigma logo
Two Sigma
Nov 28, 2025, 12:00 AM
hardData ScientistTechnical ScreenMachine Learning
4
0

You fit two simple ordinary least squares (OLS) regressions, each with an intercept, on the same paired dataset (xi,yi)(x_i, y_i)(xi​,yi​) for i=1,…,ni = 1, \dots, ni=1,…,n:

  1. Regress yyy on xxx :   y=α1+βy∣x x+ε\;y = \alpha_1 + \beta_{y|x}\, x + \varepsilony=α1​+βy∣x​x+ε
  2. Regress xxx on yyy :   x=α2+βx∣y y+η\;x = \alpha_2 + \beta_{x|y}\, y + \etax=α2​+βx∣y​y+η

The interviewer wants you to reason about how the two fitted slopes relate to each other, and what it takes for them to be equal.

Constraints & Assumptions

  • Both fits are plain OLS with an intercept and a single predictor.
  • The data are not degenerate: n≥3n \ge 3n≥3 , and the sample variances of xxx and yyy are strictly positive.
  • "Coefficients" refers to the slope estimates β^y∣x\hat\beta_{y|x}β^​y∣x​ and β^x∣y\hat\beta_{x|y}β^​x∣y​ .
  • You may transform the data (e.g., rescale variables) when asked how to make the slopes equal.

Clarifying Questions to Ask Guidance

  • Are both fits ordinary least squares, or is a symmetric method (e.g., orthogonal / total least squares) intended?
  • Should I treat the data as raw, or can I assume it has already been centered or standardized?
  • Do you care about the intercepts as well, or only the slopes?
  • When you ask how to make the coefficients equal, may I transform the variables, or must a condition hold on the raw data?

Part 1

Derive both slope estimates in terms of sample moments. What is the relationship between β^y∣x\hat\beta_{y|x}β^​y∣x​ and β^x∣y\hat\beta_{x|y}β^​x∣y​? In particular, what is their product, and why is β^x∣y\hat\beta_{x|y}β^​x∣y​ generally not equal to 1/β^y∣x1/\hat\beta_{y|x}1/β^​y∣x​, even though the second regression looks like the first one "solved for xxx"?

What This Part Should Cover Premium

Part 2

Under what condition on the data are the two slopes exactly equal? How would you transform the data so that the two regressions are guaranteed to produce the same slope, and what is the value of that common slope?

What This Part Should Cover Premium

What a Strong Answer Covers Premium

Follow-up Questions Guidance

  • Suppose both xxx and yyy are noisy measurements of the same underlying quantity. Is either OLS slope an unbiased estimate of the true relationship? What symmetric alternatives exist, and what do they assume?
  • In the (x,y)(x, y)(x,y) plane, how do the two fitted lines (not just slopes) relate geometrically? When do they coincide?
  • What happens to each of the two slopes if you add independent noise to xxx only, leaving yyy unchanged?
Loading comments...

Browse More Questions

More Machine Learning•More Two Sigma•More Data Scientist•Two Sigma Data Scientist•Two Sigma Machine Learning•Data Scientist Machine Learning

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.