UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

Stata FAQ
How can I test for equality of distribution?

An alternative test to the classic t-test is the Kolmogorov-Smirnov test for equality of distribution functions. In a simple example, we'll see if the distribution of writing test scores across gender are equal using the High-School and Beyond 2000 data set. We'll first do a kernel density plot of writing scores by gender.
use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear

kdensity write if female == 1, plot(kdensity write if female == 0) ///
	legend(label(1 "Females") label(2 "Males") rows(1))
ksmirnov write, by(female)

Two-sample Kolmogorov-Smirnov test for equality of distribution functions:

 Smaller group       D       P-value  Corrected
 ----------------------------------------------
 male:               0.2468    0.002
 female:             0.0000    1.000
 Combined K-S:       0.2468    0.005      0.003
From the test, it is apparent that the writing scores across gender do not have have the same distribution function.

How to cite this page

Report an error on this page or leave a comment

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.