Does this present a linear relationship?

I have created the following graph which contains a great number of datapoints, I can see that there is a very linear scattering of the points, but am not sure since it displays a lot of datapoints all around the graph. Could anyone explain what kind of relationship is present and their technique for identifying it?

• Google "linear regression." It is a vast topic. – John Coleman Apr 21 '17 at 3:14
• This is clearly not linear... – SmallChess Apr 21 '17 at 3:45
• @SmallChess unfortunately I cant see that as clearly, how would you suggest I learn to either calculate or determine that? – LoriDori Apr 21 '17 at 4:00
• @SmallChess Disagree. It's certainly not "clear" that a non-linear realationship would explain this data better than a linear one. – TrynnaDoStat Apr 21 '17 at 15:12

4 Answers

There is some correlation, but it is weak. You could calculate this with the cor() function.

Add + geom_smooth(method = "lm") to your ggplot to see the relationship.

Finally, I think this is showing Heteroscedasticity - https://en.m.wikipedia.org/wiki/Heteroscedasticity

• You seem to be advocating correlation as the go-to method to characterize this scatterplot. But in light of the heteroscedasticity (and some curvilinearity), why bother? Of what possible value could the correlation coefficient be? – whuber Apr 21 '17 at 14:01

It's impossible to give you a definitive answer. It's possible that the relationship is linearizable though. Look at the MATLAB code and the graph below:

x=randi(1000,10000,1);
y=arrayfun(@(lambda)nbinrnd(lambda/200,0.001)/10,x);
scatter(x,y)

This is a simulation of the negative binomial distribution where one of the parameters is proportional on x-axis variable. It looks similar to your plot.

To me the data looks linear. There are tests of linearity, look at: https://stats.stackexchange.com/questions/68454/statistical-test-to-see-if-relationship-is-linear-or-non-linear

Personally, I'd just use a qqplot, it's a quick and easy way to visualize how linear a dataset it by comparing the distributions of the 2 variables together (see ?qqplot) or this for an explanation: https://en.wikipedia.org/wiki/Q–Q_plot.

• A quantile-quantile plot can't be more informative, and more reliably informative, than a scatter plot about relationships. Wanting to get rid of noise is understandable but there are better ways of doing that. – Nick Cox Apr 21 '17 at 14:06

A linear relationship can still have large error around the regression line which your data seems to have for certain ranges of $X$. This happens when $X$ tells you something about $Y$ but doesn't fully explain values of $Y$. This happens all the time! For example, height explains weight but doesn't 100% tell you what a person's weight will be.

A linear relationship does seem to give you an adequate explanation of the general relationship between $X$ and $Y$ in your scatterplot. At least, it's not clear to me that a non-linear term would do a better job explaining this data than simply a linear one. What you don't appear to have is Normally distributed error with constant variance in $X$. You certainly have heteroskedasticity because the error around the would-be linear regression line varies for different regions of $X$. This violates an assumption of ordinary least squares (OLS) regression.

Since you are violating an assumption of OLS, do not estimate the parameters of your linear relationship using OLS (which many software treats as default). Instead, you can handle the heteroskedasticity with weighted least squares. Additionally, you ought to consider modeling your error as non-Normal because it's not obvious to me whether or not you error is Normal (so consider things like a qq-plot to check).