-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignTest.R
More file actions
37 lines (29 loc) · 737 Bytes
/
SignTest.R
File metadata and controls
37 lines (29 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
rm(list = ls())
# reading data
datasrc <- "D_AAR_AARLO.csv"
my_data <- read.csv(datasrc)
my_data
rownames(my_data) <- my_data$Problem
my_data <- my_data[2:length(my_data)]
my_data
varnames <- colnames(my_data)
varnames
# calculate differences
my_data_diff <- my_data[,1]-my_data[,2]
# remove NAs and calculate sample size
my_data_diff[my_data_diff == 0.0] <- NA
my_data_diff <- my_data_diff[!is.na(my_data_diff)]
my_data_diff
n <- length(my_data_diff)
# calculate positives
pos <- length(my_data_diff[my_data_diff > 0.0])
neg <- n - pos
pos
neg
# set the success event (smaller of pos and neg)
x <- min(c(pos, neg))
x
# calculate p-value
p <- dbinom(x, size=n, prob=0.5)
p
# if p<0.05, there is a significant difference in median