KSLTest: Kolmogorov-Smirnov-Lilliefors Test

View source: R/normal_Tests.R

KSLTestR Documentation

Kolmogorov-Smirnov-Lilliefors Test

Description

This function computes the Lilliefors variant of the one-sample Kolmogorov-Smirnov test.

Usage

KSLTest(data, alpha = 0.05, j = 1, warn = T,
  method = "molin-abdi", n_sim = 100000)

Arguments

data

The data of a univariate distribution for which the test statistic is computed (vector)

alpha

The two-sided decision threshold used for hypothesis-testing (scalar)

j

The # hypotheses tested; used to compute a Bonferonni correction, if applicable; should remain at its default if multiple testing is not an issue (scalar)

warn

Logical; warn by default that clipped polynomial output is an approximation-boundary result, not a literal tail probability of zero or one.

method

Exact calibration name: "molin-abdi" (default) or "monte-carlo".

n_sim

Positive integer simulation count, used only for "monte-carlo"; default 100000.

Details

The default method = "molin-abdi" retains Molin & Abdi's (1998) polynomial and legacy clipping of output outside [0,1]. Clipped values are not exact probabilities; clipping does not imply that the true p-value is below .001 or above .99. No automatic method switch is performed.

Select method = "monte-carlo" as an explicit alternative to clipping. Each of n_sim independent standard-normal samples has the same usable size as data; its mean and sample SD are re-estimated before computing the same D. The upper-tail p-value is (1 + count(D_sim >= D_obs)) / (n_sim + 1). This is normal-null simulation, not resampling the observed data. Use set.seed() before calling for reproducibility; simulation advances R's RNG.

At least four finite, nonconstant observations are required after omitting NA/NaN. Inputs must be numeric vectors. Centering/scaling avoids overflow and underflow where the input differences remain representable. Ties are accepted for statistic calculation; continuous-normal calibration is not established for rounded/discretized observations.

Monte Carlo p-values are returned without three-decimal rounding so that small positive estimates are not reported as zero. The minimum estimate is 1/(n_sim+1), a resolution limit, not proof of the true probability. The monte_carlo attribute records usable n, n_sim, exceedances, unrounded D, resolution, ties, and a 95 percent exact binomial interval for the null tail probability conditional on the observed statistic. That interval describes simulation uncertainty, not robustness to model misspecification. Small alpha/j thresholds may need substantially more simulation. Default-method output retains three-decimal rounding and the legacy three-element list.

Value

An object including the test statistic, p-value, and a significance flag (list)

Precision metadata

Successful computed results also carry a rita_test attribute with the unrounded statistic and p.value, n_tested, precision, calibration and details. It records existing computations without rerunning the test. Legacy list elements, warning behavior and decisions are unchanged. Unsupported or undefined results retain their existing sentinel/NA representation and may lack this attribute. See rita_analysis for reporting conventions.

References

Lilliefors, H.W. (1967). On the Kolmogorov-Smirnov Test for Normality with Mean and Variance Unknown. Journal of the American Statistical Association, 62, 399-402.

Molin, P., & Abdi, H. (1998). New Tables and numerical approximation for the KolmogorovSmirnov/Lillierfors/Van Soest test of normality.

Examples

values <- rnorm(100)
x <- KSLTest(data = values)
set.seed(2026)
mc <- KSLTest(values, method = "monte-carlo", n_sim = 999)
attr(mc, "monte_carlo") # Increase n_sim for precise tail inference.

Rita documentation built on Nov. 14, 2026, 1:07 a.m.

Related to KSLTest in Rita...