46 lines
1.6 KiB
R
46 lines
1.6 KiB
R
library(tidyverse)
|
|
count_data_fp <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/event_0215_ve_weekly_commit_count_data.csv"
|
|
input_df <- read.csv(count_data_fp, header = TRUE)
|
|
|
|
library(rdd)
|
|
|
|
var(input_df$commit_count) # 1253.343
|
|
mean(input_df$commit_count) # 44.92381
|
|
median(input_df$commit_count) # 39.5
|
|
|
|
get_optimal_bandwidth <- function(df){
|
|
bw <- tryCatch({
|
|
IKbandwidth(df$relative_week, df$commit_count, cutpoint = 0, verbose = FALSE, kernel = "triangular")
|
|
}, error = function(e) {
|
|
NA
|
|
})
|
|
}
|
|
|
|
optimal_bandwidth <- get_optimal_bandwidth(input_df)
|
|
|
|
window_num <- 19
|
|
input_df <- input_df |>
|
|
filter(relative_week >= (- window_num) & relative_week <= (window_num)) |>
|
|
mutate(other_commit_count = commit_count - bot_commit_count - mediawiki_dev_commit_count - wikia_commit_count - wikimedia_commit_count - jenkins_commit_count)
|
|
|
|
|
|
simple_model <- glm.nb(commit_count~before_after*relative_week, data=input_df)
|
|
summary(simple_model)
|
|
|
|
library(lme4)
|
|
library(dplyr)
|
|
#get into mlm format
|
|
long_df <- input_df |>
|
|
pivot_longer(cols = c(other_commit_count, wikimedia_commit_count, jenkins_commit_count, wikia_commit_count, mediawiki_dev_commit_count),
|
|
names_to = "commit_type",
|
|
values_to = "lengthened_commit_count")
|
|
|
|
mlm <- glmer.nb(lengthened_commit_count ~ before_after*relative_week + (before_after*relative_week|commit_type),
|
|
control=glmerControl(optimizer="bobyqa",
|
|
optCtrl=list(maxfun=2e5)), nAGQ=0,
|
|
data=long_df)
|
|
summary(mlm)
|
|
ranefs <- ranef(mlm)
|
|
print(ranefs)
|
|
saveRDS(mlm, "021525_ve_event_mlm.rda")
|