14
$\begingroup$

For approximately normally distributed data, boxplots are a great way to quickly visualize the median and spread of the data, as well as the presence of any outliers.

However for more heavy-tailed distributions, a lot of points are shown as outliers, since outliers are defined as being outside of fixed factor of the IQR, and this happens of course a lot more frequently with heavy-tailed distributions.

So what do people use to visualize this kind of data? Is there something more adapted? I use ggplot on R, if that matters.

$\endgroup$
6
  • 1
    $\begingroup$ Samples from heavy tailed distributions tend to have a huge range compared to the middle 50%. What do you want to do about that? $\endgroup$
    – Glen_b
    Commented Jul 3, 2013 at 8:47
  • 7
    $\begingroup$ Several relevant threads already e.g. stats.stackexchange.com/questions/13086/… Short answer includes transform first then! histograms; quantile plots of various kinds; strip plots of various kinds. $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 8:47
  • $\begingroup$ @Glen_b : that's precisely my problem, it makes the boxplots unreadable. $\endgroup$ Commented Jul 3, 2013 at 8:51
  • 2
    $\begingroup$ The thing is, there's more than one thing that might be done... so what do you want it to do? $\endgroup$
    – Glen_b
    Commented Jul 3, 2013 at 8:51
  • 2
    $\begingroup$ Perhaps worth noting that most of the statistical world knows boxplots from their naming and (re-)introduction by John Tukey in the 1970s. (They were used for several decades earlier in climatology and geography.) But in the later chapters of his 1977 book on Exploratory data analysis (Reading, MA: Addison-Wesley) he has quite different ideas on handling heavy-tailed distributions. It seems that none has caught on at all. But quantile plots are in similar spirit. $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 9:16

4 Answers 4

9
$\begingroup$

The central problem the OP appears to have is that they have very-heavy tailed data - and I don't think most of the present answers actually deal with that issue at all, so I am promoting my previous comment to an answer.

If you did want to stay with boxplots, some options are listed below. I have created some data in R which shows the basic problem:

 set.seed(seed=7513870)
 x <- rcauchy(80)
 boxplot(x,horizontal=TRUE,boxwex=.7)

unsatisfactory boxplot

The middle half of the data is reduced to a tiny strip a couple of mm wide. The same problem afflicts most of the other suggestions - including QQ plots, strip charts, beehive/beeswarm plots, and violin plots.

Now some potential solutions:

  1. transformation,

If logs, or inverses produce a readable boxplot, they may be a very good idea, and the original scale can still be shown on the axis.

The big problem is there's sometimes no 'intuitive' transformation. There's a smaller problem that while quantiles themselves translate with monotonic transformations well enough, the fences don't; if you just boxplot the transformed data (as I did here), the whiskers will be at different x-values than in the original plot.

boxplot of transformed values

Here I used a inverse-hyperbolic-sin (asinh); it's sort of log-like in the tails and similar to linear near zero, but people generally don't find it an intuitive transformation, so in general I wouldn't recommend this option unless a fairly intuitive transformation like log is obvious. Code for that:

xlab <- c(-60,-20,-10,-5,-2,-1,0,1,2,5,10,20,40)
boxplot(asinh(x),horizontal=TRUE,boxwex=.7,axes=FALSE,frame.plot=TRUE)
axis(1,at=asinh(xlab),labels=xlab)
  1. scale breaks - take extreme outliers and compress them into narrow windows at each end with a much more compressed scale than at the center. I highly recommend a complete break across the whole scale if you do this.

boxplot with scale breaks

opar <- par()
layout(matrix(1:3,nr=1,nc=3),heights=c(1,1,1),widths=c(1,6,1))
par(oma = c(5,4,0,0) + 0.1,mar = c(0,0,1,1) + 0.1)
stripchart(x[x< -4],pch=1,cex=1,xlim=c(-80,-5))
boxplot(x[abs(x)<4],horizontal=TRUE,ylim=c(-4,4),at=0,boxwex=.7,cex=1)
stripchart(x[x> 4],pch=1,cex=1,xlim=c(5,80))
par(opar)
  1. trimming of extreme outliers (which I wouldn't normally advise without indicating this very clearly, but it looks like the next plot, without the "<5" and "2>" at either end), and

  2. what I'll call extreme-outlier "arrows" - similar to trimming, but with the count of values trimmed indicated at each end

boxplot with count of, and arrows pointing to, the extreme values

xout <- boxplot(x,range=3,horizontal=TRUE)$out
xin <- x[!(x %in% xout)]
noutl <- sum(xout<median(x))
nouth <- sum(xout>median(x))
boxplot(xin,horizontal=TRUE,ylim=c(min(xin)*1.15,max(xin)*1.15))
text(x=max(xin)*1.17,y=1,labels=paste0(as.character(nouth)," >"))
text(x=min(xin)*1.17,y=1,labels=paste0("< ",as.character(noutl)))
$\endgroup$
6
  • $\begingroup$ Thanks for taking the time to write this! This is exactly the kind of answer I was expecting. Now I only need to find out how to implement these plots with R :) $\endgroup$ Commented Jul 9, 2013 at 7:19
  • 1
    $\begingroup$ Some code is there now. I didn't give code for 3) because it's a simpler version of 4); you should be able to get it by cutting out lines from that. $\endgroup$
    – Glen_b
    Commented Jul 9, 2013 at 7:40
  • $\begingroup$ Incidentally most of these ideas work also with the other great displays suggested here - jittered stripcharts and beeswarm/beehive plots and violin plots and such. $\endgroup$
    – Glen_b
    Commented Jul 9, 2013 at 7:53
  • $\begingroup$ Thanks again. I'm sure this answer will be useful to quite a few people. $\endgroup$ Commented Jul 9, 2013 at 10:03
  • $\begingroup$ I agree, this addresses the question much better than my answer did. Good stuff. $\endgroup$
    – TooTone
    Commented Jul 9, 2013 at 12:19
