Analysis of R² Behavior with Scaled Targets
Let's break down your questions systematically:
1. How does scaling the target (e.g., log transformation) affect R²?
Key Formula:
R² = 1 - (SSres / SStot),
where:
- SSres = Sum of squared residuals (errors between predictions and actual values).
- SStot = Total sum of squares = Σ(y_i - ȳ)² (variance of the target scaled by sample size).
Impact of Scaling:
- If you scale the target (e.g., log transform a skewed variable), the variance of the target changes (SStot changes).
- R² is scale-dependent:
- If you compute R² on the original target, it reflects variance explained in the original units.
- If you compute R² on the log-scaled target, it reflects variance explained in log units.
- These R² values are not directly comparable because the scales (and thus SStot) differ.
Example:
- Suppose the original target
Y has high variance (e.g., variance = 100).
- After log-scaling,
log(Y) has lower variance (e.g., variance = 0.1).
- If a model explains 50% of the variance in both scales, R² would be 0.5 in both cases, but the absolute SSres/SStot ratios differ because SStot is scale-specific.
Mistake in Your Reasoning:
Lower variance in the scaled target does not automatically lead to a higher R². R² depends on how well the model explains variance relative to the scaled target's SStot. If the model’s performance (SSres) scales proportionally with SStot, R² remains unchanged.
2. Is it "easier" to achieve a high R² on a scaled target?
Case 1: Target is log-scaled (lower variance)
- SStot decreases (variance is smaller).
- If the model’s residuals (SSres) also decrease proportionally, R² stays the same.
- However, if scaling improves the linearity of the relationship (e.g., log transform fixes heteroscedasticity), the model may explain more variance in the scaled target, leading to a higher R².
Case 2: Target is unscaled (high variance)
- SStot is larger.
- A model must explain more absolute variance (lower SSres) to achieve the same R² as in the scaled case.
Conclusion:
- R² is not inherently easier to maximize on a scaled target. It depends on how the scaling affects the relationship between features and the target.
- Scaling can improve model performance (e.g., linearizing a non-linear relationship), but this is unrelated to the variance of the target itself.
3. Are percentage increases in R² easier with high-variance targets?
Key Insight:
A percentage increase in R² depends on the absolute reduction in SSres relative to SStot.
Example:
- High-variance target: SStot = 100, initial R² = 0.5 (SSres = 50).
- To increase R² to 0.51, reduce SSres by 1 (from 50 → 49):
New R² = 1 - (49/100) = 0.51.
- Low-variance target: SStot = 10, initial R² = 0.5 (SSres = 5).
- To increase R² to 0.51, reduce SSres by 0.1 (from 5 → 4.9):
New R² = 1 - (4.9/10) = 0.51.
Observation:
- For the same percentage point increase in R² (e.g., 0.5 → 0.51), the absolute reduction in SSres is smaller when SStot is smaller (low-variance target).
- Thus, percentage increases in R² are easier to achieve with low-variance targets because the same absolute improvement in residuals has a larger proportional impact on R².
Summary of Key Points
-
R² is scale-dependent:
- Comparing R² between scaled and unscaled targets is invalid.
- A model’s R² on log-scaled data measures performance in log units, not original units.
-
Scaling does not inherently improve R²:
- Lower variance in the target reduces SStot, but R² depends on the ratio SSres/SStot.
- If scaling improves the model’s ability to explain variance (e.g., linearizing a relationship), R² may increase, but this is due to better fit, not variance reduction.
-
Percentage increases in R² are easier with low-variance targets:
- Smaller SStot means the same absolute reduction in SSres leads to a larger percentage point increase in R².
Practical Recommendations
- Avoid comparing R² across scaled/unscaled targets. Use metrics like RMSE or MAE in original units for comparability.
- If scaling improves model performance (e.g., via linearity), report R² only on the scaled target and justify why scaling was necessary.
- For regression tasks, consider metrics like RMSE or MAE (both in original units) to compare models across different scalings.
Let me know if you’d like to dive deeper into specific examples!