6

I am actually a novice to R and stats.. Could something like this be done in R

Determining the density estimates of two samples ( 2 Vectors )..?? I have done this Using R and obtained 2 density curves for the 2 samples using kernel density estimation ..

Is there anyway to quantitatively compare how similar/Dissimilar the density estimates of 2 samples are..?

I am trying to find out which data sample exhibits has a similar distribution to a particular distribution..

I am using R Language... Can somebody please help..??

Pradeep
  • 555
  • 8
  • 14
  • YOu have an answer that was very helpful. Please click on the V-sign on the left of that answer to accept it, and do the same with the answers on your previous questions. This tells other people passing by that it was a correct answer. People will be less and less helpful when you don't acknowledge their answers. – Joris Meys Apr 18 '11 at 11:22

3 Answers3

7

You can use Kolmogorov-Smirnov test (ks.test) to compare two distributions. Cramer-von-Mises test is another one. There is this PDF Fitting Distributions with R where they also list other tests that are available (although the nortest package that he uses only tests for normality).

Apprentice Queue
  • 2,036
  • 13
  • 13
4

Apprentice Queue is right about using the Kolmogorov-Smirnoff test, but I wanted to add a warning: don't use it on its own. You should visually compare the distributions as well, either with two kernel density plots or histograms, or with a qqplot. Human brains are very good at playing spot-the-difference.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
  • Good point and, interestingly, that is exactly what @Pradeep proposes as his problem which neither answer currently offered really gets at. – Gavin Simpson Apr 18 '11 at 11:38
  • @Simpson, actually Pradeep's problem was he needed a quantitative procedure not a qualitative one. He had already calculated their densities and therefore could plot them. – Apprentice Queue Jul 04 '11 at 20:18
0

You can try calculating the Earth mover's distance

kaybenleroll
  • 16,794
  • 16
  • 54
  • 66
skyde
  • 2,816
  • 4
  • 34
  • 53