moving to kibo
This commit is contained in:
parent
d2540759ab
commit
918066e98b
51
110124_supp_analysis/contrib_supp_analysis.r
Normal file
51
110124_supp_analysis/contrib_supp_analysis.r
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#library(tidyverse)
|
||||||
|
#library(plyr)
|
||||||
|
|
||||||
|
contrib_df <- read_csv("110124_contrib_strict_subset.csv")
|
||||||
|
#some preprocessing and expansion
|
||||||
|
col_order <- c("upstream_vcs_link", "age_in_days", "first_commit", "first_commit_dt", "event_gap", "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")
|
||||||
|
contrib_df <- contrib_df[,col_order]
|
||||||
|
contrib_df$ct_before_all <- str_split(gsub("[][]","", contrib_df$before_all_ct), ", ")
|
||||||
|
contrib_df$ct_after_all <- str_split(gsub("[][]","", contrib_df$after_all_ct), ", ")
|
||||||
|
contrib_df$ct_before_mrg <- str_split(gsub("[][]","", contrib_df$before_mrg_ct), ", ")
|
||||||
|
contrib_df$ct_after_mrg <- str_split(gsub("[][]","", contrib_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(contrib_df[1,])
|
||||||
|
for (i in 2:nrow(contrib_df)){
|
||||||
|
expanded_data <- rbind(expanded_data, expand_timeseries(contrib_df[i,]))
|
||||||
|
}
|
||||||
|
#filter out the windows of time that we're looking at
|
||||||
|
window_num <- 8
|
||||||
|
windowed_data <- expanded_data |>
|
||||||
|
filter(week >= (27 - window_num) & week <= (27 + window_num)) |>
|
||||||
|
mutate(D = ifelse(week > 27, 1, 0))
|
||||||
|
#scale the age numbers and calculate the week offset here
|
||||||
|
windowed_data$scaled_project_age <- scale(windowed_data$age_in_days)
|
||||||
|
windowed_data$scaled_event_gap <- scale(windowed_data$event_gap)
|
||||||
|
windowed_data$week_offset <- windowed_data$week - 27
|
||||||
|
#break out the different type of commit actions
|
||||||
|
all_actions_data <- windowed_data[which(windowed_data$observation_type == "all"),]
|
||||||
|
mrg_actions_data <- windowed_data[which(windowed_data$observation_type == "mrg"),]
|
||||||
|
# data is expanded, can look at things now
|
||||||
|
all_actions_data$logged_count <- log(all_actions_data$count)
|
||||||
|
all_actions_data$log1p_count <- log1p(all_actions_data$count)
|
||||||
|
|
||||||
|
#all_gmodel <- glmer.nb(log1p_count ~ D * week_offset + scaled_project_age + scaled_event_gap + (D * week_offset | upstream_vcs_link),
|
||||||
|
# control=glmerControl(optimizer="bobyqa",
|
||||||
|
# optCtrl=list(maxfun=2e5)), nAGQ=0, data=all_actions_data)
|
||||||
|
#saveRDS(all_gmodel, "0711_contrib_all_01.rda")
|
||||||
|
|
||||||
|
#all_residuals <- residuals(all_gmodel)
|
60
110124_supp_analysis/readme_supp_analysis.R
Normal file
60
110124_supp_analysis/readme_supp_analysis.R
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
library(readr)
|
||||||
|
library(plyr)
|
||||||
|
library(lme4)
|
||||||
|
library(stringr)
|
||||||
|
library(tidyr)
|
||||||
|
|
||||||
|
readme_df <- read_csv("110124_supp_analysis/110124_readme_strict_subset.csv")
|
||||||
|
|
||||||
|
col_order <- c("upstream_vcs_link", "age_in_days", "first_commit", "first_commit_dt", "event_gap", "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,]))
|
||||||
|
}
|
||||||
|
head(expanded_data)
|
||||||
|
#filter out the windows of time that we're looking at
|
||||||
|
window_num <- 8
|
||||||
|
windowed_data <- expanded_data |>
|
||||||
|
filter(week >= (27 - window_num) & week <= (27 + window_num)) |>
|
||||||
|
mutate(D = ifelse(week > 27, 1, 0))
|
||||||
|
#scale the age numbers
|
||||||
|
windowed_data$scaled_project_age <- scale(windowed_data$age_in_days)
|
||||||
|
windowed_data$scaled_event_gap <- scale(windowed_data$event_gap)
|
||||||
|
windowed_data$week_offset <- windowed_data$week - 27
|
||||||
|
#break out the different types of commit actions that are studied
|
||||||
|
all_actions_data <- windowed_data[which(windowed_data$observation_type == "all"),]
|
||||||
|
mrg_actions_data <- windowed_data[which(windowed_data$observation_type == "mrg"),]
|
||||||
|
#log the dependent
|
||||||
|
all_actions_data$logged_count <- log(all_actions_data$count)
|
||||||
|
all_actions_data$log1p_count <- log1p(all_actions_data$count)
|
||||||
|
range(all_actions_data$log1p_count)
|
||||||
|
|
||||||
|
|
||||||
|
var(all_actions_data$log1p_count)
|
||||||
|
mean (all_actions_data$log1p_count)
|
||||||
|
sd(all_actions_data$log1p_count)
|
||||||
|
median(all_actions_data$log1p_count)
|
||||||
|
var(all_actions_data$count)
|
||||||
|
mean (all_actions_data$count)
|
||||||
|
sd (all_actions_data$count)
|
||||||
|
median(all_actions_data$count)
|
Loading…
Reference in New Issue
Block a user