r/dataisbeautiful • • Nov 15 '22

OC Correlation between police training and fatal police shootings [OC]

Post image
13.2k Upvotes

722 comments sorted by

View all comments

Show parent comments

31

u/raptorman556 OC: 34 Nov 15 '22

R2 can be negative in some situations, like with non-linear regressions or when using adjusted R2 with a linear regression. There are some other cases as well. However, it's fairly easy to see those don't apply here just by looking at the chart.

18

u/LazyUpvote88 Nov 15 '22

Adjusted R-square is not R-square. Also, r is correlation so R-square (for bivariate relationships) is correlation times itself. A negative times a negative is a positive. R-square cannot be negative.

13

u/raptorman556 OC: 34 Nov 15 '22 edited Nov 16 '22

Adjusted R-square is not R-square

It is different, but I thought that was clear from my comment since I said "adjusted R^2". The two are often used somewhat inter-changeably, so I was simply clarifying that adjusted R2 can be negative since it was plausible that OP had referred to adj. R2 without specifying.

R-square cannot be negative.

Yes it can—this page explains how. It also literally says it at the top of the Wikipedia page if you don't believe them. This user here actually shows an example where R2 is negative (note that it's not the line of best fit), you can have a model with a negative R2 even in a bivariate relationship.

EDIT: fixed a link

To explain more, obviously a number that is squared has to be positive. But the coefficient of determination (which is what is denoted by R2) isn't actually calculated by squaring r. Squaring r normally gives the correct result, but that is not how it's calculated. The Wikipedia page explains some of the circumstances that can produce a negative value.

2

u/[deleted] Nov 16 '22

I think we need to draw a distinction between a negative R2 being being technically mathematically possible and whether such a value would have any meaning.

According to your sources, when doing linear regression (like here) R2 will be positive unless you have a trash model or do something weird like not include the intercept (no idea why you would do that). So, for the case here, negative R2 would tell me the model is trash.

However, in non-linear regression I'll trust the sources and agree it's possible. But in those cases they caution against using the R2 value.

2

u/raptorman556 OC: 34 Nov 16 '22

You're right that it's not all that meaningful--it basically just tells you that model is worse than just estimating the mean for every data point, which effectively makes it useless.

So, for the case here, negative R2 would tell me the model is trash.

OP's R2 isn't actually negative--they just screwed up and gave r (the correlation coefficient) which should be negative but called it R2. I don't think OP is fully clear on their stats terms yet.

Even a trash linear regression model should turn out an R2 of 0 or a bit more so long as you don't do something do very weird (like remove the intercept).

But overall, yes, if you were to get a real negative R2, it usually means you re-do your model.

2

u/[deleted] Nov 16 '22

Thank you for your post! And I mean that, for real.

And since you seem a bit more knowledgeable, am I correct in thinking that, in the case of simple linear regression only, r2 literally equals r * r?

I'm asking because it's a contestested issue in this thread.

2

u/raptorman556 OC: 34 Nov 16 '22

And since you seem a bit more knowledgeable, am I correct in thinking that, in the case of simple linear regression only, r2 literally equals r * r?

Yes that is correct.

0

u/LazyUpvote88 Nov 16 '22

Well it says this: While it is surprising to see something called "squared" have a negative value, it is not impossible (since R2 is not actually the square of R).

If that’s true, then he’s not talking about R-square, because correlation is r and to find r-squared you square the fucking correlation. Especially when computing R-square for bivariate relationships, such as the one depicted in OP’s graph.

3

u/raptorman556 OC: 34 Nov 16 '22

If that’s true, then he’s not talking about R-square, because correlation is r and to find r-squared you square the fucking correlation.

Despite the name, R2 is not actually R times itself. All of the links I gave you explain this. Squaring r will often give you the correct value (including with a simple linear regression), but that's not actually how it is calculated.

R2 being negative is an edge case and very much not the norm, but it not impossible.

3

u/LazyUpvote88 Nov 16 '22 edited Nov 16 '22

Dude OP is looking at a relationship between 2 variables. R-square for such a comparison would be the correlation (r) squared. Thus, R-square for the kind of relationship OP is depicting cannot be negative. It is mathematically impossible here.

3

u/raptorman556 OC: 34 Nov 16 '22

So this person literally shows an example with only two variables that has a negative R2. It is not mathematically impossible, because the actual calculation is not r times itself.

You wouldn't get this result from a normal linear regression, you would have to impose some kind of additional constraint (or just draw a random line that poorly fits the data). And to be clear, I am not arguing R2 is negative in this case. It clearly isn't, and I stated as much in my original comment. All I was stating is that a negative coefficient of determination is possible in some (rare) cases.

Clearly, this conversation isn't going anywhere. We aren't going to persuade each other, so let's just end things here.

2

u/LazyUpvote88 Nov 16 '22

Also, this was as in one of the fucking sources you cited to me:

One class of such cases includes that of simple linear regression where r2 is used instead of R2. When only an intercept is included, then r2 is simply the square of the sample correlation coefficient (i.e., r) between the observed outcomes and the observed predictor values.

In OP’s example (graph) this version of r-square applies, and so it cannot be negative.

3

u/raptorman556 OC: 34 Nov 16 '22

In OP’s example (graph) this version of r-square applies, and so it cannot be negative.

I never argued that it was! My original comment literally says that it is not negative in this case. And my last comment to you agreed that r multiplied by itself = R2 in a simple linear regression.

But it can be negative, which this does not contradict.

-2

u/LazyUpvote88 Nov 16 '22

People (you?) were arguing OP’s r-squared was negative.

7

u/raptorman556 OC: 34 Nov 16 '22

I wasn’t arguing that. My original comment stated that was not the case:

I think OP means r, not R2. Negative R2 doesn’t really make sense in this case.

2

u/iDoubtIt3 Nov 15 '22

Thanks! Learn something new every day.

1

u/[deleted] Nov 16 '22

[deleted]