R version 4.2.2 Patched (2022-11-10 r83330) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: 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.

  Natural language support but running in an English locale

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.

> pdf("g04.pdf");options(width=64)
> #setwd("C:\\Users\\kolassa\\Class555")
> setwd("~/Taught1/960-555/Data")
> #********************************************************/
> #* Yarn strength data from Example Q of Cox & Snell     */
> #* (1981).  Variables represent strength of two types of*/
> #* yarn collected from six different bobbins.           */
> #********************************************************/
> yarn<-as.data.frame(scan("yarn.dat",what=
+     list(strength=0, bobbin=0,type="")))
> wilcox.test(strength~type,data=yarn[yarn$bobbin==3,],
+    exact=FALSE, correct=FALSE)

	Wilcoxon rank sum test

data:  strength by type
W = 13, p-value = 0.1489
alternative hypothesis: true location shift is not equal to 0

> wilcox.test(strength~type,data=yarn[yarn$bobbin==3,],
+    exact=FALSE)

	Wilcoxon rank sum test with continuity correction

data:  strength by type
W = 13, p-value = 0.1939
alternative hypothesis: true location shift is not equal to 0

> wilcox.test(strength~type,data=yarn[yarn$bobbin==3,],
+    exact=TRUE)

	Wilcoxon rank sum exact test

data:  strength by type
W = 13, p-value = 0.2
alternative hypothesis: true location shift is not equal to 0

> arsenic<-as.data.frame(scan('arsenic.dat',
+   what=list(age=0,sex=0,drink=0,cook=0,water=0,nails=0)))
> wilcox.test(nails~sex,data=arsenic)

	Wilcoxon rank sum test with continuity correction

data:  nails by sex
W = 50, p-value = 0.9135
alternative hypothesis: true location shift is not equal to 0

> #*************************************************************/
> # Data from http://lib.stat.cmu.edu/datasets/Arsenic         */
> # reformatted into ASCII on the course home page.  Data re-  */
> # flect arsenic levels in toenail clippings; covariates in-  */
> # clude age, sex (1=M), categorical measures of quantities   */
> # used for drinking and cooking, arsenic in the water, and   */
> # arsenic in the nails.  To make arsenic.dat from Arsenic, do*/
> #antiword Arsenic|awk '((NR>39)&&(NR<61)){print}'>arsenic.dat*/
> #*************************************************************/
> arsenic<-read.table("arsenic.dat")
> names(arsenic)<-c("age","sex","drink","cook","water",
+    "nails")
> arsenic$status<-(arsenic$water>=.0001)+0
> arsenic$water[arsenic$water<.0001]<-.0001
> arsenic$lnail<-log(arsenic$nails)
> arsenic$lwater<-log(arsenic$water)
> library(exactRankTests)#For savage and vw scores
> arsenic$savagenails<-as.numeric(cscores(
+    arsenic$nails,type="Savage"))
> arsenic$vwnails<-as.numeric(cscores(arsenic$nails,
+    type="Normal"))
> library(MultNonParam)#For genscorestat
> genscorestat(arsenic$vwnails,arsenic$sex)

	General Score Test

data:  
Gaussian = -0.54578, mean = 0.0013198, variance =
3.9606984, p-value = 0.7834
alternative hypothesis: true median difference is  0

> genscorestat(arsenic$savagenails,arsenic$sex)

	General Score Test

data:  
Gaussian = 1.1944, mean = -0.047619, variance =
4.281902, p-value = 0.5484
alternative hypothesis: true median difference is  0

> library(MultNonParam)#For aov.P
> aov.P(dattab=arsenic$nails,treatment=arsenic$sex)
$pv
[1] 0.4823804

$tot
[1] 203490

> library(NonparametricHeuristic)#For fun.comparepower
> fun.comparepower(samp1sz=10,samp2sz=10,altvalue=0)
, , two.sided, 0, 10

                     rnorm
T-test               0.041
Exact Wilcoxon       0.037
Approximate Wilcoxon 0.047
Normal Scores        0.042
Savage Scores        0.041
Mood                 0.021

> fun.comparepower(samp1sz=10,samp2sz=10,altvalue=1)
, , two.sided, 1, 10

                     rnorm
T-test               0.525
Exact Wilcoxon       0.484
Approximate Wilcoxon 0.523
Normal Scores        0.512
Savage Scores        0.446
Mood                 0.273

>