filename cleaning
This commit is contained in:
parent
9e22d4adfe
commit
a0ab5720fa
566
R/.Rhistory
566
R/.Rhistory
@ -1,286 +1,3 @@
|
|||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
length(ages)
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(readme_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
length(ages)
|
|
||||||
readme_df$age_of_project = full_df$age_of_project[full_df$upstream_vcs_link == readme_df$upstream_vcs_link]
|
|
||||||
View(readme_df)
|
|
||||||
readme_df$age_of_project = ages
|
|
||||||
View(readme_df)
|
|
||||||
write.csv(readme_df, "deb_readme_data_4_19.csv", row.names=FALSE)
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(contributing_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(contributing_df)){
|
|
||||||
link <- readme_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
contributing_df$age_of_project = ages
|
|
||||||
write.csv(contributing_df, "deb_contributing_data_4_19.csv", row.names=FALSE)
|
|
||||||
View(contributing_df)
|
|
||||||
View(contributing_df)
|
|
||||||
View(readme_df)
|
|
||||||
View(contributing_df)
|
|
||||||
View(contributing_df)
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
View(contributing_df)
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(contributing_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(contributing_df)){
|
|
||||||
link <- contributing_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(contributing_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(contributing_df)){
|
|
||||||
link <- contributing_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#set wd, read in data
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
contributing_df <- read_csv("../final_data/deb_contrib_did.csv")
|
|
||||||
full_df <- read_csv("../final_data/deb_full_data.csv")
|
|
||||||
#preprocessing for readme_df
|
|
||||||
colnames(contributing_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
ages <- c()
|
|
||||||
projects <- c()
|
|
||||||
for (i in 1:nrow(contributing_df)){
|
|
||||||
link <- contributing_df[i,]$upstream_vcs_link
|
|
||||||
age <- full_df$age_of_project[full_df$upstream_vcs_link == link]
|
|
||||||
project <- full_df$project_name[full_df$upstream_vcs_link == link]
|
|
||||||
ages <- c(ages, age)
|
|
||||||
if (length(project) != 1){
|
|
||||||
project
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
projects <- c(projects, project)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
contributing_df$age_of_project = ages
|
|
||||||
write.csv(contributing_df, "deb_contributing_data_4_19.csv", row.names=FALSE)
|
|
||||||
# 0 loading the readme data in
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
# 0 loading the readme data in
|
|
||||||
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
|
||||||
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
||||||
View(readme_df)
|
|
||||||
# 1 preprocessing
|
|
||||||
#colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
|
||||||
col_order <- c("upstream_vcs_link", "age_of_project", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
||||||
readme_df <- readme_df[,col_order]
|
|
||||||
readme_df$ct_before_all <- str_split(gsub("[][]","", readme_df$before_all_ct), ", ")
|
|
||||||
View(readme_df)
|
|
||||||
View(readme_df)
|
|
||||||
readme_df$ct_after_all <- str_split(gsub("[][]","", readme_df$after_all_ct), ", ")
|
|
||||||
readme_df$ct_before_mrg <- str_split(gsub("[][]","", readme_df$before_mrg_ct), ", ")
|
|
||||||
readme_df$ct_after_mrg <- str_split(gsub("[][]","", readme_df$after_mrg_ct), ", ")
|
|
||||||
drop <- c("before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct")
|
|
||||||
readme_df = readme_df[,!(names(readme_df) %in% drop)]
|
|
||||||
View(readme_df)
|
|
||||||
# 2 some expansion needs to happens for each project
|
|
||||||
expand_timeseries <- function(project_row) {
|
|
||||||
longer <- project_row |>
|
|
||||||
pivot_longer(cols = starts_with("ct"),
|
|
||||||
names_to = "window",
|
names_to = "window",
|
||||||
values_to = "count") |>
|
values_to = "count") |>
|
||||||
unnest(count)
|
unnest(count)
|
||||||
@ -510,3 +227,286 @@ poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_pr
|
|||||||
summary(poisson_all_model)
|
summary(poisson_all_model)
|
||||||
poisson_residuals <- residuals(poisson_all_model)
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
qqnorm(poisson_residuals)
|
qqnorm(poisson_residuals)
|
||||||
|
# this is the file with the lmer multi-level rddAnalysis
|
||||||
|
library(tidyverse)
|
||||||
|
library(plyr)
|
||||||
|
# 0 loading the readme data in
|
||||||
|
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
||||||
|
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
||||||
|
# 1 preprocessing
|
||||||
|
#colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
||||||
|
col_order <- c("upstream_vcs_link", "age_of_project", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
||||||
|
readme_df <- readme_df[,col_order]
|
||||||
|
readme_df$ct_before_all <- str_split(gsub("[][]","", readme_df$before_all_ct), ", ")
|
||||||
|
readme_df$ct_after_all <- str_split(gsub("[][]","", readme_df$after_all_ct), ", ")
|
||||||
|
readme_df$ct_before_mrg <- str_split(gsub("[][]","", readme_df$before_mrg_ct), ", ")
|
||||||
|
readme_df$ct_after_mrg <- str_split(gsub("[][]","", readme_df$after_mrg_ct), ", ")
|
||||||
|
drop <- c("before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct")
|
||||||
|
# 2 some expansion needs to happens for each project
|
||||||
|
expand_timeseries <- function(project_row) {
|
||||||
|
longer <- project_row |>
|
||||||
|
pivot_longer(cols = starts_with("ct"),
|
||||||
|
names_to = "window",
|
||||||
|
values_to = "count") |>
|
||||||
|
unnest(count)
|
||||||
|
longer$observation_type <- gsub("^.*_", "", longer$window)
|
||||||
|
longer <- ddply(longer, "observation_type", transform, week=seq(from=0, by=1, length.out=length(observation_type)))
|
||||||
|
longer$count <- as.numeric(longer$count)
|
||||||
|
#longer <- longer[which(longer$observation_type == "all"),]
|
||||||
|
return(longer)
|
||||||
|
}
|
||||||
|
expanded_data <- expand_timeseries(readme_df[1,])
|
||||||
|
for (i in 2:nrow(readme_df)){
|
||||||
|
expanded_data <- rbind(expanded_data, expand_timeseries(readme_df[i,]))
|
||||||
|
}
|
||||||
|
#filter out the windows of time that we're looking at
|
||||||
|
window_num <- 8
|
||||||
|
expanded_data <- expanded_data |>
|
||||||
|
filter(week >= (26 - window_num) & week <= (26 + window_num)) |>
|
||||||
|
mutate(D = ifelse(week > 26, 1, 0))
|
||||||
|
# this is the file with the lmer multi-level rddAnalysis
|
||||||
|
library(tidyverse)
|
||||||
|
library(plyr)
|
||||||
|
# 0 loading the readme data in
|
||||||
|
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
||||||
|
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
||||||
|
# 1 preprocessing
|
||||||
|
#colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
||||||
|
col_order <- c("upstream_vcs_link", "age_of_project", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
||||||
|
readme_df <- readme_df[,col_order]
|
||||||
|
readme_df$ct_before_all <- str_split(gsub("[][]","", readme_df$before_all_ct), ", ")
|
||||||
|
readme_df$ct_after_all <- str_split(gsub("[][]","", readme_df$after_all_ct), ", ")
|
||||||
|
readme_df$ct_before_mrg <- str_split(gsub("[][]","", readme_df$before_mrg_ct), ", ")
|
||||||
|
readme_df$ct_after_mrg <- str_split(gsub("[][]","", readme_df$after_mrg_ct), ", ")
|
||||||
|
drop <- c("before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct")
|
||||||
|
readme_df = readme_df[,!(names(readme_df) %in% drop)]
|
||||||
|
# 2 some expansion needs to happens for each project
|
||||||
|
expand_timeseries <- function(project_row) {
|
||||||
|
longer <- project_row |>
|
||||||
|
pivot_longer(cols = starts_with("ct"),
|
||||||
|
names_to = "window",
|
||||||
|
values_to = "count") |>
|
||||||
|
unnest(count)
|
||||||
|
longer$observation_type <- gsub("^.*_", "", longer$window)
|
||||||
|
longer <- ddply(longer, "observation_type", transform, week=seq(from=0, by=1, length.out=length(observation_type)))
|
||||||
|
longer$count <- as.numeric(longer$count)
|
||||||
|
#longer <- longer[which(longer$observation_type == "all"),]
|
||||||
|
return(longer)
|
||||||
|
}
|
||||||
|
expanded_data <- expand_timeseries(readme_df[1,])
|
||||||
|
for (i in 2:nrow(readme_df)){
|
||||||
|
expanded_data <- rbind(expanded_data, expand_timeseries(readme_df[i,]))
|
||||||
|
}
|
||||||
|
#filter out the windows of time that we're looking at
|
||||||
|
window_num <- 8
|
||||||
|
windowed_data <- expanded_data |>
|
||||||
|
filter(week >= (26 - window_num) & week <= (26 + window_num)) |>
|
||||||
|
mutate(D = ifelse(week > 26, 1, 0))
|
||||||
|
#scale the age numbers
|
||||||
|
windowed_data$scaled_project_age <- scale(windowed_data$age_of_project)
|
||||||
|
#separate out the cleaning d
|
||||||
|
all_actions_data <- windowed_data[which(windowed_data$observation_type == "all"),]
|
||||||
|
mrg_actions_data <- windowed_data[which(windowed_data$observation_type == "mrg"),]
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
# 3 rdd in lmer analysis
|
||||||
|
# rdd: https://rpubs.com/phle/r_tutorial_regression_discontinuity_design
|
||||||
|
# lmer: https://www.youtube.com/watch?v=LzAwEKrn2Mc
|
||||||
|
library(lme4)
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
#logistic regression mixed effects
|
||||||
|
log_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link),data=all_actions_data, family = binomial)
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(scale(count) ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"), control=glmerControl(optimizer="bobyqa"))
|
||||||
|
#logistic regression mixed effects
|
||||||
|
log_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link),data=all_actions_data, family = binomial)
|
||||||
|
qqnorm(poisson_residuals)
|
||||||
|
summary(poisson_all_model)
|
||||||
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
|
qqnorm(poisson_residuals)
|
||||||
|
#logistic regression mixed effects (doesn't work)
|
||||||
|
log_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + upstream_vcs_link |upstream_vcs_link),data=all_actions_data, family = binomial)
|
||||||
|
#logistic regression mixed effects (doesn't work)
|
||||||
|
log_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link),data=all_actions_data, family = binomial)
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + upstream_vcs_link |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (D ||upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
|
qqnorm(poisson_residuals)
|
||||||
|
lmer_all_model <- lmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (D ||upstream_vcs_link), REML=FALSE, data=all_actions_data)
|
||||||
|
summary(lmer_all_model)
|
||||||
|
lmer_residuals <- residuals(lmer_all_model)
|
||||||
|
qqnorm(lmer_residuals)
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (D ||upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
|
qqnorm(poisson_residuals)
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
# this is the file with the lmer multi-level rddAnalysis
|
||||||
|
library(tidyverse)
|
||||||
|
library(plyr)
|
||||||
|
# 0 loading the readme data in
|
||||||
|
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
||||||
|
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
||||||
|
# 1 preprocessing
|
||||||
|
#colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
||||||
|
col_order <- c("upstream_vcs_link", "age_of_project", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
||||||
|
readme_df <- readme_df[,col_order]
|
||||||
|
readme_df$ct_before_all <- str_split(gsub("[][]","", readme_df$before_all_ct), ", ")
|
||||||
|
readme_df$ct_after_all <- str_split(gsub("[][]","", readme_df$after_all_ct), ", ")
|
||||||
|
readme_df$ct_before_mrg <- str_split(gsub("[][]","", readme_df$before_mrg_ct), ", ")
|
||||||
|
readme_df$ct_after_mrg <- str_split(gsub("[][]","", readme_df$after_mrg_ct), ", ")
|
||||||
|
drop <- c("before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct")
|
||||||
|
readme_df = readme_df[,!(names(readme_df) %in% drop)]
|
||||||
|
# 2 some expansion needs to happens for each project
|
||||||
|
expand_timeseries <- function(project_row) {
|
||||||
|
longer <- project_row |>
|
||||||
|
pivot_longer(cols = starts_with("ct"),
|
||||||
|
names_to = "window",
|
||||||
|
values_to = "count") |>
|
||||||
|
unnest(count)
|
||||||
|
longer$observation_type <- gsub("^.*_", "", longer$window)
|
||||||
|
longer <- ddply(longer, "observation_type", transform, week=seq(from=0, by=1, length.out=length(observation_type)))
|
||||||
|
longer$count <- as.numeric(longer$count)
|
||||||
|
#longer <- longer[which(longer$observation_type == "all"),]
|
||||||
|
return(longer)
|
||||||
|
}
|
||||||
|
expanded_data <- expand_timeseries(readme_df[1,])
|
||||||
|
for (i in 2:nrow(readme_df)){
|
||||||
|
expanded_data <- rbind(expanded_data, expand_timeseries(readme_df[i,]))
|
||||||
|
}
|
||||||
|
#filter out the windows of time that we're looking at
|
||||||
|
window_num <- 8
|
||||||
|
windowed_data <- expanded_data |>
|
||||||
|
filter(week >= (26 - window_num) & week <= (26 + window_num)) |>
|
||||||
|
mutate(D = ifelse(week > 26, 1, 0))
|
||||||
|
#scale the age numbers
|
||||||
|
windowed_data$scaled_project_age <- scale(windowed_data$age_of_project)
|
||||||
|
#separate out the cleaning d
|
||||||
|
all_actions_data <- windowed_data[which(windowed_data$observation_type == "all"),]
|
||||||
|
mrg_actions_data <- windowed_data[which(windowed_data$observation_type == "mrg"),]
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
# there's a conversation to be had between whether (D |upstream_vcs_link) or (D || upstream_vcs_link)
|
||||||
|
# https://www.bristol.ac.uk/cmm/learning/videos/random-intercepts.html#exvar
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
poisson_test_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_test_model)
|
||||||
|
summary(poisson_all_model)
|
||||||
|
summary(poisson_test_model)
|
||||||
|
poisson_test_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (D ||upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_test_model)
|
||||||
|
summary(poisson_all_model)
|
||||||
|
summary(poisson_test_model)
|
||||||
|
summary(poisson_all_model)
|
||||||
|
summary(poisson_test_model)
|
||||||
|
poisson_testing_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 | upstream_vcs_link) + (0 + D |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_testing_model)
|
||||||
|
#| label: packages
|
||||||
|
#| echo: true
|
||||||
|
library(tidyverse)
|
||||||
|
library(tidytext)
|
||||||
|
library(textdata)
|
||||||
|
library(textstem)
|
||||||
|
library(tidymodels)
|
||||||
|
#| label: packages
|
||||||
|
#| echo: true
|
||||||
|
library(tidyverse)
|
||||||
|
library(tidytext)
|
||||||
|
library(textdata)
|
||||||
|
library(textstem)
|
||||||
|
library(tidymodels)
|
||||||
|
#| label: data 1
|
||||||
|
#| echo: true
|
||||||
|
#|
|
||||||
|
reviews_df <- read_csv("data/rotten_tomatoes_critic_reviews.csv")
|
||||||
|
reviews_df |> head(2) |> kableExtra::kable()
|
||||||
|
summary(poisson_test_model)
|
||||||
|
summary(poisson_all_model)
|
||||||
|
summary(poisson_all_model)
|
||||||
|
summary(poisson_test_model)
|
||||||
|
#if I'm reading the residuals right, the poisson is better?
|
||||||
|
# there's a conversation to be had between whether (D |upstream_vcs_link) or (D || upstream_vcs_link)
|
||||||
|
# https://www.bristol.ac.uk/cmm/learning/videos/random-intercepts.html#exvar
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (week |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
|
qqnorm(poisson_residuals)
|
||||||
|
poisson_test_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (week ||upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_test_model)
|
||||||
|
summary(poisson_all_model)
|
||||||
|
# https://www.bristol.ac.uk/cmm/learning/videos/random-intercepts.html#exvar
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (1 + week |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
|
qqnorm(poisson_residuals)
|
||||||
|
# https://www.bristol.ac.uk/cmm/learning/videos/random-intercepts.html#exvar
|
||||||
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (week |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_all_model)
|
||||||
|
ICC(outcome="count", group="week", data=all_actions_data)
|
||||||
|
library(merTools)
|
||||||
|
ICC(outcome="count", group="week", data=all_actions_data)
|
||||||
|
# this is the file with the lmer multi-level rddAnalysis
|
||||||
|
library(tidyverse)
|
||||||
|
library(plyr)
|
||||||
|
# 0 loading the readme data in
|
||||||
|
try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path)))
|
||||||
|
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
||||||
|
# 1 preprocessing
|
||||||
|
#colnames(readme_df) <- c("upstream_vcs_link", "event_date", "event_hash", "before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct", "before_auth_new", "after_commit_new", "after_auth_new", "before_commit_new")
|
||||||
|
col_order <- c("upstream_vcs_link", "age_of_project", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
||||||
|
readme_df <- readme_df[,col_order]
|
||||||
|
readme_df$ct_before_all <- str_split(gsub("[][]","", readme_df$before_all_ct), ", ")
|
||||||
|
readme_df$ct_after_all <- str_split(gsub("[][]","", readme_df$after_all_ct), ", ")
|
||||||
|
readme_df$ct_before_mrg <- str_split(gsub("[][]","", readme_df$before_mrg_ct), ", ")
|
||||||
|
readme_df$ct_after_mrg <- str_split(gsub("[][]","", readme_df$after_mrg_ct), ", ")
|
||||||
|
drop <- c("before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct")
|
||||||
|
readme_df = readme_df[,!(names(readme_df) %in% drop)]
|
||||||
|
# 2 some expansion needs to happens for each project
|
||||||
|
expand_timeseries <- function(project_row) {
|
||||||
|
longer <- project_row |>
|
||||||
|
pivot_longer(cols = starts_with("ct"),
|
||||||
|
names_to = "window",
|
||||||
|
values_to = "count") |>
|
||||||
|
unnest(count)
|
||||||
|
longer$observation_type <- gsub("^.*_", "", longer$window)
|
||||||
|
longer <- ddply(longer, "observation_type", transform, week=seq(from=0, by=1, length.out=length(observation_type)))
|
||||||
|
longer$count <- as.numeric(longer$count)
|
||||||
|
#longer <- longer[which(longer$observation_type == "all"),]
|
||||||
|
return(longer)
|
||||||
|
}
|
||||||
|
expanded_data <- expand_timeseries(readme_df[1,])
|
||||||
|
for (i in 2:nrow(readme_df)){
|
||||||
|
expanded_data <- rbind(expanded_data, expand_timeseries(readme_df[i,]))
|
||||||
|
}
|
||||||
|
#filter out the windows of time that we're looking at
|
||||||
|
window_num <- 8
|
||||||
|
windowed_data <- expanded_data |>
|
||||||
|
filter(week >= (26 - window_num) & week <= (26 + window_num)) |>
|
||||||
|
mutate(D = ifelse(week > 26, 1, 0))
|
||||||
|
#scale the age numbers
|
||||||
|
windowed_data$scaled_project_age <- scale(windowed_data$age_of_project)
|
||||||
|
#separate out the cleaning d
|
||||||
|
all_actions_data <- windowed_data[which(windowed_data$observation_type == "all"),]
|
||||||
|
mrg_actions_data <- windowed_data[which(windowed_data$observation_type == "mrg"),]
|
||||||
|
# for visualization, may have to run model for each project and then identify top 5 projects for RDD graphs
|
||||||
|
#
|
||||||
|
#
|
||||||
|
poisson_mrg_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (week |upstream_vcs_link), data=mrg_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_mrg_model)
|
||||||
|
poisson_mrg_residuals <- residuals(poisson_mrg_model)
|
||||||
|
qqnorm(poisson_mrg_residuals)
|
||||||
|
@ -53,18 +53,18 @@ qqplot(all_actions_data$count, y)
|
|||||||
# rdd: https://rpubs.com/phle/r_tutorial_regression_discontinuity_design
|
# rdd: https://rpubs.com/phle/r_tutorial_regression_discontinuity_design
|
||||||
# lmer: https://www.youtube.com/watch?v=LzAwEKrn2Mc
|
# lmer: https://www.youtube.com/watch?v=LzAwEKrn2Mc
|
||||||
library(lme4)
|
library(lme4)
|
||||||
lmer_all_model <- lmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (D ||upstream_vcs_link), REML=FALSE, data=all_actions_data)
|
|
||||||
summary(lmer_all_model)
|
|
||||||
lmer_residuals <- residuals(lmer_all_model)
|
|
||||||
qqnorm(lmer_residuals)
|
|
||||||
# https://www.bristol.ac.uk/cmm/learning/videos/random-intercepts.html#exvar
|
# https://www.bristol.ac.uk/cmm/learning/videos/random-intercepts.html#exvar
|
||||||
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (week |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
poisson_all_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (week |upstream_vcs_link), data=all_actions_data, family = poisson(link = "log"))
|
||||||
summary(poisson_all_model)
|
summary(poisson_all_model)
|
||||||
poisson_residuals <- residuals(poisson_all_model)
|
poisson_residuals <- residuals(poisson_all_model)
|
||||||
qqnorm(poisson_residuals)
|
qqnorm(poisson_residuals)
|
||||||
# Performance:
|
# for visualization, may have to run model for each project and then identify top 5 projects for RDD graphs
|
||||||
draft_mrg_model <- lmer(count ~ D * I(week - 26) + scaled_project_age + (1 + D |upstream_vcs_link), REML=FALSE, data=mrg_actions_data)
|
#
|
||||||
summary(draft_mrg_model)
|
#
|
||||||
|
poisson_mrg_model <- glmer(count ~ D + I(week - 26) + D:I(week - 26) + scaled_project_age + (week |upstream_vcs_link), data=mrg_actions_data, family = poisson(link = "log"))
|
||||||
|
summary(poisson_mrg_model)
|
||||||
|
poisson_mrg_residuals <- residuals(poisson_mrg_model)
|
||||||
|
qqnorm(poisson_mrg_residuals)
|
||||||
# Performance:
|
# Performance:
|
||||||
|
|
||||||
library(merTools)
|
library(merTools)
|
Loading…
Reference in New Issue
Block a user