4
$\begingroup$

Personally I like to use a stripplot with jitter at least to get a feel for the data. The plot below is with lattice in R (sorry not ggplot2). I like these plots because they're very easy to interpret. As you say, one reason for this is that there isn't any transform.

df <- data.frame(y1 = c(rnorm(100),-4:4), y2 = c(rnorm(100),-5:3), y3 = c(rnorm(100),-3:5))
df2 <- stack(df)
library(lattice)
stripplot(df2$values ~ df2$ind, jitter=T)

enter image description here

The beeswarm package offers a great alternative to stripplot (thanks to @January for the suggestion).

beeswarm(df2$values ~ df2$ind)

enter image description here

With your data, as it's approximately normally distributed, another thing to try might be a qqplot, qqnorm in this case.

par(mfrow=c(1,3))
for(i in 1:3) { qqnorm(df[,i]); abline(c(0,0),1,col="red") }

enter image description here

$\endgroup$
11
  • 2
    $\begingroup$ I like stripplots too, but the question is explicitly about what to do with heavy-tailed distributions. $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 10:57
  • 1
    $\begingroup$ The point is just that the advice to use e.g. qqnorm does not match the question. Other kinds of quantile-quantile plots could, I agree, be a very good idea, as I mentioned earlier. $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 11:03
  • 1
    $\begingroup$ Even better than stripplots from R are the plots from the beeswarm package. $\endgroup$
    – January
    Commented Jul 3, 2013 at 14:06
  • 1
    $\begingroup$ @January Yeah that's pretty cool, I'm adding it to my answer (if you object please say so). $\endgroup$
    – TooTone
    Commented Jul 3, 2013 at 14:25
  • 1
    $\begingroup$ My answer was posted at stats.stackexchange.com/questions/13086, which I view as an (inconsequentially narrower) version of this question. I summarized it as "don't change the boxplot algorithm: re-express the data instead." The issue hinted at by the "adapted" in this question is addressed by standard techniques of Exploratory Data Analysis for finding helpful re-expressions of variables. $\endgroup$
    – whuber
    Commented Jul 3, 2013 at 15:12
2
$\begingroup$

You can stick to boxplots. There are different possibilities for defining whiskers. Depending on tail thickness, number of samples and tolerance to outliers you can choose two more or less extreme quantiles. Given your problem I would avoid whiskers defined through the IQR.
Unless of course you want to transform your data, which in this case makes understanding harder.

$\endgroup$
9
  • 1
    $\begingroup$ The last sentence is too unqualified to pass without comment. Transformation is not a panacea, but not transforming highly skewed data does not make any easier to understand. If the data are all positive, you can at least try using root, logarithmic or reciprocal scale. If it really doesn't help, then back off. $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 9:37
  • $\begingroup$ To what difficulties in understanding skewed data are you referring to? Those with IQR-dependent whiskers? That's a problem even with light tails. And aren't we talking about heavy tails, independently of skewness? Transformations lightening tails surely give more regular boxplots, but add an interpretation layer, trading understanding for comfort. But one can call that a feature if he likes. $\endgroup$
    – Quartz
    Commented Jul 3, 2013 at 10:25
  • 3
    $\begingroup$ Transformations often help: that's my bottom line. A statistical person who hasn't learned that many things look clearer on logarithmic scale (especially) is missing out seriously on the one of the oldest and most effective tricks there is. You seemed to be denying that; I hope I misread you. $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 10:33
  • 2
    $\begingroup$ I disagree. I transform highly skewed data all the time and my experience is that this is far more than a question of aesthetics. It often works. An anonymous statistician wrote some time ago that the lognormal is more normal than the normal. He/she was being a little facetious but there's an important truth there too. (Not that many other distributions might not be better fits.) $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 10:43
  • 1
    $\begingroup$ I guess I need to stop here to let others judge, but my view is not eccentric. Transformation is discussed as one possibility at e.g. stats.stackexchange.com/questions/13086/… I suggest that you answer or comment there to explain why that advice is unsound. $\endgroup$
    – Nick Cox
    Commented Jul 3, 2013 at 10:54
0
$\begingroup$

I assume this question is about understanding data (as opposed to otherwise “managing” it )
If the data are heavy tailed and/or multimodal, I find these "layers" of ggplot2 very useful for the purpose: geom_violin and geom_jitter.

$\endgroup$
1
  • 3
    $\begingroup$ Could you summarize why violin plots and/or jittered points would be useful with heavy-tailed distributions? $\endgroup$
    – chl
    Commented Jul 3, 2013 at 11:57

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.