3
$\begingroup$

I have a regression prediction task where my outcome variable is right skewed. I performed a log transformation of the outcome variable and put it in a linear regression model. I assessed the R squared of the model and found it to be greatly improved (over non-transformed model).

Next I converted my dev set prediction values and dev set actual outcome values out of log scale (log -> exp). When I calculate R squared with the converted values it is quite a bit lower (.80 -> .70).

Am I wrong to think the R squared shouldn't be changing?

$\endgroup$
2
  • 1
    $\begingroup$ Could you explain what "dev set prediction" and "dev set actual outcome" values are? And if you expected $R^2$ not to change, why did you transform the variables in the first place? $\endgroup$ – whuber Jul 6 '18 at 18:32
  • 1
    $\begingroup$ By dev set prediction and actual outcomes I just mean that after forming my model with my data, I had a held out set of data that I wanted to predict values for (of which I already new the true value). Because my model's outcome variable is log transformed, so are my predictions. I used these two sets (true values and predicted values) to calculate an R squared. But ultimately I don't want my predictions in log values, so I converted back. However when I then calculate R squared using the converted predictions (and non-log true values), my R squared drops significantly. $\endgroup$ – David Skarbrevik Jul 6 '18 at 19:10
0
$\begingroup$

Assuming simple regression problem with one variable (X). General expression would be(for log transformed Y) : log(Y)= alpha *X + error. When you will take the exponential, then this will become: Y= exponential(alpha *X+error) If the R-squared value is 1, then it will remain the same after taking exponential because your error would be zero for each observation. However, since your value is .80, there would be error associated with each value and when you will take exponential of the error term, it will change and therefore, r-squared value will be different on non-transformed data.

$\endgroup$
5
  • $\begingroup$ I think I'm following you. Are you suggesting I just shouldn't do a log transformation on my outcome variable even though it improves the R-squared? I guess the weird part to me is if I did a great job of predicting the log of the outcome variable... it feels natural to think exp(log(outcome)) will be an equally great prediction for non-transformed outcome. But I guess not. $\endgroup$ – David Skarbrevik Jul 6 '18 at 22:09
  • $\begingroup$ You shouldn't be worried about R-square of non-transformed variable. R-square is a criteria to check performance of your model. Since, you applied model on transformed data, you should only consider R-square on transformed data, irrespective of its value on non-transform data. If you want to fit model on non-transform outcome variable, try to alter your predictor (variable), so that your performance/R-squared value can be improved. For example: try some polynomial form of predictors. $\endgroup$ – Harshit Mehta Jul 6 '18 at 22:46
  • $\begingroup$ So just to confirm, in a scenario where I built a great model on a log transformed outcome variable. When someone comes to me with new data and they want predictions from me (in non-transformed scale). I shouldn't expect that I'll have good predictions if I put their data in my model and then exp() the predictions to give to them? Those exp() predictions won't necessarily be very good? Is that an accurate statement? $\endgroup$ – David Skarbrevik Jul 7 '18 at 2:11
  • $\begingroup$ I won't say that those predictions are not good, but a bit distorted due to scaling. $\endgroup$ – Harshit Mehta Jul 7 '18 at 6:17
  • $\begingroup$ Facing similar issue, except I am getting a negative R2 of -0.02 when taking reversed transformation i.e exponent (reduced from 0.07 with log-transformed). Without any transformation to the target variable the model gives an R2 of 0.54. Which model should I trust? $\endgroup$ – DS_Enthusiast Dec 9 '19 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.