0

I have a predictor $\hat{y}$. I have noticed that the correlation between $\hat{y}$ and $y$ are quite positive, above 50% even, while the $R^2$ is negative. Note that this is an out-of-sample $R^2$ and correlation. I train my predictor in-sample and test the correlation and $R^2$ out of sample.

Can someone explain what this say about my data?

  • 1
    $R^2$ cannot be negative. You'd better explain how you reached this conclusion that $R^2$ is negative. – Michael Hardy Sep 22 '23 at 02:13
  • 1
    It can be negative if you don't have constant or test out of sample? – Matt Frank Sep 22 '23 at 02:16
  • 1
    I’ll gladly reopen if that doesn’t answer the question, and I will address follow-up questions in the comments. Still, I think the images in my linked answer are pretty compelling. // $R^2<0$ is possible in many situations, basically in any situation other than fitting a linear model with an intercept using ordinary least squares and calculating in-sample, if you calculate according to $1-SSRes/SSTotal$ (but not if you square the Pearson correlation). – Dave Sep 22 '23 at 02:21
  • $R^2=1-SSRes/SSTotal$ can be negative if your predictions are worse (in a mean square error sense) than using a constant $\bar y$. This does not exclude positive correlation. If $y=(90,100,110)$ and $\hat y =(50,100,150)$ then $r=1$ but $R^2=-15$. It will not happen with ordinary least squares regression, but can with other modelling or with out-of-sample prediction. – Henry Sep 22 '23 at 09:18
  • I don't know what you mean by "an out-of-sample $R^2$." – Michael Hardy Sep 22 '23 at 16:03
  • @Henry : Where in the world did you get $-15$? – Michael Hardy Sep 22 '23 at 16:07
  • @MichaelHardy https://stats.stackexchange.com/q/590199/247274 If you calculate in a way other than squaring the correlation between true and predicted values, it is possible to achieve a negative value. – Dave Sep 22 '23 at 16:09
  • Normally the notation $\widehat y$ would refer to a fitted value rather than a predictor. – Michael Hardy Sep 22 '23 at 16:10
  • @MichaelHardy I only see $\hat y$ being used to refer to fitted values here. – Dave Sep 22 '23 at 16:11
  • @Dave : The very first sentence calls $\hat y$ a predictor. Of course the correlation between the fitted values and the observed values will be positive, but that's different from saying the correlation between the predictor and the observed values is positive. – Michael Hardy Sep 22 '23 at 16:19
  • 1
    @MichaelHardy $1-\frac{(90-50)^2+(100-100)^2+(110-150)^2}{(90-100)^2+(100-100)^2+(110-100)^2}=-15$ – Henry Sep 22 '23 at 16:21
  • @Henry : If you mean $\hat y=(50,100,150)$ are predicted values and $y=(90,100,110)$ are observed values that were not used in making the prediction, then the expression you write is not an example of what I would have understood $\text{“}R^2\text{”}$ to mean. – Michael Hardy Sep 22 '23 at 17:17
  • @MichaelHardy I am simply saying that in general a very poor model can produce negative $R^2$ values, while ordinary least squares regression will not. – Henry Sep 23 '23 at 02:50
  • @Henry : Note that I have posted this question: https://stats.stackexchange.com/questions/627589/definition-of-text-r2-text – Michael Hardy Sep 29 '23 at 16:49

0 Answers0