3
$\begingroup$

I have data of a continuous random variable within the range [-1,1], which sometimes is concentrated around 0, while other times is concentrated toward -1 and 1, while zero is relatively underpopulated.

What measure can I use for both these cases to measure the divergence from a uniform distribution?

In other terms: I am looking for a measure of how evenly spread out the data is within the range, but standard dispersion measures (like variance) don't seem to work, since they favor distributions in which the tails are higher than the 'peak', e.g., when the region around zero is relatively underpopulated.

$\endgroup$
1
  • 2
    $\begingroup$ you mean like some goodness of fit statistic (such as a Kolmogorov-Smirnov or Cramer-von Mises statistic)? $\endgroup$
    – Glen_b
    Commented Feb 10, 2014 at 11:02

1 Answer 1

3
$\begingroup$

Expanding on @Glen_b 's comment:

KS works quite well here. In R, first create distributions like those mentioned

set.seed(123)
library(moments)
library(lattice)

UniDist <- runif(10000,-1,1)
NormDist <- rnorm(10000,0,1)
TruncNormDist <- NormDist[NormDist > -1 & NormDist < 1]
LowDist <- rnorm(5000,-.5,.1)
HighDist <- rnorm(5000,.5,.1)
TruncLowDist <- LowDist[LowDist < 0 & LowDist > -.5]
TruncHighDist <- HighDist[HighDist > 0 & HighDist < .5]
InvDist <- c(TruncLowDist, TruncHighDist)

Then test with ks.test:

ks.test(TruncNormDist, UniDist)
ks.test(InvDist, UniDist)

However, the D values are not intuitive (at least, not to me); ordinarily, I would suggest also using quantile plots:

qqplot(TruncNormDist, UniDist)

But that does not work well here (there is almost no divergence). Nor is a basic scatterplot much help:

xyplot(TruncNormDist~UniDist)

But Tukey mean difference plots are another matter

tmd(xyplot(TruncNormDist~UniDist))

Shows that the difference between the two distributions is near 0 at -1 and 1, but larger in the middle.

Comparing the inverse distribution to the truncated normal is much easier; both qqplot and xyplot show huge differences, and tmdplot is fascinating.

$\endgroup$
3
  • $\begingroup$ It's been a while since I've used R. How do I get tmd and xyplot? $\endgroup$
    – Angelorf
    Commented Feb 10, 2014 at 12:28
  • 1
    $\begingroup$ install.packages("lattice") and library(lattice). If you use SAS you can get both of these plots there, as well. Let me know if that's the case and I will provide more details. $\endgroup$
    – Peter Flom
    Commented Feb 10, 2014 at 12:28
  • $\begingroup$ Yes, I just needed to do library(lattice). Not using SAS, though. $\endgroup$
    – Angelorf
    Commented Feb 10, 2014 at 12:32

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.