This commit is contained in:
zhangxunhui 2021-02-15 22:14:57 +08:00
parent 8fb6348361
commit 1c750fd3b4
7 changed files with 164337 additions and 2 deletions

25
analysis_regression.R Normal file
View File

@ -0,0 +1,25 @@
# analysis based on mixed-effect regression model, where user login is the random effect
library(lmerTest)
data = read.csv(file="data_4_filtered_users.csv")
data = data[!(data[['index']]==0),]
data[['intervention']] = as.factor(data[['intervention']])
m = lmer(
formula=log(commit_num+0.5)~
log(user_age+0.5) +
log(history_commit_num+0.5) +
log(history_pr_num+0.5) +
log(history_issue_num+0.5) +
log(history_issue_comment_num+0.5) +
log(history_pr_review_num+0.5) +
time +
intervention +
time_after_intervention +
(1|login),
verbose=TRUE,
data=data
)
car::Anova(m, type=II)

View File

@ -71,6 +71,7 @@ gap_df['pr_review_num'] = -1
min_start_at = min(gap_df['start_at'])
for row in gap_df.itertuples():
login = getattr(row, 'login')
# 1.
cur.execute("select created_at from github_user where login=%s", (login,))
@ -80,7 +81,11 @@ for row in gap_df.itertuples():
# 2.
cur.execute("select sum(contribution_count) as history_commit_num from github_user_commits_per_day where date<%s and login=%s", (start_at,login))
history_commit_num = int(cur.fetchone()['history_commit_num'])
history_commit_num = cur.fetchone()['history_commit_num']
if history_commit_num is None:
history_commit_num = 0
else:
history_commit_num = int(history_commit_num)
# 3.
cur.execute("select count(*) as history_pr_num from github_user_pr where created_at<%s and login=%s", (start_at, login))
@ -126,7 +131,11 @@ for row in gap_df.itertuples():
# 10.
end_at = getattr(row, 'end_at')
cur.execute("select sum(contribution_count) as commit_num from github_user_commits_per_day where date>%s and date<=%s and login=%s", (start_at, end_at, login))
commit_num = int(cur.fetchone()['commit_num'])
commit_num = cur.fetchone()['commit_num']
if commit_num is None:
commit_num = 0
else:
commit_num = int(commit_num)
# 11.
cur.execute("select count(*) as pr_num from github_user_pr where created_at>%s and created_at<=%s and login=%s", (start_at, end_at, login))

164301
data_4_filtered_users.csv Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.