Skip to content

Instantly share code, notes, and snippets.

View alstat's full-sized avatar

Al Asaad alstat

View GitHub Profile
?cochran.qtest #after hitting 'Enter/Return' there should be
#another window to open for documentation or
#it will open on your default browser,
#depending on how you install R.
results <- c(1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,0,1,1,0,1,1,1,0,1)
results <- c(1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,0,1,1,0,1,1,1,0,1)
length(results) #if the output is 24 then you haven't miss
#any data to input.
methods <- factor(rep(LETTERS[1:4],6))
fabrics <- factor(rep(letters[1:6],each = 4))
tapply(results, list(fabrics,methods), sum)
A B C D
a 1 1 0 0
b 1 1 0 1
c 1 0 0 0
d 1 1 1 0
e 1 1 0 1
f 1 1 0 1
cochran.qtest(results~methods|fabrics)
Cochran Q test
results ~ methods , block = fabrics
Q df p.value signif
9.3158 3 0.025374 *
Pairwise comparisons by Wilcoxon sign test - correction: fdr
t.test(drug, placebo, alternative = "less", var.equal = F)
drug <-c(15,10,13,7,9,8,21,9,14,8)
placebo <-c(15,14,12,8,14,7,16,10,15,12)
t.test(drug, placebo, alternative = "less", var.equal = T)