R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
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("g07.pdf");options(width=64)
> #setwd("C:\\Users\\kolassa\\Class555")
> setwd("~/Taught1/960-555/Data")
> twinbrain<-as.data.frame(scan("IQ_Brain_Size",
+   what=list(CCMIDSA=0,FIQ=0,HC=0,ORDER=0,PAIR=0,SEX=0,
+   TOTSA=0, TOTVOL=0,WEIGHT=0),skip=27,nmax=20))
> fir<-twinbrain[twinbrain$ORDER==1,]
> fir$v1<-fir$TOTVOL
> sec<-twinbrain[twinbrain$ORDER==2,]
> sec$v2<-sec$TOTVOL
> brainpairs<-merge(fir,sec,by="PAIR")[,c("v1","v2")]
> brainpairs$diff<-brainpairs$v2-brainpairs$v1
> wilcox.test(brainpairs$diff)

	Wilcoxon signed rank exact test

data:  brainpairs$diff
V = 32, p-value = 0.6953
alternative hypothesis: true location is not equal to 0

> library(BSDA)#For SIGN.test
> SIGN.test(brainpairs$diff)

	One-sample Sign-Test

data:  brainpairs$diff
s = 5, p-value = 1
alternative hypothesis: true median is not equal to 0
95 percent confidence interval:
 -40.37778  62.24000
sample estimates:
median of x 
         10 

Achieved and Interpolated Confidence Intervals: 

                  Conf.Level   L.E.pt U.E.pt
Lower Achieved CI     0.8906 -37.0000  44.00
Interpolated CI       0.9500 -40.3778  62.24
Upper Achieved CI     0.9785 -42.0000  71.00

> t.test(brainpairs$diff)

	One Sample t-test

data:  brainpairs$diff
t = 0.47424, df = 9, p-value = 0.6466
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 -32.04566  49.04566
sample estimates:
mean of x 
      8.5 

> library(MultNonParam)# for symscorestat
> cat("Asymptotic test using normal scores\n")
Asymptotic test using normal scores
> brainpairs$normalscores<-qqnorm(seq(length(
+    brainpairs$diff)),plot.it=F)$x
> symscorestat(brainpairs$diff,brainpairs$normalscores)
          pv          tot         stat 
   0.8635849 1024.0000000    1.5466353 
> cat("Asymptotic test using savage scores\n")
Asymptotic test using savage scores
> brainpairs$savagescores<-cumsum(
+    1/rev(seq(length(brainpairs$diff))))
> symscorestat(brainpairs$diff,brainpairs$savagescores)
          pv          tot         stat 
   0.7304268 1024.0000000    6.2686508 
> aves<-outer(brainpairs$diff,brainpairs$diff,"+")/2
> sort(aves[upper.tri(aves,diag=TRUE)])
 [1] -92.0 -67.0 -64.5 -50.5 -50.0 -42.0 -39.5 -37.0 -32.0 -28.0
[11] -25.5 -25.0 -24.0 -23.0 -22.5 -10.5  -9.0  -8.5  -8.0  -7.0
[21]  -4.5  -3.0  -0.5   1.0   1.0   3.5   9.5  10.0  13.5  14.0
[31]  14.5  17.0  17.5  18.0  26.0  28.0  28.5  31.0  31.5  32.0
[41]  36.0  36.0  40.0  42.5  43.0  44.0  49.5  53.5  57.5  61.0
[51]  65.0  69.0  71.0  82.5  94.0
> library(NonparametricHeuristic)#For hodgeslehmannexample
> hodgeslehmannexample()
[1]  1 21
> qsignrank(0.025, 10)
[1] 9
> wilcox.test(brainpairs$diff,conf.int=TRUE)

	Wilcoxon signed rank exact test

data:  brainpairs$diff
V = 32, p-value = 0.6953
alternative hypothesis: true location is not equal to 0
95 percent confidence interval:
 -32.0  49.5
sample estimates:
(pseudo)median 
            10 

>