R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 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 a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("diptest-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('diptest') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "dip" > > ### * dip > > flush(stderr()); flush(stdout()) > > ### Name: dip > ### Title: Compute Hartigan's Dip Test Statistic for Unimodality > ### Aliases: dip > ### Keywords: htest distribution > > ### ** Examples > > data(statfaculty) > plot(density(statfaculty)) > dip(statfaculty) [1] 0.05952381 > > str(dip(statfaculty, full = TRUE, debug = TRUE)) dip() in C: N = 63; starting with N*dip = 1. 'dip':LOOP-BEGIN: low, high = 1, 63 'dip':LOOP-BEGIN: low, high = 7, 58 'dip':LOOP-BEGIN: low, high = 7, 44 List of 12 $ x : num [1:63] 30 33 35 36 37 37 39 39 39 39 ... $ n : int 63 $ dip : num 0.0595 $ lo.hi : int [1:2] 7 44 $ ifault: int 0 $ gcm : int [1:63] 44 43 38 7 7 1 0 0 0 0 ... $ lcm : int [1:63] 7 11 15 42 44 58 0 0 0 0 ... $ mn : int [1:63] 1 1 2 3 3 5 3 7 7 7 ... $ mj : int [1:63] 44 44 15 15 6 15 11 11 11 11 ... $ debug : logi TRUE $ xl : num 39 $ xu : num 54 > > data(faithful) > fE <- faithful$eruptions > plot(density(fE)) > str(dip(fE, full = TRUE, debug = TRUE)) dip() in C: N = 272; starting with N*dip = 1. 'dip':LOOP-BEGIN: low, high = 1, 272 'dip':LOOP-BEGIN: low, high = 120, 261 List of 12 $ x : num [1:272] 1.60 1.67 1.70 1.73 1.75 ... $ n : int 272 $ dip : num 0.0924 $ lo.hi : int [1:2] 120 261 $ ifault: int 0 $ gcm : int [1:272] 261 260 252 181 146 135 120 0 0 0 ... $ lcm : int [1:272] 120 124 233 246 261 79 91 261 268 272 ... $ mn : int [1:272] 1 1 2 2 4 5 5 5 5 5 ... $ mj : int [1:272] 40 40 40 10 10 10 10 10 10 40 ... $ debug : logi TRUE $ xl : num 3.83 $ xu : num 4.83 > > data(precip) > plot(density(precip)) > str(dip(precip, full = TRUE, debug = TRUE)) dip() in C: N = 70; starting with N*dip = 1. 'dip':LOOP-BEGIN: low, high = 1, 70 'dip':LOOP-BEGIN: low, high = 19, 64 'dip':LOOP-BEGIN: low, high = 31, 55 List of 12 $ x : num [1:70] 7 7.2 7.8 7.8 11.5 13 14 14.6 15 15.2 ... $ n : int 70 $ dip : num 0.0357 $ lo.hi : int [1:2] 31 55 $ ifault: int 0 $ gcm : int [1:70] 55 49 31 31 29 19 0 0 0 0 ... $ lcm : int [1:70] 31 32 35 55 55 64 0 0 0 0 ... $ mn : int [1:70] 1 1 1 3 1 1 6 7 8 9 ... $ mj : int [1:70] 2 4 4 64 55 10 10 10 10 55 ... $ debug : logi TRUE $ xl : num 35.9 $ xu : num 43.4 > > > > cleanEx(); ..nameEx <- "exHartigan" > > ### * exHartigan > > flush(stderr()); flush(stdout()) > > ### Name: exHartigan > ### Title: Hartigan's Artificial n-modal Example Data Set > ### Aliases: exHartigan > ### Keywords: data > > ### ** Examples > > data(exHartigan) > plot(dH <- density(exHartigan)) > rug(exHartigan)# should jitter > > > > cleanEx(); ..nameEx <- "qDiptab" > > ### * qDiptab > > flush(stderr()); flush(stdout()) > > ### Name: qDiptab > ### Title: Table of Quantiles from a Large Simulation for Hartigan's Dip > ### Test > ### Aliases: qDiptab > ### Keywords: datasets > > ### ** Examples > > data(qDiptab) > str(qDiptab) num [1:17, 1:26] 0.1250 0.1000 0.0833 0.0714 0.0625 ... - attr(*, "dimnames")=List of 2 ..$ n : chr [1:17] "4" "5" "6" "7" ... ..$ Pr: chr [1:26] "0" "0.01" "0.02" "0.05" ... > ## the sample sizes `n' : > dnqd <- dimnames(qDiptab) > (nn <- as.integer(dnqd $n)) [1] 4 5 6 7 8 9 10 15 20 30 50 100 200 500 1000 [16] 2000 5000 > ## the probabilities: > P.p <- as.numeric(print(dnqd $ Pr)) [1] "0" "0.01" "0.02" "0.05" "0.1" "0.2" "0.3" [8] "0.4" "0.5" "0.6" "0.7" "0.8" "0.9" "0.95" [15] "0.98" "0.99" "0.995" "0.998" "0.999" "0.9995" "0.9998" [22] "0.9999" "0.99995" "0.99998" "0.99999" "1" > > ## This is as "Table 1" in Hartigan & Hartigan (1985) -- but more accurate > ps <- c(1,5,10,50,90,95,99, 99.5, 99.9)/100 > tab1 <- qDiptab[nn <= 200, as.character(ps)] > round(tab1, 4) Pr n 0.01 0.05 0.1 0.5 0.9 0.95 0.99 0.995 0.999 4 0.1250 0.1250 0.1250 0.1250 0.1874 0.2073 0.2318 0.2373 0.2444 5 0.1000 0.1000 0.1000 0.1216 0.1768 0.1864 0.1965 0.1982 0.1996 6 0.0833 0.0833 0.0833 0.1231 0.1591 0.1648 0.1919 0.2021 0.2195 7 0.0714 0.0726 0.0817 0.1178 0.1442 0.1599 0.1841 0.1910 0.2023 8 0.0625 0.0739 0.0820 0.1110 0.1418 0.1540 0.1730 0.1790 0.1945 9 0.0613 0.0733 0.0804 0.1042 0.1364 0.1466 0.1642 0.1728 0.1887 10 0.0610 0.0718 0.0780 0.0978 0.1305 0.1396 0.1597 0.1672 0.1806 15 0.0546 0.0610 0.0643 0.0836 0.1101 0.1188 0.1360 0.1425 0.1555 20 0.0474 0.0527 0.0568 0.0733 0.0972 0.1051 0.1206 0.1266 0.1386 30 0.0396 0.0444 0.0474 0.0615 0.0815 0.0882 0.1015 0.1065 0.1172 50 0.0314 0.0353 0.0377 0.0489 0.0649 0.0703 0.0812 0.0853 0.0941 100 0.0228 0.0257 0.0274 0.0355 0.0472 0.0511 0.0590 0.0620 0.0684 200 0.0165 0.0185 0.0198 0.0256 0.0340 0.0368 0.0427 0.0450 0.0497 > > > > cleanEx(); ..nameEx <- "statfaculty" > > ### * statfaculty > > flush(stderr()); flush(stdout()) > > ### Name: statfaculty > ### Title: Faculty Quality in Statistics Departments > ### Aliases: statfaculty > ### Keywords: datasets > > ### ** Examples > > data(statfaculty) > plot(dH <- density(statfaculty)) > rug(jitter(statfaculty)) > > > > ### *