binom.test(1, 10, p = 0.5)
binom.test(1, 100, p = 0.5)
binom.test(50, 100, p = 0.5)
binom.test(28, 39+28, p = 0.5)
binom.test(20, 39+28, p = 0.5)
binom.test(30, 39+28, p = 0.5)
binom.test(25, 39+28, p = 0.5)
binom.test(21, 29+21, p = 0.5)
binom.test(35, 35+14, p = 0.5)
binom.test(46, 46+29, p = 0.5)
binom.test(43, 43+34, p = 0.5)
binom.test(22, 55, p = 0.5)
binom.test(22, 53, p = 0.5)
binom.test(22, 530, p = 0.5)
binom.test(22, 53, p = 0.5)
binom.test(25, 53, p = 0.5)
binom.test(2, 53, p = 0.5)
binom.test(25, 53, p = 0.5)
binom.test(22, 53, p = 0.5)
chisq.test(table(x))            # NOT 'chisq.test(x)'!
## From Agresti(2007) p.39
## From Agresti(2007) p.39
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"),
party = c("Democrat","Independent", "Republican"))
(Xsq <- chisq.test(M))  # Prints test summary
Xsq$observed   # observed counts (same as M)
source('~/pearson-chi-squared.R', echo=TRUE)
source('~/pearson-chi-squared.R', echo=TRUE)
clear
clc''
clc;
cat("\014")
asd
source('~/pearson-chi-squared.R', echo=TRUE)
## From Agresti(2007) p.39
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"),
party = c("Democrat","Independent", "Republican"))
(Xsq <- chisq.test(M))  # Prints test summary
Xsq$observed   # observed counts (same as M)
Xsq$expected   # expected counts under the null
Xsq$residuals  # Pearson residuals
Xsq$stdres     # standardized residuals
762+327+468
484+239+477
1557+1200
(762+484)/2757*1557
chisq.test(M)
[5,5]
(5,5)
[5 5]
(5 5)
M
x
c(5,5)
chisq.test(c(5,5),c(1,9))
chisq.test(c(5,5,5),c(1,9,5))
x <- c(A = 20, B = 15, C = 25)
x
chisq.test(as.table(x))             # the same
x <- c(89,37,30,28,2)
p <- c(40,20,20,15,5)
try(
chisq.test(x, p = p)                # gives an error
)
chisq.test(x, p = p, rescale.p = TRUE)
x <- c(50,50)
p <- c(1,1)
chisq.test(x, p = p, rescale.p = TRUE)
p <- c(1,9)
chisq.test(x, p = p, rescale.p = TRUE)
binom.test(22, 53, p = 0.5)
binom.test(10, 10, p = 0.5)
binom.test(10, 10, p = 0.1)
binom.test(5, 10, p = 0.1)
chisq.test(x, p = p, rescale.p = TRUE)
x
p
root(1.8)
sqrt(1.8)
8/sqrt(1.8)
x
z.test(x, y = NULL, alternative = "two.sided", mu = 0, sigma.x = NULL,
sigma.y = NULL, conf.level = 0.95)
z.test
install.packages("BSDA")
z.test
library(BSDA)
Orange
z.test
x<-c(0,1,0,1,0,1)
x
sqrt(6*0.1*0.9)
(3-0.6)/sqrt(6*0.1*0.9)
chisq.test(c(3,3),p = c(0.5,0.5))
x2 <- c(3,3)
p
chisq.test(x2, p = p, rescale.p =  TRUE)
p
x2
3.265986* 3.265986
x
z.test(x,mu = 0.1, sigma.x = 0.7348469)
z.test(x,mu = 0.1, sigma.x = 0.7348469, alternative = "two.sided")
z.test(x,mu = 0.6, sigma.x = 0.7348469, alternative = "two.sided")
x
x2
x <- cbind(x,x)
x
x <- c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1)
x
z.test(x,mu = 84*0.1, sigma.x = sqrt(84*0.1*0.9), alternative = "two.sided")
z.test(x,mu = 0.1, sigma.x = sqrt(84*0.1*0.9), alternative = "two.sided")
z.test(x,mu = 0.1, sigma.x = sqrt(84*0.1*0.9)/84, alternative = "two.sided")
z.test(x,mu = 0.1, sigma.x = sqrt(0.1*0.9/84), alternative = "two.sided")
z.test(x,mu = 0.1, sigma.x = sqrt(0.1*0.9*84), alternative = "two.sided")
z.test(x,mu = 0.1, sigma.x = sqrt(0.1*0.9), alternative = "two.sided")
binom.test(3,6,p=0.1)
a <- binom.test(3,6,p=0.1)
a
a$statistic
a$parameter
a$method
x2
chisq.test(x2, p = p, rescale.p =  TRUE)
b <- chisq.test(x2, p = p, rescale.p =  TRUE)
b$p.value
b$statistic
sqrt(10.66667)
pnrm(-abs(3.265987))
pnprm(-abs(3.265987))
pnorm(-abs(3.265987))
pnorm(-abs(3.265987))*2
chisq.test(x2, p = p, rescale.p =  TRUE)
x2
x3 <- c(41,28,35)
p <- c(1,1,1)
chisq.test(x3, p = p, rescale.p =  TRUE)
x4 = (33,33,33)
x4 <- c(33,33,33)
chisq.test(x4, p = p, rescale.p =  TRUE)
x4 <- c(41,28)
p4 <= c(50,50)
p4 <- c(50,50)
chisq.test(x4, p = p4, rescale.p =  TRUE)
x5 <- c(28,35)
chisq.test(x5, p = p4, rescale.p =  TRUE)
x6 <- c(41,35)
chisq.test(x6, p = p4, rescale.p =  TRUE)
load("~/Documents/research/Responses/ChisquaredTest.R")
# Set2
# H0 : is step-by-step?
observed_total <- c(53,49)
expected <- c(2,22)
chisq.test(observed_total, p = expected, rescale.p =  TRUE)
writeLines("asd")
writeLines("asd\nasd")
cat("asd\nasd")
# Set2
cat("H0 : is step-by-step?")
observed_total <- c(53,49)
expected <- c(2,22)
chisq.test(observed_total, p = expected, rescale.p =  TRUE)
# Set2
# H0 : is step-by-step?
observed_total <- c(53,49)
observed_cse512 <- c(53,49)
observed_mturk <- c(53,49)
expected <- c(2,22)
chisq.test(observed_total, p = expected, rescale.p =  TRUE)
chisq.test(observed_cse512, p = expected, rescale.p =  TRUE)
chisq.test(observed_mturk, p = expected, rescale.p =  TRUE)
# Set2
# H0 : is step-by-step?
observed_total <- c(53,49)
observed_cse512 <- c(33,20)
observed_mturk <- c(20,29)
expected <- c(2,22)
chisq.test(observed_total, p = expected, rescale.p =  TRUE)
chisq.test(observed_cse512, p = expected, rescale.p =  TRUE)
chisq.test(observed_mturk, p = expected, rescale.p =  TRUE)
# Set2
# H0 : is step-by-step?
observed_total <- c(53,49)
observed_cse512 <- c(330,200)
observed_mturk <- c(20,29)
expected <- c(2,22)
chisq.test(observed_total, p = expected, rescale.p =  TRUE)
chisq.test(observed_cse512, p = expected, rescale.p =  TRUE)
chisq.test(observed_mturk, p = expected, rescale.p =  TRUE)
observed_total <- c(53,49)
observed_cse512 <- c(33,20)
observed_mturk <- c(30,30)
expected <- c(2,22)
chisq.test(observed_total, p = expected, rescale.p =  TRUE)
chisq.test(observed_cse512, p = expected, rescale.p =  TRUE)
chisq.test(observed_mturk, p = expected, rescale.p =  TRUE)
binom.test(53,53+49,2/22)
binom.test(33,33+20,2/22)
binom.test(20,20+29,2/22)
a <- binom.test(20,20+29,2/22)
a$statistic
a$parameter
a$data.name
a$estimate
a <- binom.test(33,33+20,2/22)
a$p.value
a <- binom.test(53,53+49,2/22)
a$p.value
binom.test(53,53+49,2/22)$p.value
#cse512
binom.test(38,38+15,24/720)$p.value
#mturk
binom.test(46,46+8,24/720)$p.value
#total
binom.test(84,84+23,24/720)$p.value
#cse512
binom.test(45,45+8,0.5)$p.value
#mturk
binom.test(41,41+13,0.5)$p.value
#total
binom.test(86,86+21,0.5)$p.value
# Set8
# H0 : Add Field vs Remove Field
#cse512
binom.test(30,30+23,0.5)$p.value
#mturk
binom.test(24,24+30,0.5)$p.value
#total
binom.test(54,54+53,0.5)$p.value
# Set8
# H0 : Transpose vs Filter
#cse512
binom.test(38,38+15,0.5)$p.value
#mturk
binom.test(23,23+31,0.5)$p.value
#total
binom.test(61,61+46,0.5)$p.value
# Set11
# H0 : Add Filter vs Remove Filter
#cse512
binom.test(29,29+24,0.5)$p.value
#mturk
binom.test(29,29+25,0.5)$p.value
#total
binom.test(58,58+49,0.5)$p.value
### --------------------------------------------------------------
###  Second Mendel example, multinomial exact test, p. 35–36
###     and SAS example, p. 38
### --------------------------------------------------------------
observed = c(315, 108, 101, 32)
expected = c(9, 3, 3, 1)
library(XNomial)
xmulti(observed,
expected,
detail = 2)              # reports three types of p-value
install.packages('XNomial')
library(XNomial)
observed = c(315, 108, 101, 32)
expected = c(9, 3, 3, 1)
library(XNomial)
xmulti(observed,
expected,
detail = 2)              # reports three types of p-value
xmulti(observed,
expected)              # reports three types of p-value
# Set13
# H0 : Bin vs Aggregate vs Filter
expected = c(1, 1, 1)
#cse512
observed = c(23, 17, 12)
xmulti(observed,
expected,
detail = 2)              # reports three types of p-value. I use the second one.
#mturk
observed = c(18, 11, 23)
xmulti(observed,
expected,
detail = 2)
#total
observed = c(41, 26, 35)
xmulti(observed,
expected,
detail = 2)
binom.test(53,53+49,2/22)
binom.test(53,53+101,2/24)
binom.test(53,101,2/24)
binom.test(49,53,1/2)
binom.test(23,23+31,1/2)
binom.test(22,22+31,1/2)
binom.test(14,14+37,1/2)
binom.test(48+4,99,1/2)
binom.test(32,51,1/2)
binom.test(32,51,1/24)
binom.test(32,51,2/24)
binom.test(48+4,99,2/24)
chisq.test([1/2,1/2])
chisq.test(c(1/2,1/2)
)
chisq.test(c(28,51))
chisq.test(c(28,23))
chisq.test(c(28,23),c(0.1,0.9))
chisq.test(c(28,23),p=c(0.1,0.9))
a <- chisq.test(c(28,23))
a$parameter
summary(a)
a$statistic
sqrt(0.4901961/51)
install.packages("pwr", repos="http://cran.r-project.org")
library(pwr)
pwr.chisq.test(0.09803922,51,1)
a <- chisq.test(c(37,51-37))
w <- sqrt(a$statistic/51)
w
pwr.chisq.test(w,51,1)
pwr.chisq.test(w,41,1)
N=51;
proportion = c(37,N-37);
chisqTest <- chisq.test(proportion);
w <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(w,N,1)
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 33;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 33;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion)
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 33;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion);
summary(chisqTest);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 33;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 34;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 35;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 36;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
N=51;
p = 36;
proportion = c(p,N-p);
proportion = c(26,11,14);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,1)
chisqTest
proportion.length
length(proportion)
N=51;
p = 36;
proportion = c(p,N-p);
proportion = c(26,11,14);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,length(proportion)-1)
N=51;
p = 36;
proportion = c(p,N-p);
proportion = c(32,12,7);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,length(proportion)-1)
N=51;
p = 36;
proportion = c(p,N-p);
chisqTest <- chisq.test(proportion);
print(chisqTest$p.value);
effectiveSize <- sqrt(chisqTest$statistic/N);
pwr.chisq.test(effectiveSize,N,length(proportion)-1)
setwd("~/Documents/research/papers-graphscape/supplementary_material/evaluation_study")
responses = read.csv('ratings.csv')
responses = responses[responses$corrected_quiz==3,]
responses[, 'task_id'] <- as.factor(responses[,'task_id'])	#id of question / set of sequences / task
responses['seq_id'] = as.factor(substr(responses[,'seq_global_id'],3,3)) #sequence id in each task. (1 to 5)
responses[, 'seq_global_id'] <- as.factor(responses[,'seq_global_id']) #sequence id across all tasks. combination of task_id and seq_id
responses[, 'user_id'] <- as.factor(responses[,'user_id'])
responses[, 'graphscape'] <- as.factor(ifelse(responses[, 'graphscape']=='yes',TRUE,FALSE))
responses[, 'rating'] <- as.numeric(responses[,'rating'])
responses[, 'position'] <- as.numeric(floor(responses[,'position']/2) +1) #where the sequence are presented in each task. (it was randomly placed.)
View(responses)
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
library(lme4)
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
summary(full.model);
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id), REML=FALSE,  data=responses);
summary(full.model);
responses = read.csv('ratings.csv')
responses[, 'position'] <- as.numeric(floor(responses[,'position']/2) +1) #where the sequence are presented in each task. (it was randomly placed.)
responses[, 'rating'] <- as.numeric(responses[,'rating'])
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
summary(full.model);
responses[, 'graphscape'] <- as.factor(ifelse(responses[, 'graphscape']=='yes',TRUE,FALSE))
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
summary(full.model);
summary(responses)
responses[, 'user_id'] <- as.factor(responses[,'user_id'])
responses[, 'task_id'] <- as.factor(responses[,'task_id'])	#id of question / set of sequences / task
summary(responses)
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
summary(full.model);
responses[, 'rating'] <- as.numeric(responses[,'rating'])
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
responses[, 'rating'] <- as.numeric(responses[,'rating'])
responses = responses[responses$corrected_quiz==3,]
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
responses = read.csv('ratings.csv')
responses = responses[responses$corrected_quiz==3,]
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
View(responses)
responses = read.csv('ratings.csv')
responses = responses[responses$corrected_quiz==3,]
responses[, 'task_id'] <- as.factor(responses[,'task_id'])	#id of question / set of sequences / task
responses['seq_id'] = as.factor(substr(responses[,'seq_global_id'],3,3)) #sequence id in each task. (1 to 5)
responses[, 'seq_global_id'] <- as.factor(responses[,'seq_global_id']) #sequence id across all tasks. combination of task_id and seq_id
responses[, 'user_id'] <- as.factor(responses[,'user_id'])
responses[, 'graphscape'] <- as.factor(ifelse(responses[, 'graphscape']=='yes',TRUE,FALSE))
responses[, 'rating'] <- as.numeric(responses[,'rating'])
# Fit Linear Mixed-Effects Model
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
summary(full.model);
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
library(simr)
powerSim(full.model)
fixef(full.model)
fixef(full.model)[1]
fixef(full.model)[2]
fixef(full.model)[2] <- 0.5
powerSim(full.model, nsim = 10)
fixef(full.model)[2] <- 0.3
powerSim(full.model, nsim = 10)
# Fit Linear Mixed-Effects Model
install.packages('simr')
library(simr)
responses = read.csv('ratings.csv')
responses = responses[responses$corrected_quiz==3,]
responses[, 'task_id'] <- as.factor(responses[,'task_id'])	#id of question / set of sequences / task
responses['seq_id'] = as.factor(substr(responses[,'seq_global_id'],3,3)) #sequence id in each task. (1 to 5)
responses[, 'seq_global_id'] <- as.factor(responses[,'seq_global_id']) #sequence id across all tasks. combination of task_id and seq_id
responses[, 'user_id'] <- as.factor(responses[,'user_id'])
responses[, 'graphscape'] <- as.factor(ifelse(responses[, 'graphscape']=='yes',TRUE,FALSE))
responses[, 'rating'] <- as.numeric(responses[,'rating'])
# Fit Linear Mixed-Effects Model
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
powerSim(full.model, nsim = 10)
install.packages("simr")
library(simr)
responses = read.csv('ratings.csv')
responses = responses[responses$corrected_quiz==3,]
responses[, 'task_id'] <- as.factor(responses[,'task_id'])	#id of question / set of sequences / task
responses['seq_id'] = as.factor(substr(responses[,'seq_global_id'],3,3)) #sequence id in each task. (1 to 5)
responses[, 'seq_global_id'] <- as.factor(responses[,'seq_global_id']) #sequence id across all tasks. combination of task_id and seq_id
responses[, 'user_id'] <- as.factor(responses[,'user_id'])
responses[, 'graphscape'] <- as.factor(ifelse(responses[, 'graphscape']=='yes',TRUE,FALSE))
responses[, 'rating'] <- as.numeric(responses[,'rating'])
# Fit Linear Mixed-Effects Model
full.model <- lmer(rating  ~ graphscape + position + (1 + position | user_id) + (1 + position | task_id),  data=responses);
powerSim(full.model, nsim = 10)
fixef(full.model)[2] <- 0.3
powerSim(full.model, nsim = 10)
