New R package for K-S goodness-of-fit tests

May 2, 2016

This is a re-post from the R packages mailing list


We wanted to announce a new R package ‘KScorrect’ that carries out the Lilliefors correction to the Kolmogorov-Smirnoff test for use in (one-sample) goodness-of-fit tests.

It’s well-established it’s inappropriate to use the K-S test when sample statistics are used to estimate parameters, which results in substantially increased Type-II errors. This warning is mentioned in the ks.test Help page, but no general solution is currently available for non-normal distributions.

The ‘KScorrect’ package corrects for the bias by using Monte Carlo simulation, a solution first recommended by Lilliefors (1967) but not widely heeded. The primary function ‘LcKS()’ is written to complement, and can be used directly in place of, ‘ks.test()’. It can be used with most continuous distribution functions, including normal, univariate mixture of normals, lognormal, uniform, loguniform (flat when data are log-transformed), exponential, gamma, and Weibull distributions, and corresponding maximum-likelihood parameters are estimated automatically from the provided sample.

Distribution functions are provided in the package for the loguniform and univariate mixture of normal distributions, which are not included in the R base installation.

Simple examples are provided by calling example(KScorrect) or example(LcKS).

Additional details are available at Bug reports, suggestions, and feature requests are encouraged at

We hope you find the functions useful when conducting goodness-of-fit tests using the K-S test.

Phil Novack-Gottshall and Steve Wang

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)