Where can I find the limiting distribution of the Kolmogorov-Smirnov distance in R?

Conducting an experiment on the selection of importance, I simulate the values ​​of the Kolmogorov-Smirnov distances

$$ D_n = \ max_x | \ hat {F} _n (x) -F (x) | $$

where $ n $ is the sample size of the initial value, and I want to compare these values ​​with the asymptotic distribution of the Kolmogorov-Smirnov test or the Kolmogorov distribution , i.e.

$$ \ sqrt {N} D_n \ longrightarrow \ sup_ {t \ in [0,1]} | B (t) | $$

where $ B $ is the Brownian bridge.

Since ks.test relies on this asymptotic distribution, its cdf is already present somewhere in R, and I would like to know how to access it. R ks.test function contains an instruction

 PVAL <- 1 - if (alternative == "two.sided") .Call(C_pKolmogorov2x, STATISTIC, n) 

but my own call to C_pKolmogorov2x does not work.

+7
r
source share
1 answer

Relevant excerpt from "Writing R Extensions" manual

Then the directive in the NAMESPACE file

useDynLib (myDLL, .registration = TRUE)

causes the DLL to load, as well as for the R variables foo, bar_sym, R_call_sym and R_version_sym, which will be defined in the package namespace.

A translation per person says that this means (approximately) that the default location for all code other than R is in the package namespace. Hence the need for the triple intestine.

So, if you find .Call(something,args) in the code, you can call it from comandline to .Call(package:::something,args) . This is why a simple call to C_pKolmogorovx did not work. R did not find it because the package namespace is for the package, not the user.

If you want to know where the external code is, you need to examine 2 files. First, use the NAMESPACE package to find out if useDynLib to register external code functions, and then look in the src/init.c , where all available external code functions from the package are registered.

+4
source share

All Articles