Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Re-analysis of the data from '"What Went Right and What Went Wrong": An Analysis of 155 Postmortems from Game Development'
# Copyright (c) 2017 Nathan Hwang, "thenoviceoof"
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
################################################################################
# Run install.packages("Exact") in the R shell.
library(Exact)
args = commandArgs(trailingOnly=TRUE)
data = read.csv(file=args[1])
z_flag = args[2] == "True"
zc_flag = args[3] == "True"
t_flag = args[4] == "True"
f_flag = args[5] == "True"
b_csm_flag = args[6] == "True"
b_csm_approx_flag = args[7] == "True"
b_boschloo_flag = args[8] == "True"
# Just use the first row.
mat = matrix(
c(data[1, 1], data[1, 3], data[1, 2], data[1, 4]),
nrow = 2,
ncol = 2
)
# Suppress chi-squared warnings.
options(warn=-1)
# Z-test
if(z_flag) {
cat(prop.test(mat, correct = FALSE, alternative="two.sided")$p.value)
} else {
cat("")
}
cat("\n")
# Z-test with correction
if(zc_flag) {
cat(prop.test(mat, correct = TRUE, alternative="two.sided")$p.value)
} else {
cat("")
}
cat("\n")
options(warn=0)
# t-test
if(t_flag) {
t_test_x = c(rep.int(1, mat[1,1]), rep.int(0, mat[1,2]))
t_test_y = c(rep.int(1, mat[2,1]), rep.int(0, mat[2,2]))
if(length(t_test_x) > 1 && length(t_test_y) > 1) {
cat(t.test(t_test_x, t_test_y, alternative="two.sided")$p.value)
} else {
cat("")
}
} else {
cat("")
}
cat("\n")
# Fischer's exact test
if(f_flag) {
cat(fisher.test(mat, alternative="two.sided")$p.value)
} else {
cat("")
}
cat("\n")
# Barnard's test, CSM method
if(b_csm_flag && all(mat > 0)) {
cat(exact.test(mat, "two.sided", method="csm", model="Binomial")$p.value)
} else {
cat("")
}
cat("\n")
# Barnard's test, CSM method (approximate)
if(b_csm_approx_flag && all(mat > 0)) {
cat(exact.test(mat, "two.sided", method="csm approximate",
model="Binomial")$p.value)
} else {
cat("")
}
cat("\n")
# Barnard's test, Boschloo method
if(b_boschloo_flag && all(mat > 0)) {
cat(exact.test(mat, "two.sided", method="boschloo",
model="Multinomial")$p.value)
} else {
cat("")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment