-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path01_exploratory_data_analysis.Rmd
More file actions
1608 lines (1250 loc) · 61.1 KB
/
Copy path01_exploratory_data_analysis.Rmd
File metadata and controls
1608 lines (1250 loc) · 61.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "01 Exploratory Data Analysis"
author: "Anders Sundelin"
date: "2023-03-18"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(GGally)
library(tidyr)
library(brms)
library(bayesplot)
library(dplyr)
library(tidyverse)
library(ggpubr)
options(dplyr.summarise.inform = FALSE)
```
## Exploring why certain teams introduce duplicates
Models are cached in subdirectory, as they take considerable time to run. Expect multiple hours for the complete, multi-level model with all the data set.
You might need to remove the cached models when changing some parameters (though formula or data changes are usually detected by brms).
We move away from zero-based scaling, instead opting for scaling the logarithm of the severely right-skewed values (added, removed, complexity, duplicated lines).
We are also heeding the advice of Gelman: https://statmodeling.stat.columbia.edu/2019/08/21/you-should-usually-log-transform-your-positive-data/
This also means that the linear model will be based on the _magnitude_ of the change in parameter (e.g. 0, 1, 2.7, 7.3, 19.8 added lines/existing complexity). So each individual line will have marginally lower impact, but the scale of the parameter will still matter.
A simple scientific model, where rates of change is taken from the population only, and the intercept varies per group becomes:
$log(\lambda) = \beta_{0,i} + \beta_A A_i + \beta_C C_i + \beta_D D_i$
where
$A_i = \frac{ln(added_i+1) - \hat{\mu_{\alpha}}}{\hat{\sigma_{\alpha}}}$
and
$\hat{\mu_{\alpha}} = mean(ln(added+1))$
$\hat{\sigma_{\alpha}} = stddev(ln(added+1))$
$C_i = \frac{ln(complexity_i+1) - \hat{\mu_{\gamma}}}{\hat{\sigma_{\gamma}}}$
and
$\hat{\mu_{\gamma}} = mean(ln(complexity+1))$
$\hat{\sigma_{\gamma}} = stddev(ln(complexity+1))$
and
$D_i = \frac{ln(dupblocks_i+1) - \hat{\mu_{\delta}}}{\hat{\sigma_{\delta}}}$
and
$\hat{\mu_{\delta}} = mean(ln(dupblocks+1))$
$\hat{\sigma_{\delta}} = stddev(ln(dupblocks+1))$
This corresponds to the following multiplicative model for $\lambda$ (also called $\mu$ in the negative binomial context):
$\lambda_i = e^{\beta_{0,i}} (\frac{added_i+1}{e^\hat{\mu_\alpha}})^{\frac{\beta_A}{\hat{\sigma_\alpha}}} (\frac{complexity_i+1}{e^\hat{\mu_\gamma}})^{\frac{\beta_C}{\hat{\sigma_\gamma}}} (\frac{duplicates_i+1}{e^\hat{\mu_\delta}})^{\frac{\beta_D}{\hat{\sigma_\delta}}}$
In this equation, $added$, $complexity$ and $duplicates$ are on their natural scale, starting at 0 and counting upwards.
Depending on which parameters we include in the group-level effect, the exponent will change accordingly (hence the $i$ in $\beta_{0,i}$ for the model where only the intercept changes per team and repo).
The other parameters, $\hat{\mu_\alpha}$ and $\hat{\sigma_\alpha}$, et al. are just normalizing constants, defined as the mean and standard deviation of the logarithm of the corresponding metric count.
```{r}
INTTEST <- "IntTest"
JUPITER <- "Jupiter"
MARS <- "Mars"
MERCURY <- "Mercury"
NEPTUNE <- "Neptune"
SATURN <- "Saturn"
URANUS <- "Uranus"
VENUS <- "Venus"
ARCH <- "Arch"
BLUE <- "Blue"
BROWN <- "Brown"
GREEN <- "Green"
NEWTEAM <- "NewTeam"
ORANGE <- "Orange"
PINK <- "Pink"
RED <- "Red"
UI <- "UI"
UNKNOWN <- "Unknown"
VIOLET <- "Violet"
YELLOW <- "Yellow"
```
```{r, eval=FALSE}
INTTEST <- "int.test"
JUPITER <- "billrun"
MARS <- "cdac"
MERCURY <- "stats"
NEPTUNE <- "config"
SATURN <- "dataaccess"
URANUS <- "eventagg"
VENUS <- "billfmt"
ARCH <- "DAT"
BLUE <- "CFT24"
BROWN <- "CFT84"
GREEN <- "CFT23"
NEWTEAM <- "NewTeam"
ORANGE <- "CFT53"
PINK <- "CFT55"
RED <- "CFT22"
UI <- "UI"
UNKNOWN <- "Unknown"
VIOLET <- "CFT54"
YELLOW <- "CFT25"
```
```{r ingest data}
source("ingest_data.R")
levels(data$repo)
levels(data$committerteam)
levels(data$authorteam)
```
```{r}
levels(data$repo) <- c(INTTEST, JUPITER, MARS, MERCURY, NEPTUNE, SATURN, URANUS, VENUS)
levels(data$committerteam) <- c(ARCH, BLUE, BROWN, GREEN, ORANGE, PINK, RED, UI, UNKNOWN, VIOLET, YELLOW)
levels(data$authorteam) <- c(ARCH, BLUE, BROWN, GREEN, ORANGE, PINK, RED, UI, UNKNOWN, VIOLET, YELLOW)
```
# Exploratory Data Analysis
Introduced duplicates in files, per repo.
```{r}
#describe_distribution <- function(df, x) { df |> select(x) }#|> summarize(min=min(x), low=quantile(x, 0.25), median=quantile(x, 0.5), high=quantile(x, 0.75), very_high=quantile(x, 0.99), max=max(x))}
#describe_distribution(data, ADD)
low_stat <- function(x) quantile(x, 0.25, type=3)
median_stat <- function(x) quantile(x, 0.5, type=3)
high_stat <- function(x) quantile(x, 0.75, type=3)
q95_stat <- function(x) q95(x)
very_high_stat <- function(x) quantile(x, 0.99, type=3)
max_stat <- function(x) max(x)
m1 <- data |> select(ADD, DEL, COMPLEX, DUP, INTROD) |> summarise(across(ADD:INTROD, min)) |> pivot_longer(cols=everything(), values_to="min")
m2 <- data |> select(ADD, DEL, COMPLEX, DUP, INTROD) |> summarise(across(ADD:INTROD, low_stat)) |> pivot_longer(cols=everything(), values_to="low")
m3 <- data |> select(ADD, DEL, COMPLEX, DUP, INTROD) |> summarise(across(ADD:INTROD, median_stat)) |> pivot_longer(cols=everything(), values_to="median")
m4 <- data |> select(ADD, DEL, COMPLEX, DUP, INTROD) |> summarise(across(ADD:INTROD, high_stat)) |> pivot_longer(cols=everything(), values_to="high")
m5 <- data |> select(ADD, DEL, COMPLEX, DUP, INTROD) |> summarise(across(ADD:INTROD, q95_stat)) |> pivot_longer(cols=everything(), values_to="q95")
m6 <- data |> select(ADD, DEL, COMPLEX, DUP, INTROD) |> summarise(across(ADD:INTROD, very_high_stat)) |> pivot_longer(cols=everything(), values_to="very_high")
m7 <- data |> select(ADD, DEL, COMPLEX, DUP, INTROD) |> summarise(across(ADD:INTROD, max)) |> pivot_longer(cols=everything(), values_to="max")
metrics <- merge(
merge(
merge(
merge(
merge(
merge(m1, m2, by="name"),
m3, by="name"),
m4, by="name"),
m5, by="name"),
m6, by="name"),
m7, by="name")
metrics
```
```{r}
data |> filter(INTROD > 0) |> group_by(repo, INTROD) |> tally()
```
Most of the introduced duplicates are small (single-digits), but some are large, ranging into the hundreds for the IntTest repo.
```{r}
changesPerRepoAndTeam <- data |> group_by(repo, committerteam) |> summarise(fileschanged=n())
zerosPerRepoAndTeam <- data |> filter(INTROD == 0) |> group_by(repo, committerteam) |> summarise(zeros=n())
zeros_ratio <- merge(changesPerRepoAndTeam, zerosPerRepoAndTeam) |> mutate(introdRatio = 1-(zeros/fileschanged)) |> arrange(introdRatio)
(p <- zeros_ratio |> filter(committerteam != "Unknown") |> ggplot(aes(x=committerteam, y=introdRatio, color=committerteam, size=fileschanged)) + geom_point() + facet_wrap(~ repo) + xlab("team") + scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() + scale_y_continuous(limits=c(0,0.27)) + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
)
```
Unknown team change 7 files in Neptune, and manage to get 3 files with duplicates there. Excluding Unknown from this presentation, saves screen real estate.
```{r}
figsave("observed_proportion_dup_per_repo_team.pdf", p)
```
```{r}
changesPerRepoAndTeam <- data |> group_by(repo, authorteam) |> summarise(fileschanged=n())
zerosPerRepoAndTeam <- data |> filter(INTROD == 0) |> group_by(repo, authorteam) |> summarise(zeros=n())
zeros_ratio <- merge(changesPerRepoAndTeam, zerosPerRepoAndTeam) |> mutate(introdRatio = 1-(zeros/fileschanged)) |> arrange(introdRatio)
zeros_ratio |> ggplot(aes(x=authorteam, y=introdRatio, color=repo, size=fileschanged)) + geom_point() + ggtitle("Proportion of introduced duplicates in one file, per repo and team") #+ scale_y_continuous(limits=c(0,0.3))
```
Except for the Unknown outlier, there are not any large differences whether we group on authorteam or committerteam.
```{r}
```
```{r}
data |> filter(repo %in% c(INTTEST, JUPITER, URANUS), committerteam %in% c(RED, BLUE, PINK)) |>
group_by(committerteam, repo, INTROD) |> ggplot(aes(x=INTROD, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) +
xlab("Maximum number of introduced duplicates") +
ggtitle("Cumulative introduced duplicates") +
# paste0("added: ", round(added$added, 0), " removed: ", round(removed$removed, 0), " complexity: ", round(complexity$complexity, 0), " duplicates: ", round(duplicates$duplicates, 0))) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() + scale_y_continuous(limits = c(0.7, 1)) + scale_x_continuous(limits = c(0,20))
```
```{r}
data |> filter(committerteam== RED, repo==SATURN) |> arrange(desc(INTROD)) |> head()
```
```{r}
#data |> filter(repo == JUPITER, committerteam %in% c(RED, BLUE, GREEN, ARCH)) |> group_by(committerteam, COMPLEX) |> summarize(n=n())#, quantile(COMPLEX, 0.25, type=3), median(COMPLEX), quantile(COMPLEX, 0.75, type=3), max(COMPLEX))
```
```{r}
#data |> filter(repo == JUPITER) |> summarize(n=n(), quantile(data$COMPLEX, 0.25, type=3), median(data$COMPLEX), quantile(data$COMPLEX, 0.75, type=3), max(data$COMPLEX))
```
```{r}
#data |> filter(repo == JUPITER, committerteam %in% c(RED, BLUE, GREEN, ARCH)) |> group_by(committerteam, INTROD) |> summarize(n=n()) |> mutate(freq = 1-(n/sum(n))) |> arrange(freq)
```
```{r}
data |> filter(repo == JUPITER) |> group_by(INTROD) |> tally() |> mutate(freq = n/sum(n)) |> arrange(desc(freq))
```
```{r}
data |> filter(repo == JUPITER, committerteam %in% c(RED, BLUE)) |> group_by(committerteam, INTROD) |> tally()
```
```{r}
data |> filter(repo == JUPITER, committerteam %in% c(RED, BLUE)) |> group_by(committerteam) |> summarize(mean(ADD), mean(DEL), mean(COMPLEX), mean(DUP))
data |> filter(repo == JUPITER, committerteam %in% c(RED, BLUE)) |> group_by(committerteam) |> summarize(median(ADD), median(DEL), median(COMPLEX), median(DUP))
data |> filter(repo == JUPITER, committerteam %in% c(RED, BLUE)) |> group_by(committerteam) |> summarize(q95(ADD), q95(DEL), q95(COMPLEX), q95(DUP))
```
Viewing the added and removed lines, we see some correlation, and also quite a few "pure additions" and "pure removals" (along the x and y axes, respectively).
```{r}
data |> ggplot(aes(x=DUP)) + geom_histogram(bins=50)
```
```{r}
data |> group_by(DUP) |> tally()
```
```{r}
data |> group_by(COMPLEX) |> tally()
```
```{r}
data |> group_by(repo) |> ggplot(aes(x=logADD, y=logDEL, color=authorteam)) + geom_point() + facet_wrap( ~ repo)
```
We see that, overall, there are more duplicates present in the IntTest and Jupiter repos (largest one). And there seems to be at least some indications of correlation with complexity (although there are also some duplicates in files where complexity is 0, i.e. the y axis).
```{r}
data |> group_by(repo) |> ggplot(aes(x=logCOMPLEX, y=logDUP)) + geom_point() + facet_wrap( ~ repo)
```
A more thorough pairs plot reveal that the parameters seem quite independet - at least no obvious correlations are present (though logCOMPLEX and logDUP are somewhat related, as seen above). Plot can be repeated per repo or per team, with the same conclusions.
```{r}
ggpairs(data |> select(logADD, logDEL, logCOMPLEX, logDUP))
```
```{r}
# quantile type 3 to avoid having interpolation of the observations
repo_committerteam <- data |> group_by(repo, committerteam) |> summarize(q95=quantile(INTROD, 0.95, type=3),
q99=quantile(INTROD, 0.99, type=3),
max=max(INTROD),
files=n(),
mean_added=mean(ADD),
median_added=median(ADD),
mean_removed=mean(DEL),
median_removed=median(DEL)) |> mutate(team=committerteam)
```
```{r}
repo_committerteam |> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=files)) +
geom_text(aes(label=round(files, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed number of changes to files by team and repo"))
```
Repositories are named and sized (though not to scale) after the seven neighboring planets, plus the INTTEST repository, which contains integration tests developed in Java.
We note that some teams have not changed files in some repostories, and that some teams have made very many, and some very few changes to some repositories.
```{r}
repo_committerteam |> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=mean_added)) +
geom_text(aes(label=round(mean_added, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed mean number of added lines to files by team and repo"))
```
```{r}
repo_committerteam |> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=median_added)) +
geom_text(aes(label=round(median_added, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed median number of added lines to files by team and repo"))
```
```{r}
repo_committerteam |> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=mean_removed)) +
geom_text(aes(label=round(mean_removed, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed mean number of removed lines to files by team and repo"))
```
```{r}
repo_committerteam |> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=median_removed)) +
geom_text(aes(label=round(median_removed, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed median number of removed lines to files by team and repo"))
```
```{r}
plot_existing_dup_in_repo <- function(aRepo, team_selector) {
data |> filter(repo == aRepo, team_selector(committerteam)) |> mutate(team = committerteam) |> group_by(team) |> ggplot(aes(x=logDUP, color=team, fill=team)) + geom_histogram(position = "dodge", binwidth = 1) + ggtitle(paste("Existing log(duplicates+1) in repo", aRepo)) + scale_fill_manual(name="team", values=teamcolors) + scale_colour_manual(name="team", values=teamcolors) + ylab("filechanges") + xlab("Log existing duplicates")
}
three_teams <- function(x) x %in% c(ARCH, RED, BLUE, GREEN)
(p <- plot_existing_dup_in_repo(JUPITER, three_teams) + theme_bw() )
(p <- plot_existing_dup_in_repo(INTTEST, three_teams) + theme_bw() )
```
```{r}
plot_existing_complexity_in_repo <- function(aRepo, team_selector) {
data |> filter(repo == aRepo, team_selector(committerteam)) |> mutate(team = committerteam) |> group_by(team) |> ggplot(aes(x=logCOMPLEX, color=team, fill=team)) + geom_histogram(aes(y=..density..), position = "dodge", binwidth = 1) + ggtitle(paste("Existing log(complexity+1) in repo", aRepo)) + scale_fill_manual(name="team", values=teamcolors) + scale_colour_manual(name="team", values=teamcolors) + ylab("proportion of filechanges") + xlab("Log existing complexity")
}
three_teams <- function(x) x %in% c(ARCH, RED, BLUE, GREEN)
(p <- plot_existing_complexity_in_repo(JUPITER, three_teams) + theme_bw() )
(p <- plot_existing_complexity_in_repo(INTTEST, three_teams) + theme_bw() )
(p <- plot_existing_complexity_in_repo(URANUS, three_teams) + theme_bw() )
```
```{r}
data |> filter(repo == JUPITER, committerteam %in% c(BLUE, RED)) |> group_by(committerteam) |> summarize(n(), mean(COMPLEX), median(COMPLEX), mean(DUP), q95(DUP))
```
Picking a random repo, and three random teams, show that the number of introduced duplicates follow a Poisson-like (or Negative Binomial) distribution, once you exclude all the zeros, for the zero-inflation part.
```{r}
plot_introd_issues_in_repo <- function(aRepo, team_selector) {
data |> filter(repo == aRepo, team_selector(committerteam)) |> mutate(team = committerteam) |> group_by(team) |> ggplot(aes(x=INTROD, color=team, fill=team)) + geom_histogram(binwidth = 1) + facet_wrap(~ team) + scale_fill_manual(name="team", values=teamcolors) + scale_colour_manual(name="team", values=teamcolors) + ylab("number of changed files") + xlab("Number of duplicates introduced in the change") + ylim(0,65)
}
(p <- plot_introd_issues_in_repo(JUPITER, function(x) x %in% c(RED, BLUE, GREEN, ARCH)) + theme_bw() + theme(legend.position = "bottom"))
```
```{r}
figsave("observed-INTROD-4teams-Jupiter.pdf", p)
```
```{r}
plot_introd_issues_in_repo <- function(aRepo, team_selector) {
data |> filter(repo == aRepo, team_selector(committerteam)) |> mutate(team = committerteam) |> group_by(team) |> ggplot(aes(x=INTROD, color=team, fill=team)) + geom_histogram(aes(y=..density..), position = "dodge", binwidth = 1) + ggtitle(paste("Introduced duplicates in repo", aRepo)) + scale_fill_manual(name="team", values=teamcolors) + scale_colour_manual(name="team", values=teamcolors) + ylab("proportion of filechanges") + xlab("Number of duplicates introduced in the change") + ylim(0,0.1)
}
three_teams <- function(x) x %in% c(RED, BLUE, BROWN)
(p <- plot_introd_issues_in_repo(JUPITER, three_teams) + theme_bw() + ylim(0,0.045)
)
```
```{r}
figsave("observed_introd_jupiter_four_teams.pdf", p)
```
```{r}
plot_introd_per_team <- function(aRepo, team_selector) {
data |> filter(repo == aRepo, team_selector(committerteam)) |> mutate(team = committerteam) |> group_by(team) |> ggplot(aes(x=INTROD, color=team, fill=team)) + geom_histogram(aes(y=..density..), binwidth = 1) + facet_wrap(~ team) + ggtitle(paste("Introduced duplicates in repo", aRepo)) + scale_fill_manual(name="team", values=teamcolors) + scale_colour_manual(name="team", values=teamcolors) + ylab("proportion of filechanges") + xlab("Number of duplicates introduced in the change") + ylim(0,0.1)
}
```
```{r}
(p <- plot_introd_per_team(JUPITER, function(x) x %in% c(ARCH, RED, BLUE, GREEN)) + theme_bw() + scale_y_continuous(limits=c(0,0.04)) )
pngsave("observed-INTROD-4teams-Jupiter.png", p)
```
```{r}
(p <- plot_introd_per_team(INTTEST, function(x) x %in% c(ARCH, RED, BLUE, GREEN)) + theme_bw() + scale_y_continuous(limits=c(0,0.04)) )
pngsave("observed-INTROD-4teams-IntTest.png", p)
```
```{r}
(p <- plot_introd_per_team(URANUS, function(x) x %in% c(ARCH, RED, BLUE, GREEN)) + theme_bw() + scale_y_continuous(limits=c(0,0.06)) )
```
```{r}
(p <- plot_introd_per_team(VENUS, function(x) x %in% c(ARCH, RED, BLUE, GREEN)) + theme_bw() + scale_y_continuous(limits=c(0,0.04)) )
pngsave("observed-INTROD-4teams-Venus.png", p)
```
```{r}
data |> filter(repo == INTTEST, committerteam == ARCH) |> group_by(INTROD) |> tally()
```
```{r}
data |> filter(repo == VENUS, committerteam == ARCH) |> group_by(INTROD) |> tally()
```
```{r}
data |> filter(repo == VENUS, committerteam == GREEN) |> group_by(INTROD) |> tally()
```
```{r}
(p <- plot_introd_issues_in_repo(INTTEST, three_teams) + theme_bw() + ylim(0,0.045) )
```
setting the xlim seems to make the histogram behave weirdly... so, better to focus on the ylim - this will make the histogram work correctly...
```{r}
data |> filter(repo == INTTEST, committerteam == BLUE) |> group_by(INTROD) |> tally()
```
```{r}
data |> filter(committerteam %in% c(BLUE, GREEN), repo == URANUS) |> group_by(committerteam) |> summarize(median(COMPLEX))
```
```{r}
data |> filter(committerteam %in% c(BLUE, GREEN), repo == MARS) |> group_by(committerteam, INTROD) |> summarize(n=n(), median(COMPLEX)) |> mutate(freq=n/sum(n))
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo == JUPITER) |> group_by(committerteam, INTROD) |> summarize(n=n()) |> mutate(freq=n/sum(n))
```
There are also differences between teams --- we see that the ARCH team in this repo introduced very few duplicates, whereas the Blue and Green teams were more comparable.
The pattern is even more pronounced in the IntTest repo
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo == URANUS) |> group_by(committerteam, INTROD) |> summarize(n=n()) |> mutate(freq=n/sum(n))
```
```{r}
(p <- data |> filter(committerteam %in% c(ARCH, BLUE, RED, BROWN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(repo, committerteam, INTROD) |> ggplot(aes(x=INTROD, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) +
xlab("Maximum number of introduced duplicates") +
ggtitle("Observed cumulative distribution of introduced duplicates") +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() + scale_y_continuous(limits = c(0.85,1.0)) #+ scale_x_continuous(limits = c(0,30))
)
#|> summarize(n=n()) |> mutate(freq=n/sum(n)) |> ggplot(aes(x=INTROD, y=freq, color=committerteam)) + geom_line()
```
```{r}
figsave("observed_introd.pdf", p)
```
```{r}
(p <- data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(repo, committerteam) |> ggplot(aes(x=COMPLEX, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) + scale_x_continuous(trans="log1p", breaks=c(0,1,3,10,50,200, 1000)) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() +
xlab("Existing complexity in changed file (log scale)") +
ggtitle("Observed cumulative frequency of existing complexity")
)
```
```{r}
figsave("observed_complexity.pdf", p)
```
In the Jupiter repo, Team Blue are more likely to make changes in less complex files, relative to the Red team. Same for Arch team.
In the Neptune repo, the Arch team likewise are less likely to change complex files, but the Blue and Red teams are more similar.
```{r}
data |> summarize(max(ADD), max(DEL), max(COMPLEX), max(DUP))
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(committerteam) |> summarize(n(), max(ADD), max(DEL), max(COMPLEX), max(DUP), q95(ADD), q95(DEL), q95(COMPLEX), q95(DUP))
```
```{r}
(p <- data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(repo, committerteam) |> ggplot(aes(x=DUP, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) + scale_x_continuous(trans="log1p", breaks=c(0,1,3,10,50,200, 1000)) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() +
xlab("Duplicates in changed file (log scale)") +
ggtitle("Observed cumulative frequency of existing duplicates")
)
```
```{r}
figsave("observed_duplicates.pdf", p)
```
```{r}
(p <- data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(repo, committerteam) |> ggplot(aes(x=ADD, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) +
scale_x_continuous(trans="log1p", breaks=c(0,1,3,10,50,200, 1000)) + #, guide=guide_axis(angle=90)) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() +
xlab("Number of added lines (log scale)") +
ggtitle("Observed cumulative frequency of added lines")
)
```
```{r}
figsave("observed_added.pdf", p)
```
```{r}
(p <- data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(repo, committerteam) |> ggplot(aes(x=DEL, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) +
scale_x_continuous(trans="log1p", breaks=c(0,1,3,10,50,200, 1000, 4000)) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() +
xlab("Number of deleted lines (log scale)") +
ggtitle("Observed cumulative frequency of deleted lines") #+ scale_y_continuous(limits = c(0.9,1))
)
```
```{r}
figsave("observed_removed.pdf", p)
```
```{r}
quantile_table <- function(df) {
df |> mutate(team=committerteam) |> group_by(repo, team) |> summarize(n=n(), q50ADD=median(ADD), q50DEL=median(DEL), q50COMP=median(COMPLEX), q50DUP=median(DUP), q75ADD=quantile(ADD, 0.75, type=3), q75DEL=quantile(DEL, 0.75, type=3), q75COMP=quantile(COMPLEX, 0.75, type=3), q75DUP=quantile(DUP, 0.75, type=3))
}
quantile_table(data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)))
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> mutate(team=committerteam) |> group_by(repo, team) |> summarize(n=n(), q50ADD=median(ADD), q50DEL=median(DEL), q50COMP=median(COMPLEX), q50DUP=median(DUP), q95ADD=quantile(ADD, 0.95, type=3), q95DEL=quantile(DEL, 0.95, type=3), q95COMP=quantile(COMPLEX, 0.95, type=3), q95DUP=quantile(DUP, 0.95, type=3))
```
```{r}
data |> filter(committerteam %in% c(GREEN, BLUE, RED), repo %in% c(JUPITER, NEPTUNE, URANUS)) |> mutate(team=committerteam) |> group_by(team, repo) |> summarize(n=n(), q50ADD=median(ADD), q50DEL=median(DEL), q50COMP=median(COMPLEX), q50DUP=median(DUP), q95ADD=quantile(ADD, 0.95, type=3), q95DEL=quantile(DEL, 0.95, type=3), q95COMP=quantile(COMPLEX, 0.95, type=3), q95DUP=quantile(DUP, 0.95, type=3))
```
```{r}
data |> filter(committerteam %in% c(BLUE)) |> mutate(team=committerteam) |> group_by(repo, team) |> summarize(n=n(), q50ADD=median(ADD), q50DEL=median(DEL), q50COMP=median(COMPLEX), q50DUP=median(DUP), q95ADD=quantile(ADD, 0.95, type=3), q95DEL=quantile(DEL, 0.95, type=3), q95COMP=quantile(COMPLEX, 0.95, type=3), q95DUP=quantile(DUP, 0.95, type=3))
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED), repo == JUPITER, DEL <= 3) |> group_by(committerteam) |> tally()
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(repo, committerteam, COMPLEX, logCOMPLEX) |> ggplot(aes(x=COMPLEX, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw() + scale_x_continuous(trans="log1p", breaks=c(0,3,10,50,200, 1000))
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER, URANUS)) |> group_by(repo, committerteam, logCOMPLEX) |> ggplot(aes(x=logCOMPLEX, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw()
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED, GREEN), repo %in% c(INTTEST, JUPITER)) |> group_by(repo, committerteam, logDUP) |> ggplot(aes(x=logDUP, color=committerteam)) + stat_ecdf() + facet_wrap(~ repo) +
scale_color_manual(values=COLOR_BY_TEAM) + theme_bw()
```
```{r}
data |> filter(committerteam %in% c(ARCH, BLUE, RED), repo == INTTEST) |> group_by(committerteam, INTROD) |> summarize(n=n()) |> mutate(freq=n/sum(n)) |> ggplot(aes(x=INTROD, y=freq, color=committerteam)) + geom_line()
```
```{r}
(p <- plot_introd_issues_in_repo(INTTEST, three_teams) + ylim(0,0.045) )
```
There seem to be some team-level variation, as well as repo-level variation in the number of introduced duplicates.
Comparing the largest repo, and the three largest contributors to that repo reveals that the Blue team is more likely to introduce a small amount of duplicates (it has almost double the amount of single-added duplicates as the Red team, which has a similar amount of contributions). But the red team has some more occurrences of 4-8 duplicates added to a single file.
```{r}
pngsave <- function(file, p, width=16*1.25, height=9*1.25, units="cm") ggsave(file, p, device = "png", dpi = 1200, width=width, height=height, units=units)
pngsave("observed_INTROD_inttest.png", p)
```
```{r}
(p <- plot_introd_issues_in_repo(JUPITER, function(x) x %in% c(RED, GREEN,BLUE)) + ylim(0,0.045) )
```
```{r}
pngsave("observed_INTROD_billrun.png", p)
```
```{r}
( data |> filter(committerteam == BLUE, ISTEST==F) |> ggplot(aes(x=INTROD, fill=repo)) + geom_histogram(aes(y=after_stat(count/sum(count))), binwidth = 1) + scale_y_continuous(labels=scales::percent) + ylim(0,0.04) + ggtitle(paste0("Introduced duplicates in non-test code by team ", BLUE)) )
```
```{r}
(data |> filter(committerteam == BLUE, ISTEST==T) |> ggplot(aes(x=INTROD, fill=repo)) + geom_histogram(aes(y=after_stat(count/sum(count))), binwidth = 1) + scale_y_continuous(labels=scales::percent) + ylim(0,0.04) + ggtitle(paste0("Introduced duplicates in test code by team ", BLUE)) )
```
```{r}
(data |> filter(committerteam == BLUE) |> ggplot(aes(x=INTROD, fill=repo)) + geom_histogram(aes(y=after_stat(count/sum(count))), binwidth = 1) + facet_wrap(~ ISTEST) + scale_y_continuous(labels=scales::percent) + ylim(0,0.025) + ggtitle(paste0("Introduced duplicates overall by team ", BLUE)) )
```
```{r}
(data |> filter(committerteam == BLUE) |> ggplot(aes(x=INTROD, fill=repo)) + geom_histogram(aes(y=after_stat(count/sum(count))), binwidth = 1) + scale_y_continuous(labels=scales::percent) + ylim(0,0.04) + ggtitle(paste0("Introduced duplicates overall by team ", BLUE)) )
```
```{r}
data |> filter(repo == JUPITER, committerteam == RED) |> filter(INTROD > 0)
```
```{r}
plot_introd_issues_in_repo(MARS, function(x) x %in% c(RED, GREEN,BLUE))+ ylim(0,0.05)
```
```{r}
data |> filter(repo == MARS, committerteam == RED) |> filter(INTROD > 0)
```
```{r}
data |> filter(repo == URANUS, committerteam == RED) |> filter(INTROD > 0)
```
```{r}
data |> filter(repo == VENUS, committerteam == RED) |> filter(INTROD > 0)
```
```{r}
plot_introd_issues_in_repo(SATURN, function(x) x %in% c(RED, GREEN,BLUE))+ ylim(0,0.05)
```
```{r}
data |> filter(repo == SATURN, committerteam == RED) |> filter(INTROD > 0)
```
Quantile plots
```{r}
repo_committerteam |> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=q95)) +
geom_text(aes(label=round(q95, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed 95% introductions by team and repo"))
```
The 95% quantile plots show that for many repos, and many teams in those repos, in 19 out of 20 file changes, no duplicates were added. The outlier is INTTEST, where many teams can be expected to introduce single-digit duplicates. In the NEPTUNE repository, we also can expect some more duplicate introduction than in the others.
```{r}
repo_committerteam |> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=q99)) +
geom_text(aes(label=round(q99, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed 99% introductions by team and repo"))
```
The pattern repeats for the 99% quantile. Integration test can be expected to have more duplicates introduced, and in particular the Brown team stands out.
In the Neptune repo, however, it is the Blue and Green teams that are a bit more likely to introduce duplicates.
We also note that the Architect team are unlikely to introduce duplicates.
```{r}
repo_committerteam|> ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=max)) +
geom_text(aes(label=round(max, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed max number of introduced duplicates by team and repo"))
```
```{r}
repo_committerteam_summary <- repo_committerteam |> mutate(files=replace_na(files, 0)) |> group_by(repo) |> summarize(mx=max(files), mn=min(files))
(p <- repo_committerteam |> inner_join(repo_committerteam_summary) |> mutate(p=(files - mn)/(mx-mn)) |>
ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=p)) +
geom_text(aes(label=round(files, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle("Observed number of changes to files by team and repo", "Heatmap colored by row")
)
```
```{r}
pngsave("filechanges_per_team_and_repo.png", p)
```
```{r}
repo_committerteam_summary <- repo_committerteam |> mutate(max=replace_na(max, 0)) |> group_by(repo) |> summarize(mx=max(max), mn=min(max))
(p <- repo_committerteam |> inner_join(repo_committerteam_summary) |> mutate(p=(max - mn)/(mx-mn)) |>
ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=p)) +
geom_text(aes(label=round(max, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle("Observed max number of introduced duplicates by team and repo", "Heatmap colored by row")
)
```
```{r}
pngsave("max_introd_per_team_and_repo.png", p)
```
```{r}
repo_committerteam_summary <- repo_committerteam |> mutate(max=replace_na(q99, 0)) |> group_by(repo) |> summarize(mx=max(q99), mn=min(q99))
(p <- repo_committerteam |> inner_join(repo_committerteam_summary) |> mutate(p=(q99 - mn)/(mx-mn)) |>
ggplot(aes(x=team, y=repo)) +
geom_tile(aes(fill=p)) +
geom_text(aes(label=round(q99, 0)), color="white") +
xlab("team") + ylab("repo") +
ggtitle("Observed Q99 number of introduced duplicates by team and repo", "Heatmap colored by row")
)
```
```{r}
pngsave("q99_introd_per_team_and_repo.png", p)
```
```{r}
data |> group_by(repo, committerteam) |> select(committer) |> distinct() |> tally() |> ggplot(aes(x=committerteam, y=repo)) +
geom_tile(aes(fill=n)) +
geom_text(aes(label=n), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed number of committers by team and repo"))
```
```{r}
data |> group_by(repo, authorteam) |> select(author) |> distinct() |> tally() |> ggplot(aes(x=authorteam, y=repo)) +
geom_tile(aes(fill=n)) +
geom_text(aes(label=n), color="white") +
xlab("team") + ylab("repo") +
ggtitle(paste("Observed number of authors by team and repo"))
```
The maximum number of introduced duplicates reveals that the Brown team, which also had high 95% value in the IntTest repo, also introduced 150 duplicates, the overall max value, to a single file in the integration test repository.
Overall, we see the pattern repeat:
* Integration tests are highly likely to involve additions of duplicates
* The architect team overall is highly unlikely to introduce any duplicates
* There seems to be differences between teams in the numer of introduced duplicates, relative to their contributions. Differences between Red and Blue team, and also the Brown team stands out for introducing many duplicates in at least the integration test repository.
```{r}
#summary(data)
data |> filter(INTROD >0) |> ggplot(aes(x=D, y=INTROD, color=C)) + geom_point()
```
```{r}
data |> filter(INTROD >0) |> ggplot(aes(x=C, y=INTROD, color=D)) + geom_point()
```
Those plots show that complexity, rather than number of existing duplicates, are more linearly related to number of introduced duplicates.
At the same time, complexity and existing duplicates are also related - it is just that even if DUP is zero, there is no strong evidence that INTROD is low or zero.
```{r}
data |> filter(INTROD>0) |> ggplot(aes(x=C, y=D, color=INTROD)) + geom_point()
```
```{r}
data |> ggplot(aes(x=repo, y=ADD)) + geom_violin()
data |> ggplot(aes(x=repo, y=ADD)) + geom_boxplot()
```
```{r}
data |> ggplot(aes(x=repo, y=A)) + geom_violin()
```
```{r}
data |> ggplot(aes(x=committerteam, y=A)) + geom_violin() + geom_boxplot(width=0.1)
```
```{r}
data |> ggplot(aes(x=committerteam, y=A)) + geom_violin() + stat_summary(fun.data=mean_sdl, mult=1, geom="pointrange", color="red")
```
Zero is here the population-level (total) average number of added lines. Some teams stand out, e.g. Brown team seems to add fewer lines, and the team with the Unknown authors are adding more. But, as can be expected, the team metrics vary across the global average.
```{r}
data |> ggplot(aes(x=repo, y=(1+ADD))) + geom_violin() + geom_boxplot(width=0.1) + scale_y_continuous(trans='log', breaks=c(5, 20, 100, 500, 1000, 3000)) + ylab("Added lines")
```
```{r}
data |> ggplot(aes(x=committerteam, y=(1+ADD))) + geom_violin() + geom_boxplot(width=0.1) + scale_y_continuous(trans='log', breaks=c(5, 20, 100, 500, 1000, 3000)) + ylab("Added lines")
```
```{r}
data |> ggplot(aes(x=committerteam, y=(1+DEL))) + geom_violin() + geom_boxplot(width=0.1) + scale_y_continuous(trans='log', breaks=c(5, 20, 100, 500, 1000, 3000)) + ylab("Deleted lines")
```
```{r}
data |> ggplot(aes(x=committerteam, y=(1+DUP))) + geom_violin() + geom_boxplot(width=0.1) + scale_y_continuous(trans='log', breaks=c(5, 20, 100, 500)) + ylab("Existing duplicates")
```
```{r}
data |> ggplot(aes(x=committerteam, y=(1+COMPLEX))) + geom_violin() + geom_boxplot(width=0.1) + scale_y_continuous(trans='log', breaks=c(5, 20, 100, 500, 1000)) + ylab("McCabe complexity")
```
```{r}
data |> ggplot(aes(x=committerteam, y=C)) + geom_violin() + geom_boxplot(width=0.1)
```
```{r}
data |> ggplot(aes(x=committerteam, y=D)) + geom_violin()
```
```{r}
data |> ggplot(aes(x=committerteam, y=INTROD)) + geom_violin() + geom_boxplot(width=0.1)
```
# Unknown team, overall
```{r}
data |> group_by(committerteam) |> summarize(n=n()) |> mutate(frac=round(100*n/sum(n), 2))
```
```{r}
data |> group_by(repo, committerteam) |> summarize(n=n()) |> mutate(frac=round(100*n/sum(n), 2)) |> arrange(desc(frac)) |> filter(committerteam == ARCH)
```
# Architect team
```{r}
summary(data)
```
```{r}
data |> group_by(committerteam, REASON) |> summarize(n=n()) |> mutate(frac=n/sum(n))
```
```{r}
data |> group_by(committerteam) |> summarize(added=median(ADD), removed=median(DEL), IQR(ADD), IQR(DEL))
```
```{r}
data |> filter(repo == VENUS) |> group_by(committerteam) |> summarize(n(), added=median(ADD), removed=median(DEL), IQR(ADD), IQR(DEL), q99(ADD), q99(DEL), max(ADD))
```
```{r}
data |> filter(repo == VENUS) |> group_by(committerteam) |> summarize(n(), median(INTROD), q95(INTROD), IQR(INTROD), q99(INTROD), max(INTROD))
```
# OCAM metrics
Data definition:
* churn: is the per-file-change max value of added and removed lines. So a file change with 2 added and 20 removed lines will have a churn value of 20.
* addcomplex: is the per-file-added McCabe complexity, or 0 in case the complexity of the file decreased due to the change.
* delcomplex: is the per-file-deleted McCabe complexity, or 0 in case the complexity of the file increased due to the change.
* commits: the number of unique commits made by the team
The above definition means that, at minimum, one of either addcomplex or delcomplex is zero, for any given file change.
The only way for the churn value to be zero is if an empty file (containing no lines) was removed. This happens four times in the data set.
```{r}
source("ingest_data.R")
ocam_data <- data
#ocam_metrics(ocam_data) |> dplyr::filter(repo == INTTEST)
(p <- ocam_rank_repo(ocam_metrics(ocam_data) |> dplyr::filter(repo == INTTEST)) + theme(legend.position = "none"))
```
```{r}
ocam_data <- data
(p <- ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == INTTEST)) + theme_bw() )
figsave("ocam_inttest.pdf", p, width = 17.8, height=13)
(p <- ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == JUPITER)) + theme_bw() )
figsave("ocam_jupiter.pdf", p, width = 17.8, height=13)
(p <- ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == SATURN)) + theme_bw() )
figsave("ocam_saturn.pdf", p, width = 17.8, height=13)
(p <- ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == URANUS)) + theme_bw() )
figsave("ocam_uranus.pdf", p, width = 17.8, height=13)
ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == NEPTUNE)) + theme_bw()
ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == VENUS)) + theme_bw()
(p <- ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == MARS)) + theme_bw())
figsave("ocam_mars.pdf", p, width = 17.8, height=13)
ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo == MERCURY)) + theme_bw()
```
```{r}
library(cowplot)
```
```{r}
(ocam_plot <- ocam_rank_repo(ocam_metrics(ocam_data) |> filter(repo %in% c(JUPITER, URANUS))) + theme_bw() + theme(legend.position = "none") + ylab(NULL)
)
figsave("ocam_jupiter_uranus.pdf", ocam_plot)
```
```{r}
myrank <- function(df) {
df |> pivot_longer(cols=c("Grankcommits", "Frankchurn", "Erankaddcomplex", "Drankdelcomplex"), values_to = "metric") |>
group_by(repo) |> ggplot(aes(x=committerteam, y=name)) + geom_tile(aes(fill=metric)) + facet_wrap(~ repo, ncol=1) +
geom_text(aes(label=metric)) + xlab("team") + ylab("metric") + coord_fixed() + scale_y_discrete(labels=ocam_labels_plain) +
scale_fill_gradient2(name="team rank", guide=guide_legend(reverse=T), midpoint=6, low = "#91BFDB", mid = "#FFFFBF", high = "#FC8D59") +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=0.25)) + theme(legend.position = "none") #+ ggtitle(paste("OCAM rank for repo", repo$repo))
}
(ocam_jupiter <- myrank(ocam_metrics(ocam_data) |> filter(repo %in% c(JUPITER, URANUS))) + theme_bw() + theme(legend.position = "none") + ylab(NULL))
```
```{r}
data |> filter(addedComplexity == 0, removedComplexity > 0)
```
## Conditional independencies
We can test whether our data supports the conditional independencies implied by our DAG.
COMP _||_ INTR | ADD, REM
DUP _||_ INTR | ADD, REM
DUP _||_ REM
These would seem to imply that "knowing ADD and REM, makes INTROD and COMPLEX" independent (similar for DUP). Do our data support that claim?
```{r}
d <- data |> select(y=INTROD,
A=A,
C=C,
D=D,
R=R,
team=committerteam,
repo=repo)
formula <- bf(y ~ 1 + A + C + R,
zi ~ 1 + A + C + R)
get_prior(data=d,
family=zero_inflated_negbinomial,
formula=formula)
```
```{r}
priors <- c(prior(normal(0, 0.5), class = Intercept),
prior(normal(0, 0.25), class = b),
prior(normal(0, 0.5), class = Intercept, dpar=zi),
prior(normal(0, 0.25), class = b, dpar=zi),
prior(gamma(1, 1), class = shape))
v <- validate_prior(prior=priors,
formula=formula,
data=d,
family=zero_inflated_negbinomial)
v
```
```{r, eval=FALSE}
M_cond_ind <-
brm(data = d,
family = zero_inflated_negbinomial,
file = ".cache/added-M_cond_ind",
formula = formula,
prior = priors,
warmup = 1000,
iter = ITERATIONS,
chains = CHAINS,
cores = CORES,
backend="cmdstanr",
file_refit = "on_change",
threads = threading(THREADS),
save_pars = SAVE_PARS,
adapt_delta = ADAPT_DELTA)
```
```{r, eval=FALSE}
summary(M_cond_ind)
```
All coefficients are != 0, which indicates some sort of dependency. Thus, we conclude that C and INTROD are not conditionally independent given ADD and DEL.
### New DAG