0

Kolmogorov–Smirnov test KS can be done for the single variable as

x <- rnorm(50)
ks.test(x, "pnorm", mean=mean(x), sd=sd(x))

Results:

One-sample Kolmogorov-Smirnov test

data: x D = 0.057841, p-value = 0.9927 alternative hypothesis: two-sided

How can I compute the weighted KS for single variable as well? I appreciate your suggestions. Thanks!

library(Ecume)
ks_test(x, y,thresh = .001)

I wanted to reproduce the test results of modified KS test of this paper on Jarque –Bera Test and its Competitors for Testing Normality – A Power Comparison.

Jarque –Bera Test and its Competitors for Testing Normality – A Power Comparison

ForestGump
  • 50
  • 2
  • 19
  • Did you search before posting? And do you realize that a "one-sample KS test is really just a 2-sample KS test against a specified theoretical distribution, typically one with similar first and second moments? So ... Is this a duplicate? https://stackoverflow.com/questions/62513941/kolmogorov-smirnov-test-and-weighted-data – IRTFM Nov 11 '21 at 00:37
  • @IRTFM Yes, I did! It didn't work. I couldn't install that fastDR package – ForestGump Nov 11 '21 at 00:51
  • @IRTFM I got this error: Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : namespace 'cli' 3.0.1 is being loaded, but >= 3.1.0 is required Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace – ForestGump Nov 11 '21 at 01:19
  • So is there a reason not to update `cli`? I initially got an error about an old versy of pkg: `survey` but running install.packages"survey") proceeded without error and then installing `fastDR` from github went smoothly. – IRTFM Nov 11 '21 at 01:21
  • @IRTFM Here is the error message: byte-compile and prepare package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : namespace 'cli' 3.0.1 is being loaded, but >= 3.1.0 is required Calls: ... namespaceImportFrom -> asNamespace -> loadNamespace Execution halted ERROR: lazy loading failed for package 'sessioninfo' * removing 'C:/Users/Jishan/Documents/R/win-library/4.1/sessioninfo' Warning in install.packages : installation of package ‘sessioninfo’ had non-zero exit status – ForestGump Nov 11 '21 at 01:36
  • I’m not an R parser. So I can only see inside that message that your current version of the cli package is OUT-OF-DATE. WHY NOT UPDATE IT? – IRTFM Nov 11 '21 at 02:57
  • I tried with that, but still not working! – ForestGump Nov 11 '21 at 03:08
  • WHAT did you try? The tail end of that message said something about an attempted installation of a “sessioninfo” package. There is a “sessionInfo” function but it’s not a package name. Spelling is critical in R. – IRTFM Nov 11 '21 at 03:10
  • It worked, but i just found that fastDR test is for multivariable whereas i wanna test the normality of residuals which is just single variable. – ForestGump Nov 11 '21 at 03:56
  • I wanted to reproduce the test results of modified KS test of this paper. https://www.scinapse.io/papers/2142225982#fullText – ForestGump Nov 11 '21 at 04:01
  • Generally procedures for multivariable tasks will have the same results when used with a model that has only one predictor as are produced by single variable tests. – IRTFM Nov 11 '21 at 06:32

0 Answers0