Course contentsShow
← Data Science
Lesson 592 of 2,14515. Regression DiagnosticsFree lesson

Common Transformations: Log, Square Root, Reciprocal

Apply logarithmic, square root, and reciprocal transformations to stabilize variance and linearize relationships.

Common Transformations: Log, Square Root, Reciprocal

What you'll learn: How to apply three powerful mathematical transformations that fix common regression problems like curved relationships and unequal variance.

Why These Transformations Matter

When residual plots reveal non-linearity or heteroscedasticity (remember, that's non-constant variance), transforming your variables can "straighten out" relationships and stabilize variance—making linear regression assumptions hold.

The Three Workhorses

Logarithmic Transformation

Apply log(y) or log(x) when:

  • Data spans several orders of magnitude (e.g., income, population)
  • Variance increases with the mean
  • Growth is exponential or multiplicative

Effect: Compresses large values more than small ones, pulling in the right tail of skewed distributions.

Square Root Transformation

Apply sqrt(y) or sqrt(x) when:

  • You have count data (always non-negative)
  • Variance increases with the mean, but less dramatically than log situations
  • You want a gentler transformation than log

Effect: Moderately compresses larger values while preserving zero.

Reciprocal Transformation

Apply 1/y or 1/x when:

  • Diminishing returns are present (effect weakens as X increases)
  • You're modeling rates or speeds
  • The relationship approaches an asymptote

Effect: Dramatically compresses large values; makes infinity become zero. Changes interpretation significantly.

Choosing the Right One

Think of these as strength levels: reciprocal is strongest, log is medium, square root is gentlest. Start with the mildest transformation that fixes your diagnostics. After transforming, always re-check residual plots and Q-Q plots to confirm improvement.

Key Takeaway: Logarithmic, square root, and reciprocal transformations are your toolkit for linearizing curved relationships and stabilizing variance—choose based on your data's behavior and check diagnostics afterward to verify the fix worked.