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("cramer-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('cramer') Loading required package: boot > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "cramer.test" > > ### * cramer.test > > flush(stderr()); flush(stdout()) > > ### Name: cramer.test > ### Title: Cramer-Test for uni- and multivariate two-sample-problem > ### Aliases: cramer.test phiBahr phiCramer phiFracA phiFracB phiLog > ### print.cramertest > ### Keywords: nonparametric multivariate htest > > ### ** Examples > > # comparison of two univariate normal distributions > x<-rnorm(20,mean=0,sd=1) > y<-rnorm(50,mean=0.5,sd=1) > cramer.test(x,y) 1 -dimensional nonparametric Cramer-Test with kernel phiCramer (on equality of two distributions) x-sample: 20 values y-sample: 50 values critical value for confidence level 95 % : 1.297253 observed statistic 0.8205867 , so that hypothesis ("x is distributed as y") is ACCEPTED . estimated p-value = 0.1638362 [result based on 1000 ordinary bootstrap-replicates] > > # comparison of two multivariate normal distributions with permutation test: > # library "MASS" for multivariate routines (included in package "VR") > > # library(MASS) > # x<-mvrnorm(n=20,mu=c(0,0),Sigma=diag(c(1,1))) > # y<-mvrnorm(n=50,mu=c(0.3,0),Sigma=diag(c(1,1))) > # cramer.test(x,y,sim="permutation") > > # comparison of two univariate normal distributions with Bahrs Kernel > phiBahr<-function(x) return(1-exp(-x/2)) > x<-rnorm(20,mean=0,sd=1) > y<-rnorm(50,mean=0,sd=2) > cramer.test(x,y,sim="eigenvalue",kernel="phiBahr") 1 -dimensional nonparametric Cramer-Test with kernel phiBahr (on equality of two distributions) x-sample: 20 values y-sample: 50 values critical value for confidence level 95 % : 1.487634 observed statistic 3.742670 , so that hypothesis ("x is distributed as y") is REJECTED . estimated p-value = 0.0004704174 [result based on eigenvalue decomposition and inverse fft] > > > > > ### *