# Relationships between two variables

Comparing two variables, I came up with the following chart. the x, y pairs represent independent observations of data on the field. I've doen Pearson correlation on it and have found one of 0.6.

My end goal is to establish a relationship between y and x such that y = f(x).

What analaysis would you recommend to obtain some form ofa relationship between the two variables?

• Too bad the image is gone. Sep 30, 2011 at 10:00
• @MicheldeRuiter - I'll try to find it at my office and rehost it, thanks for mentioning this Sep 30, 2011 at 10:54

Normality seems to be strongly violated at least by your y variable. I would log transform y to see if that cleans things up a bit. Then, fit a regression to log(y) ~ x. The formula the regression will return will be of the form log(y) = \alpha + \beta*x which you can transform back to the original scale by y = exp(\alpha + \beta*x)

• It also seems as if $y$ is always larger than some linear function of $x$, $y>C x$. Jul 30, 2010 at 10:11
• Possibly; still it is hard to tell without a zoom on this dense area (points are not transparent, so one cannot judge the density, and so this plot may be deceiving).
– user88
Jul 30, 2010 at 10:48

Another solution to your problem (without transforming variables) is regression with error distribution other then Gaussian for example Gamma or skewed t-Student. Gamma is in GLM family, so there is a lot of software to fit model with this error distribution.

What you are looking for is called regression; there are a lot of methods you can do it, both statistical and machine learning ones. If you want to find f, you must use statistics; in that case you must first assume that f is of some form, like f:y=a*x+b and then use some regression method to fit the parameters.
The plot suggests there are a lot of outliers (elements that does not follow f(x)); you may need robust regression to get rid of them.

And just eyeballing the data, you are probably going to want to transform the data, as (at least to me) it looks skewed. Looking at the histograms of the two variables should suggest which transforms may be beneficial.

As suggested by mbq, more text here.

I agree with the suggestions about running a regression possibly with log(y) as the outcome variable or some other suitable transformation. I just wanted to add one comment, if you are reporting the bivariate association, you might prefer: (a) to correlate log(x) and log(y), (b) Spearman's rho, which correlates the ranks of the two variables.

Try a bivariate robust regression (see http://cran.r-project.org/web/packages/rrcov/vignettes/rrcov.pdf for an intro).

If your data points are all positive, you might want to try to regress log(y) on log(x). Note that log() is not a substitute for a robust regression, but it sometimes makes the results more interpretable.

Many have already made excellent suggestions regarding transforming the variables and using robust regression methods. But, when looking at the scatter plot, I observe two separate data sets. One set has a very strong linear relationship where the correlation is a lot higher than the overall 0.6. And, visually it looks like Y = 0.13X. So, when X = 15,000 Y is around 2,000 or so. Thus, a regression line with a similar slope would fit the vast majority of the data points really well. Then, you have a second data set of 300 datapoints that are wild outliers that are random.

I would focus on those 300 outliers. Can you explain them? Are there reasons why they are so far off the regression line? Are those datapoints a fractional % of your whole data set? Are they material events you need to keep for your study? Or can you afford to take them out? If you can take them out, you may have a pretty strong regression with a high R Square. You just would have to accept that in a few percentage of the time things go wild and your regression model will be off. But, that's the truth of any model you built.

If you have to keep those 300 outliers in your overall data set, they will materially affect your regression. And, you will end up with a regression model that does not fit well the majority of your data point. And, it won't fit the outliers either because they are random and won't fit any regression line.

Like the others have said, some sort of transformation is recommended. Your data seems highly clustered, and could be roughly linear, but it's difficult to tell with all the other points around it. Others have suggested trying a log transformation, but it might also be a good idea to try a Box-Cox Transformation. If the resulting exponent it tells you to multiply by is 0, then a log transform is the best. All software packages that I know of allow you to do Box-Cox. In R, it's in the MASS package. Here's some information about that:

Doing Box-Cox Transformations in R

That's not going to give a you a perfectly linear fit, but it'll probably make the interpretation of your data a little easier.