KScorrect-package: KScorrect: Lilliefors-Corrected Kolmogorov-Smirnov...

Description Details Author(s) Examples

Description

Implements the Lilliefors-corrected Kolmogorov-Smirnov test for use in goodness-of-fit tests.

Details

KScorrect implements the Lilliefors-corrected Kolmogorov-Smirnov test for use in goodness-of-fit tests, suitable when population parameters are unknown and must be estimated by sample statistics. P-values are estimated by simulation. Coded to complement ks.test, it can be used with a variety of continuous distributions, including normal, lognormal, univariate mixtures of normals, uniform, loguniform, exponential, gamma, and Weibull distributions.

Functions to generate random numbers and calculate density, distribution, and quantile functions are provided for use with the loguniform and mixture distributions.

Author(s)

Phil Novack-Gottshall pnovack-gottshall@ben.edu

Steve C. Wang scwang@swarthmore.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Get the package version and citation of KScorrect
packageVersion("KScorrect")
citation("KScorrect")

x <- runif(200)
Lc <- LcKS(x, cdf="pnorm", nreps=999)
hist(Lc$D.sim)
abline(v = Lc$D.obs, lty = 2)
print(Lc, max=50)  # Print first 50 simulated statistics
# Approximate p-value (usually) << 0.05

# Confirmation uncorrected version has increased Type II error rate when
#   using sample statistics to estimate parameters:
ks.test(x, "pnorm", mean(x), sd(x))   # p-value always larger, (usually) > 0.05

x <- rlunif(200, min=exp(1), max=exp(10)) # random loguniform sample
Lc <- LcKS(x, cdf="plnorm")
Lc$p.value      # Approximate p-value: (usually) << 0.05

Example output

[1] '1.2.0'

To cite package 'KScorrect' in publications use:

  Phil Novack-Gottshall and Steve C. Wang (2016). KScorrect:
  Lilliefors-Corrected Kolmogorov-Smirnoff Goodness-of-Fit Tests. R
  package version 1.2.0. https://CRAN.R-project.org/package=KScorrect

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {KScorrect: Lilliefors-Corrected Kolmogorov-Smirnoff Goodness-of-Fit Tests},
    author = {Phil Novack-Gottshall and Steve C. Wang},
    year = {2016},
    note = {R package version 1.2.0},
    url = {https://CRAN.R-project.org/package=KScorrect},
  }

ATTENTION: This citation information has been auto-generated from the
package DESCRIPTION file and may need manual editing, see
'help("citation")'.

$D.obs
[1] 0.09114347

$D.sim
 [1] 0.04565911 0.03190328 0.04737380 0.03071354 0.04508665 0.02935098
 [7] 0.04282106 0.06095178 0.05173946 0.05343180 0.05030270 0.04207781
[13] 0.05625275 0.06238326 0.03522480 0.04650097 0.02962732 0.03463333
[19] 0.04142999 0.05599441 0.02827065 0.04788359 0.04036313 0.03743886
[25] 0.05522633 0.03562870 0.04227442 0.03386727 0.04840123 0.04039188
[31] 0.04132396 0.02959564 0.04364906 0.04438291 0.05756264 0.04201633
[37] 0.03527176 0.03776829 0.04516687 0.03397409 0.03171127 0.03340024
[43] 0.03994028 0.04621413 0.04484181 0.03824021 0.04564599 0.05107912
[49] 0.03449863 0.06591203
 [ reached getOption("max.print") -- omitted 949 entries ]

$p.value
[1] 0.001


	One-sample Kolmogorov-Smirnov test

data:  x
D = 0.091143, p-value = 0.0721
alternative hypothesis: two-sided

[1] 4e-04

KScorrect documentation built on July 4, 2019, 1:02 a.m.