require(foreign);require(lmtest);require(sandwich);require(oddsratio)
require(dplyr);require(effsize);require(car);require(pscl);require(pastecs)
require(MASS);library(effsize);library(epiR)
# Load the results
results <- read.table(
file = "results.csv",
sep = ',',
header = T,
na.strings = c("NA", "-1"))
# We only consider reviews in which there is at least 1 comment.
# This command excludes 7 participants.
results <- results %>% filter(Number.of.Comments > 0)
# All results of the first experiment, to answer RQ1
patch1 <- results %>% filter(CR.Exp.Type == "files_experiment1")
# All results of the second experiment, to answer RQ2
patch2 <- results %>% filter(CR.Exp.Type == "files_experiment2")
# Whether the participant has been primed in the psychologic experiment
psycho_exp_primed <- results %>% filter(Has.been.primed == "True")
psycho_exp_not_primed <- results %>% filter(Has.been.primed == "False")
# For both experiments, we split the participants in primed (test group) and
# not primed (control group)
patch1_primed <- patch1 %>% filter(Is.primed == "True")
patch1_not_primed <- patch1 %>% filter(Is.primed == "False")
patch2_primed <- patch2 %>% filter(Is.primed == "True")
patch2_not_primed <- patch2 %>% filter(Is.primed == "False")
####################### STATISTICAL MODEL ##############################
# This is the function to print the statistical model. As explained in the
# paper, we use a logistic regression model.
print_fit <- function(dataset,formula) {
fitglm <- glm(formula=formula, family=binomial(logit), data=dataset)
cov.m1 <- vcovHC(fitglm, type = "HC0")
std.err <- sqrt(diag(cov.m1))
q.val <- qnorm(0.975)
r.est <- cbind(
Estimate = coef(fitglm)
, "Robust SE" = std.err
, z = (coef(fitglm)/std.err)
, "Pr(>|z|) "= 2 * pnorm(abs(coef(fitglm)/std.err), lower.tail = FALSE)
, LL = coef(fitglm) - q.val  * std.err
, UL = coef(fitglm) + q.val  * std.err
)
print(summary(fitglm))
return(fitglm)
}
PR_not_found_bug_primed <- patch1_primed %>% filter(Found.bugA == "1")
PR_found_bug_primed <- patch1_primed %>% filter(Found.bugA == "0")
NPR_not_found_bug_primed <- patch1_not_primed %>% filter(Found.bugB == "1")
NPR_found_bug_primed <- patch1_not_primed %>% filter(Found.bugB == "0")
PR_not_found_bug_not_primed <- patch1_primed %>% filter(Found.bugB == "1")
PR_found_bug_not_primed <- patch1_primed %>% filter(Found.bugB == "0")
NPR_not_found_bug_not_primed <- patch1_not_primed %>% filter(Found.bugC == "1")
NPR_found_bug_not_primed <- patch1_not_primed %>% filter(Found.bugC == "0")
tab <- matrix(c(as.numeric(count(PR_found_bug_primed)),
as.numeric(count(PR_not_found_bug_primed)),
as.numeric(count(NPR_found_bug_primed)),
as.numeric(count(NPR_not_found_bug_primed))), ncol=2)
colnames(tab) <- c('test', 'control')
rownames(tab) <- c('found', 'not found')
# Odds radio of finding the primed bug in the 2 groups.
# In the paper, this is Table 3 (upper table).
epi.2by2(tab, method="cohort.count", conf.level=0.95)
require(foreign);require(lmtest);require(sandwich);require(oddsratio)
require(dplyr);require(effsize);require(car);require(pscl);require(pastecs)
require(MASS);library(effsize);library(epiR)
# Load the results
results <- read.table(
file = "results.csv",
sep = ',',
header = T,
na.strings = c("NA", "-1"))
# We only consider reviews in which there is at least 1 comment.
# This command excludes 7 participants.
results <- results %>% filter(Number.of.Comments > 0)
# All results of the first experiment, to answer RQ1
patch1 <- results %>% filter(CR.Exp.Type == "files_experiment1")
# All results of the second experiment, to answer RQ2
patch2 <- results %>% filter(CR.Exp.Type == "files_experiment2")
# Whether the participant has been primed in the psychologic experiment
psycho_exp_primed <- results %>% filter(Has.been.primed == "True")
psycho_exp_not_primed <- results %>% filter(Has.been.primed == "False")
# For both experiments, we split the participants in primed (test group) and
# not primed (control group)
patch1_primed <- patch1 %>% filter(Is.primed == "True")
patch1_not_primed <- patch1 %>% filter(Is.primed == "False")
patch2_primed <- patch2 %>% filter(Is.primed == "True")
patch2_not_primed <- patch2 %>% filter(Is.primed == "False")
####################### STATISTICAL MODEL ##############################
# This is the function to print the statistical model. As explained in the
# paper, we use a logistic regression model.
print_fit <- function(dataset,formula) {
fitglm <- glm(formula=formula, family=binomial(logit), data=dataset)
cov.m1 <- vcovHC(fitglm, type = "HC0")
std.err <- sqrt(diag(cov.m1))
q.val <- qnorm(0.975)
r.est <- cbind(
Estimate = coef(fitglm)
, "Robust SE" = std.err
, z = (coef(fitglm)/std.err)
, "Pr(>|z|) "= 2 * pnorm(abs(coef(fitglm)/std.err), lower.tail = FALSE)
, LL = coef(fitglm) - q.val  * std.err
, UL = coef(fitglm) + q.val  * std.err
)
print(summary(fitglm))
return(fitglm)
}
PR_not_found_bug_primed <- patch1_primed %>% filter(Found.bugA == "1")
PR_found_bug_primed <- patch1_primed %>% filter(Found.bugA == "0")
NPR_not_found_bug_primed <- patch1_not_primed %>% filter(Found.bugB == "1")
NPR_found_bug_primed <- patch1_not_primed %>% filter(Found.bugB == "0")
tab <- matrix(c(as.numeric(count(PR_found_bug_primed)),
as.numeric(count(PR_not_found_bug_primed)),
as.numeric(count(NPR_found_bug_primed)),
as.numeric(count(NPR_not_found_bug_primed))), ncol=2)
colnames(tab) <- c('test', 'control')
rownames(tab) <- c('found', 'not found')
# Odds radio of finding the primed bug in the 2 groups.
# In the paper, this is Table 3 (upper table).
epi.2by2(tab, method="cohort.count", conf.level=0.95)
PR_not_found_bug_not_primed <- patch1_primed %>% filter(Found.bugB == "1")
PR_found_bug_not_primed <- patch1_primed %>% filter(Found.bugB == "0")
NPR_not_found_bug_not_primed <- patch1_not_primed %>% filter(Found.bugC == "1")
NPR_found_bug_not_primed <- patch1_not_primed %>% filter(Found.bugC == "0")
tab <- matrix(c(as.numeric(count(PR_found_bug_not_primed)),
as.numeric(count(PR_not_found_bug_not_primed)),
as.numeric(count(NPR_found_bug_not_primed)),
as.numeric(count(NPR_not_found_bug_not_primed))), ncol=2)
colnames(tab) <- c('test', 'control')
rownames(tab) <- c('found', 'not found')
# Odds radio of finding the NOT primed bug in the 2 groups.
# In the paper, this is Table 3  (bottom table).
epi.2by2(tab, method="cohort.count")
# For convenience, we create 2 new columns, foundPrimed and foundNotPrimed, that are
# set to True if the participant found the primed bug and the not primed bug respectively.
patch1OK = patch1 %>%
mutate(foundPrimed = factor(case_when( patch1$Is.primed == "True" ~ (1 - patch1$Found.bugA) ,
patch1$Is.primed == "False" ~ (1 - patch1$Found.bugB))),
foundNotPrimed = factor(case_when(patch1$Is.primed == "True" ~ (1 - patch1$Found.bugB) ,
patch1$Is.primed == "False" ~ (1 - patch1$Found.bugC))))
# Regression model for the primed bug. Table 4 in the paper, left side.
print_fit(patch1OK, patch1OK$foundPrimed ~
patch1OK$Is.primed +
patch1OK$CR.time +
patch1OK$Developing.experience +
patch1OK$How.often.programming +
patch1OK$Code.Review.experience +
patch1OK$How.often.Code.Review +
patch1OK$Tired +
patch1OK$Hours.worked +
patch1OK$Interruption)
# Regression model for the NOT primed bug. Table 4 in the paper, right side
print_fit(patch1OK, patch1OK$foundNotPrimed ~
patch1OK$Is.primed +
patch1OK$CR.time +
patch1OK$Developing.experience +
patch1OK$How.often.programming +
patch1OK$Code.Review.experience +
patch1OK$How.often.Code.Review +
patch1OK$Tired +
patch1OK$Hours.worked +
patch1OK$Interruption)
PR_not_found_bug_primed <- patch2_primed %>% filter(Found.bugB == "1")
PR_found_bug_primed <- patch2_primed %>% filter(Found.bugB == "0")
NPR_not_found_bug_primed <- patch2_not_primed %>% filter(Found.bugC == "1")
NPR_found_bug_primed <- patch2_not_primed %>% filter(Found.bugC == "0")
tab <- matrix(c(as.numeric(count(PR_found_bug_primed)),
as.numeric(count(PR_not_found_bug_primed)),
as.numeric(count(NPR_found_bug_primed)),
as.numeric(count(NPR_not_found_bug_primed))), ncol=2)
colnames(tab) <- c('test', 'control')
rownames(tab) <- c('found', 'not found')
# Odds radio of finding the primed bug in the 2 groups.
# In the paper, this is Table 5 (upper table).
epi.2by2(tab, method="cohort.count", conf.level=0.95)
PR_not_found_bug_not_primed <- patch2_primed %>% filter(Found.bugA == "1")
PR_found_bug_not_primed <- patch2_primed %>% filter(Found.bugA == "0")
NPR_not_found_bug_not_primed <- patch2_not_primed %>% filter(Found.bugA == "1")
NPR_found_bug_not_primed <- patch2_not_primed %>% filter(Found.bugA == "0")
tab <- matrix(c(as.numeric(count(PR_found_bug_not_primed)),
as.numeric(count(PR_not_found_bug_not_primed)),
as.numeric(count(NPR_found_bug_not_primed)),
as.numeric(count(NPR_not_found_bug_not_primed))), ncol=2)
colnames(tab) <- c('test', 'control')
rownames(tab) <- c('found', 'not found')
# Odds radio of finding the NOT primed bug in the 2 groups.
# In the paper, this is Table 5 (bottom table).
epi.2by2(tab, method="cohort.count")
