# calc_ks_test_stat: Calculate the one-sample KS test statistic of data against a... In PaulMTeggin/practechniques: Functions for the Practical Actuarial Techniques online book

 calc_ks_test_stat R Documentation

## Calculate the one-sample KS test statistic of data against a fitted distribution

### Description

The purpose of this function is to allow the KS test statistic to be calculated for a wide range of distributions, i.e. to abstract the calculation of the test statistic from the CDF (p) function. This requires the estimated parameters to be specified as a single object.

### Usage

``````calc_ks_test_stat(x, params, fn_p)
``````

### Arguments

 `x` The data. `params` The parameters of the distribution, generally estimated from the data, as a single object. `fn_p` The cumulative distribution function of the distribution, in the form of a function that takes the data and estimated parameters as a single object, and returns cumulative probability values.

### Value

The KS test statistic.

Other Test statistic functions: `calc_ad_test_stat()`

### Examples

``````set.seed(1)
x <- rnorm(100)
params <- list(mean = mean(x), sd = sd(x))
calc_ks_test_stat(x, params, function(x, params) pnorm(x, params\$mean, params\$sd))
stats::ks.test(x, "pnorm", mean(x), sd(x))\$statistic
``````

PaulMTeggin/practechniques documentation built on Aug. 19, 2023, 4:44 p.m.