I want to study the relationship between two variables. I've got the following scatter plot.

enter image description here

But now I'm hesitating on what to do with this:

  1. Should I check the assumptions of OLS and then use the lm function?
  2. Or should I remove some outliers first?
  3. Or should I use ridge regression with the rlm function?
  4. Or should I check whether there's an quadratic relation?
  5. ...
  • $\begingroup$ I've taken R out of the title. What software you are using or might use is secondary to the question. $\endgroup$
    – Nick Cox
    Oct 30, 2014 at 15:49

2 Answers 2


The scatterplot shows a bunch of problems that indicate that regular regression will not be a good way of capturing the relationship:

1) Both variables are right skew

2) The variable on the y-axis appears to be bounded by 0 and 1 - is it a proportion?

3) There are "bands" in the plot.

4) No straight line comes close to showing the relationship.

So, what to do?

The problem is not just outliers and removing some outliers is unlikely to solve the problems.

If the 0's on the Y variable are indicative of problem data, you might want to remove them. It's hard to know without context. If you remove them, then it might be sensible to take logs of both variables. If you don't remove the 0's then it is possible to add a small value and then take logs, but this always strikes me as arbitrary.

A smoothed regression (loess or splines or something similar) might be useful on the untransformed variables.

More context will definitely help.

  • $\begingroup$ Hello! Thanks for the answer. The context of the problem is the following: There are 6000 documents. I've deleted some words out of these documents because it was garbage. So on the x-axis, you can read how many words a document contains BEFORE removing. On the y-axis, you can read how many (percent) garbage there is. Now I want to check if there's a relationship betweens how many words the documents contained en how many words that were removed in that document $\endgroup$
    – Anita
    Oct 30, 2014 at 11:48
  • $\begingroup$ You might want to look into beta regression, which deals with bounded dependent variables. $\endgroup$
    – Peter Flom
    Oct 30, 2014 at 12:32
  • 2
    $\begingroup$ @PeterFlom Wouldn't it be better to model the absolute values using Poisson regression? The bands in the plot are a result of only a discrete set of percentage values being possible for a given word count. $\endgroup$
    – Roland
    Oct 30, 2014 at 14:45
  • 1
    $\begingroup$ I see no reason to believe that you should strain towards a model. Echoing @PeterFlom, I'd start with some smooth of response given predictor and perhaps stop with that. For example, if the smooth is nearly flat, there is no relationship to model. Pedantic point: if something is shown as a proportion between 0 and 1, please don't call it a percent[age]. People here should all know the difference (or the identity), but using the less appropriate word is a minor distraction. $\endgroup$
    – Nick Cox
    Oct 30, 2014 at 15:47

Your plot is pretty consistent with proportion data with varying denominator. That is, the error in the estimate of the proportion of bad words is more variable in documents with fewer words to begin with, and the runs of curvy lines are a result of the discrete nature of the outcome.

A useful addition to the plot for exploratory purposes is to add a funnel for the confidence intervals of the global percentage given the varying number in the denominator. See Funnel plots for comparing institutional performance (Spiegelhalter, 2005), PDF Here, for a fuller description of funnel plots.

Here is a brief example in R for somewhat similar data (at least in the total estimated proportions and the range of document sizes).

x <- trunc(runif(500,1,150)) #generate vector of integers
pop_prob <- 0.2              #population probability
suc <- sapply(X=x,rbinom,n=1,prob=pop_prob,simplify=TRUE)
prob <- suc/x                #fake data to mock yours

plot(x,prob)                 #base plot

#generate 99% confidence intervals based on overall probability of pop_prob
alph <- 0.01
seq <- 1:(max(x)+5)

#via http://r.789695.n4.nabble.com/inverse-binomial-in-R-td4631935.html
invbinomial <- function(n, k, p) { 
   uniroot(function(x) pbinom(k, n, x) - p, c(0, 1))$root 

low <- mapply(invbinomial,n=seq,k=seq*pop_prob,p=1-alph/2)
high <- mapply(invbinomial,n=seq,k=seq*pop_prob,p=alph/2)

lines(low,col='red')              #low and high funnel lines

enter image description here

The lines give a better sense of the typical error, allow you to identify outliers, and also provide a guide on whether the proportions in the higher range are perhaps trending upwards or downwards, or more generally provide graphical evidence that the observed set of proportions come from a mixture of different processes. (As an example, one might see a trend for higher homicide rates in police jurisdictions with larger populations in a blog post I write, which is pretty consistent with criminological literature).

Note that with many observations you would expect a few points outside the bands simply by chance (as can be seen in my example), but they provide a useful exploratory guide nonetheless.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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