Rev 69376 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
R Under development (unstable) (2015-09-13 r69375) -- "Unsuffered Consequences"Copyright (C) 2015 The R Foundation for Statistical ComputingPlatform: x86_64-pc-linux-gnu (64-bit)R is free software and comes with ABSOLUTELY NO WARRANTY.You are welcome to redistribute it under certain conditions.Type 'license()' or 'licence()' for distribution details.R is a collaborative project with many contributors.Type 'contributors()' for more information and'citation()' on how to cite R or R packages in publications.Type 'demo()' for some demos, 'help()' for on-line help, or'help.start()' for an HTML browser interface to help.Type 'q()' to quit R.> ## some examples of the KS test>> ## unrealistic one of PR#14561> ds1 <- c(1.7,2,3,3,4,4,5,5,6,6)> ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216)One-sample Kolmogorov-Smirnov testdata: ds1D = 0.274, p-value = 0.4407alternative hypothesis: two-sidedWarning message:In ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216) :ties should not be present for the Kolmogorov-Smirnov test> # how on earth can sigma = 1.55216 be known?>> # R >= 2.14.0 allows the equally invalid> ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216, exact = TRUE)One-sample Kolmogorov-Smirnov testdata: ds1D = 0.274, p-value = 0.3715alternative hypothesis: two-sidedWarning message:In ks.test(ds1, "pnorm", mean = 3.3, sd = 1.55216, exact = TRUE) :ties should not be present for the Kolmogorov-Smirnov test>> ## Try out the effects of rounding> set.seed(123)> ds2 <- rnorm(1000)> ks.test(ds2, "pnorm") # exact = FALSE is default for n = 1000One-sample Kolmogorov-Smirnov testdata: ds2D = 0.019416, p-value = 0.8452alternative hypothesis: two-sided> ks.test(ds2, "pnorm", exact = TRUE)One-sample Kolmogorov-Smirnov testdata: ds2D = 0.019416, p-value = 0.8379alternative hypothesis: two-sided> ## next two are still close> ks.test(round(ds2, 2), "pnorm")One-sample Kolmogorov-Smirnov testdata: round(ds2, 2)D = 0.019169, p-value = 0.856alternative hypothesis: two-sidedWarning message:In ks.test(round(ds2, 2), "pnorm") :ties should not be present for the Kolmogorov-Smirnov test> ks.test(round(ds2, 2), "pnorm", exact = TRUE)One-sample Kolmogorov-Smirnov testdata: round(ds2, 2)D = 0.019169, p-value = 0.8489alternative hypothesis: two-sidedWarning message:In ks.test(round(ds2, 2), "pnorm", exact = TRUE) :ties should not be present for the Kolmogorov-Smirnov test> # now D has doubled, but p-values remain similar (if very different from ds2)> ks.test(round(ds2, 1), "pnorm")One-sample Kolmogorov-Smirnov testdata: round(ds2, 1)D = 0.03674, p-value = 0.1344alternative hypothesis: two-sidedWarning message:In ks.test(round(ds2, 1), "pnorm") :ties should not be present for the Kolmogorov-Smirnov test> ks.test(round(ds2, 1), "pnorm", exact = TRUE)One-sample Kolmogorov-Smirnov testdata: round(ds2, 1)D = 0.03674, p-value = 0.1311alternative hypothesis: two-sidedWarning message:In ks.test(round(ds2, 1), "pnorm", exact = TRUE) :ties should not be present for the Kolmogorov-Smirnov test>>> proc.time()user system elapsed0.121 0.012 0.122