-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocumentation_state.Rmd
940 lines (739 loc) · 27.6 KB
/
documentation_state.Rmd
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
---
title: "Documentation State Model"
author: Hampus Broman & William Levén
date: 2021-05
output:
html_document:
pandoc_args: [ "-o", "docs/documentation_state.html" ]
---
```{r include-setup, include=FALSE}
# Load setup file
source(knitr::purl('setup.Rmd', output = tempfile()))
```
## Looking at the data
We plot the data and can see that there is some difference between the debt versions
```{r}
d.both_completed %>%
mutate_at("high_debt_version",
function(x) case_when(
x == "false" ~ "Low debt",
x == "true" ~ "High debt"
)) %>%
ggplot(aes(high_debt_version, fill = documentation)) +
geom_bar() +
scale_y_reverse() +
xlab("Debt level") +
scale_fill_manual("Documentation state", values = c("Correct" = "darkblue", "None" = "transparent", "Incorrect" = "lightblue"), guide = guide_legend(reverse = TRUE))
```
## Initial model
The type of the outcome is categorical and is hence modeled as categorical.
We include `high_debt_verison` as a predictor in our model as this variable represent the very effect we want to measure.
We also include a varying intercept for each individual to prevent the model from learning too much from single participants with extreme measurements.
### Selecting priors {.tabset}
We iterate over the model until we have sane priors.
#### Base model with priors
```{r initial-model-definition, class.source = 'fold-show'}
documentation.with <- extendable_model(
base_name = "documentation",
base_formula = "documentation ~ 1 + high_debt_version + (1 | session)",
base_priors = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = d.both_completed,
)
```
#### Default priors
```{r default-priors}
prior_summary(documentation.with(only_priors= TRUE))
```
#### Selected priors
```{r selected-priors, warning=FALSE}
prior_summary(documentation.with(sample_prior = "only"))
```
#### Prior predictive check
```{r priors-check, warning=FALSE}
pp_check(documentation.with(sample_prior = "only"), nsamples = 200, type = "bars")
```
#### Beta parameter influence
We choose a beta parameter priors allowing for the beta parameter to account for 100% of the effect but that is skeptical to such strong effects from the beta parameter.
```{r priors-beta, warning=FALSE}
sim.size <- 1000
sim.intercept <- rnorm(sim.size, 0, 1)
sim.beta <- rnorm(sim.size, 0, 1)
sim.beta.diff <- (plogis(sim.intercept + sim.beta) / plogis(sim.intercept) * 100) - 100
data.frame(x = sim.beta.diff) %>%
ggplot(aes(x)) +
geom_density() +
xlim(-80, 80) +
labs(
title = "Beta parameter prior influence",
x = "Estimate with beta as % of estimate without beta",
y = "Density"
)
```
### Model fit {.tabset}
We check the posterior distribution and can see that the model seems to have been able to fit the data well.
Sampling seems to also have worked well as Rhat values are close to 1 and the sampling plots look nice.
#### Posterior predictive check
```{r base-pp-check, warning=FALSE}
pp_check(documentation.with(), nsamples = 200, type = "bars")
```
#### Summary
```{r base-summary, warning=FALSE}
summary(documentation.with())
```
#### Sampling plots
```{r base-plot, message=FALSE, warning=FALSE}
plot(documentation.with(), ask = FALSE)
```
## Model predictor extenstions {.tabset}
```{r mo-priors}
# default prior for monotonic predictor
edlvl_prior <- c(
prior(dirichlet(2), class = "simo", coef = "moeducation_level1", dpar = "muIncorrect"),
prior(dirichlet(2), class = "simo", coef = "moeducation_level1", dpar = "muNone")
)
```
We use `loo` to check some possible extensions on the model.
### One variable {.tabset}
```{r model-extension-1, warning=FALSE, class.source = 'fold-show'}
loo_result <- loo(
# Benchmark model(s)
documentation.with(),
# New model(s)
documentation.with("work_domain"),
documentation.with("work_experience_programming.s"),
documentation.with("work_experience_java.s"),
documentation.with("education_field"),
documentation.with("mo(education_level)", edlvl_prior),
documentation.with("workplace_peer_review"),
documentation.with("workplace_td_tracking"),
documentation.with("workplace_pair_programming"),
documentation.with("workplace_coding_standards"),
documentation.with("scenario"),
documentation.with("group")
)
```
#### Comparison
```{r model-extension-1-sum, warning=FALSE}
loo_result[2]
```
#### Diagnostics
```{r model-extension-1-dig, warning=FALSE}
loo_result[1]
```
### Two variables {.tabset}
```{r model-extension-2, warning=FALSE, class.source = 'fold-show'}
loo_result <- loo(
# Benchmark model(s)
documentation.with(),
documentation.with("group"),
documentation.with("work_domain"),
documentation.with("workplace_peer_review"),
documentation.with("workplace_td_tracking"),
documentation.with("workplace_pair_programming"),
documentation.with("education_field"),
# New model(s)
documentation.with(c("group", "work_domain")),
documentation.with(c("group", "workplace_peer_review")),
documentation.with(c("group", "workplace_td_tracking")),
documentation.with(c("group", "workplace_pair_programming")),
documentation.with(c("group", "education_field")),
documentation.with(c("work_domain", "workplace_peer_review")),
documentation.with(c("work_domain", "workplace_td_tracking")),
documentation.with(c("work_domain", "workplace_pair_programming")),
documentation.with(c("work_domain", "education_field")),
documentation.with(c("workplace_peer_review", "workplace_td_tracking")),
documentation.with(c("workplace_peer_review", "workplace_pair_programming")),
documentation.with(c("workplace_peer_review", "education_field")),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming")),
documentation.with(c("workplace_td_tracking", "education_field")),
documentation.with(c("workplace_pair_programming", "education_field"))
)
```
#### Comparison
```{r model-extension-2-sum, warning=FALSE}
loo_result[2]
```
#### Diagnostics
```{r model-extension-2-dig, warning=FALSE}
loo_result[1]
```
### Three variables {.tabset}
```{r model-extension-3, warning=FALSE, class.source = 'fold-show'}
loo_result <- loo(
# Benchmark model(s)
documentation.with(),
documentation.with("group"),
documentation.with("work_domain"),
documentation.with("workplace_peer_review"),
documentation.with("workplace_td_tracking"),
documentation.with("workplace_pair_programming"),
documentation.with("education_field"),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming")),
documentation.with(c("group", "work_domain")),
documentation.with(c("group", "workplace_peer_review")),
documentation.with(c("group", "workplace_pair_programming")),
documentation.with(c("workplace_peer_review", "workplace_td_tracking")),
# New model(s)
documentation.with(c("workplace_td_tracking", "workplace_pair_programming", "group")),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming", "work_domain")),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming", "workplace_peer_review")),
documentation.with(c("group", "work_domain", "workplace_td_tracking")),
documentation.with(c("group", "work_domain", "workplace_pair_programming")),
documentation.with(c("group", "work_domain", "workplace_peer_review")),
documentation.with(c("group", "workplace_peer_review", "workplace_td_tracking")),
documentation.with(c("group", "workplace_peer_review", "workplace_pair_programming")),
documentation.with(c("group", "workplace_pair_programming", "work_domain")),
documentation.with(c("workplace_peer_review", "workplace_td_tracking", "work_domain"))
)
```
#### Comparison
```{r model-extension-3-sum, warning=FALSE}
loo_result[2]
```
#### Diagnostics
```{r model-extension-3-dig, warning=FALSE}
loo_result[1]
```
### Four variables {.tabset}
```{r model-extension-4, warning=FALSE, class.source = 'fold-show'}
loo_result <- loo(
# Benchmark model(s)
documentation.with(),
documentation.with("group"),
documentation.with("work_domain"),
documentation.with("workplace_peer_review"),
documentation.with("workplace_td_tracking"),
documentation.with("workplace_pair_programming"),
documentation.with("education_field"),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming")),
documentation.with(c("group", "work_domain")),
documentation.with(c("group", "workplace_peer_review")),
documentation.with(c("group", "workplace_pair_programming")),
documentation.with(c("workplace_peer_review", "workplace_td_tracking")),
documentation.with(c("group", "work_domain", "workplace_peer_review")),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming", "workplace_peer_review")),
documentation.with(c("group", "workplace_peer_review", "workplace_pair_programming")),
documentation.with(c("group", "workplace_peer_review", "workplace_td_tracking")),
# New model(s)
documentation.with(c("work_domain", "workplace_peer_review", "workplace_td_tracking", "workplace_pair_programming")),
documentation.with(c("group", "workplace_peer_review", "workplace_td_tracking", "workplace_pair_programming")),
documentation.with(c("group", "work_domain", "workplace_peer_review", "workplace_pair_programming")),
documentation.with(c("group", "work_domain", "workplace_peer_review", "workplace_td_tracking"))
)
```
#### Comparison
```{r model-extension-4-sum, warning=FALSE}
loo_result[2]
```
#### Diagnostics
```{r model-extension-4-dig, warning=FALSE}
loo_result[1]
```
### Five variables {.tabset}
```{r model-extension-5, warning=FALSE, class.source = 'fold-show'}
loo_result <- loo(
# Benchmark model(s)
documentation.with(),
documentation.with("group"),
documentation.with("work_domain"),
documentation.with("workplace_peer_review"),
documentation.with("workplace_td_tracking"),
documentation.with("workplace_pair_programming"),
documentation.with("education_field"),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming")),
documentation.with(c("group", "work_domain")),
documentation.with(c("group", "workplace_peer_review")),
documentation.with(c("group", "workplace_pair_programming")),
documentation.with(c("workplace_peer_review", "workplace_td_tracking")),
documentation.with(c("group", "work_domain", "workplace_peer_review")),
documentation.with(c("workplace_td_tracking", "workplace_pair_programming", "workplace_peer_review")),
documentation.with(c("group", "workplace_peer_review", "workplace_pair_programming")),
documentation.with(c("group", "workplace_peer_review", "workplace_td_tracking")),
documentation.with(c("group", "work_domain", "workplace_peer_review", "workplace_td_tracking")),
documentation.with(c("group", "work_domain", "workplace_peer_review", "workplace_pair_programming")),
# New model(s)
documentation.with(c("group", "work_domain", "workplace_peer_review", "workplace_pair_programming", "workplace_td_tracking"))
)
```
#### Comparison
```{r model-extension-5-sum, warning=FALSE}
loo_result[2]
```
#### Diagnostics
```{r model-extension-5-dig, warning=FALSE}
loo_result[1]
```
## Candidate models {.tabset}
We pick some of our top performing models as candidates and inspect them closer.
The candidate models are named and listed in order of complexity.
### Documentation0 {.tabset}
We select the simplest model as a baseline.
```{r documentation0, class.source = 'fold-show', warning=FALSE, message=FALSE}
documentation0 <- brm(
"documentation ~ 1 + high_debt_version + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.both_completed),
file = "fits/documentation0",
file_refit = "on_change",
seed = 20210421
)
```
#### Summary
```{r documentation0-sum}
summary(documentation0)
```
#### Random effects
```{r documentation0-raneff}
ranef(documentation0)
```
#### Sampling plots
```{r documentation0-plot}
plot(documentation0, ask = FALSE)
```
#### Posterior predictive check
```{r documentation0-pp}
pp_check(documentation0, nsamples = 200, type = "bars")
```
### Documentation1 {.tabset}
We select the best performing model with one variable.
```{r documentation1, class.source = 'fold-show', warning=FALSE, message=FALSE}
documentation1 <- brm(
"documentation ~ 1 + high_debt_version + group + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.both_completed),
file = "fits/documentation1",
file_refit = "on_change",
seed = 20210421
)
```
#### Summary
```{r documentation1-sum}
summary(documentation1)
```
#### Random effects
```{r documentation1-raneff}
ranef(documentation1)
```
#### Sampling plots
```{r documentation1-plot}
plot(documentation1, ask = FALSE)
```
#### Posterior predictive check
```{r documentation1-pp}
pp_check(documentation1, nsamples = 200, type = "bars")
```
### Documentation2 {.tabset}
We select the best performing model with two variables.
```{r documentation2, class.source = 'fold-show', warning=FALSE, message=FALSE}
documentation2 <- brm(
"documentation ~ 1 + high_debt_version + group + work_domain + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.both_completed),
file = "fits/documentation2",
file_refit = "on_change",
seed = 20210421
)
```
#### Summary
```{r documentation2-sum}
summary(documentation2)
```
#### Random effects
```{r documentation2-raneff}
ranef(documentation2)
```
#### Sampling plots
```{r documentation2-plot}
plot(documentation2, ask = FALSE)
```
#### Posterior predictive check
```{r documentation2-pp}
pp_check(documentation2, nsamples = 200, type = "bars")
```
### Documentation3 {.tabset}
We select the best performing model with three variables.
```{r documentation3, class.source = 'fold-show', warning=FALSE, message=FALSE}
documentation3 <- brm(
"documentation ~ 1 + high_debt_version + group + work_domain + workplace_peer_review + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.both_completed),
file = "fits/documentation3",
file_refit = "on_change",
seed = 20210421
)
```
#### Summary
```{r documentation3-sum}
summary(documentation3)
```
#### Random effects
```{r documentation3-raneff}
ranef(documentation3)
```
#### Sampling plots
```{r documentation3-plot}
plot(documentation3, ask = FALSE)
```
#### Posterior predictive check
```{r documentation3-pp}
pp_check(documentation3, nsamples = 200, type = "bars")
```
### Documentation4 {.tabset}
We select the best performing model with four variables.
```{r documentation4, class.source = 'fold-show', warning=FALSE, message=FALSE}
documentation4 <- brm(
"documentation ~ 1 + high_debt_version + group + work_domain + workplace_peer_review + workplace_td_tracking + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.both_completed),
file = "fits/documentation4",
file_refit = "on_change",
seed = 20210421
)
```
#### Summary
```{r documentation4-sum}
summary(documentation4)
```
#### Random effects
```{r documentation4-raneff}
ranef(documentation4)
```
#### Sampling plots
```{r documentation4-plot}
plot(documentation4, ask = FALSE)
```
#### Posterior predictive check
```{r documentation4-pp}
pp_check(documentation4, nsamples = 200, type = "bars")
```
### Documentation5 {.tabset}
We select the best performing model with five variables.
```{r documentation5, class.source = 'fold-show', warning=FALSE, message=FALSE}
documentation5 <- brm(
"documentation ~ 1 + high_debt_version + group + work_domain + workplace_peer_review + workplace_td_tracking + workplace_pair_programming + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.both_completed),
file = "fits/documentation5",
file_refit = "on_change",
seed = 20210421
)
```
#### Summary
```{r documentation5-sum}
summary(documentation5)
```
#### Random effects
```{r documentation5-raneff}
ranef(documentation5)
```
#### Sampling plots
```{r documentation5-plot}
plot(documentation5, ask = FALSE)
```
#### Posterior predictive check
```{r documentation5-pp}
pp_check(documentation5, nsamples = 200, type = "bars")
```
## Final model
All candidate models look nice, candidate 3 is significantly better than the other candidates, we will proceed with: `documentation3`
### Variations {.tabset}
We will try a few different variations of the selected candidate model.
#### All data points {.tabset}
Some participants did only complete one scenario. Those has been excluded from the initial dataset to improve sampling of the models. We do however want to use all data we can and will therefore try to fit the model with the complete dataset.
```{r variation.all, message=FALSE, warning=FALSE, class.source = 'fold-show'}
documentation3.all <- brm(
"documentation ~ 1 + high_debt_version + group + work_domain + workplace_peer_review + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.completed),
file = "fits/documentation3.all",
file_refit = "on_change",
seed = 20210421
)
```
##### Summary
```{r variation.all-sum}
summary(documentation3.all)
```
##### Random effects
```{r variation.all-raneff}
ranef(documentation3.all)
```
##### Sampling plots
```{r variation.all-plot}
plot(documentation3.all, ask = FALSE)
```
##### Posterior predictive check
```{r variation.all-pp}
pp_check(documentation3.all, nsamples = 200, type = "bars")
```
#### With experience predictor {.tabset}
As including all data points didn't harm the model we will create this variant with all data points as well.
This variation includes `work_experience_programming.s` predictors as it can give further insight into how experience play a factor in the effect we try to measure. This is especially important as our sampling shewed towards containing less experienced developer than the population at large.
```{r variation.all.exp, class.source = 'fold-show', message=FALSE, warning=FALSE}
documentation3.all.exp <- brm(
"documentation ~ 1 + high_debt_version + group + work_domain + workplace_peer_review + work_experience_programming.s + (1 | session)",
prior = c(
prior(normal(0, 1), class = "b"),
prior(normal(0, 1), class = "Intercept"),
prior(exponential(1), class = "sd", dpar = "muIncorrect"),
prior(exponential(1), class = "sd", dpar = "muNone")
),
family = categorical(),
data = as.data.frame(d.completed),
file = "fits/documentation3.all.exp",
file_refit = "on_change",
seed = 20210421
)
```
##### Summary
```{r variation.all.exp-sum}
summary(documentation3.all.exp)
```
##### Random effects
```{r variation.all.exp-raneff}
ranef(documentation3.all.exp)
```
##### Loo comparison
```{r variation.all.exp-loo, warning=FALSE}
loo(
documentation3.all,
documentation3.all.exp
)
```
##### Sampling plots
```{r variation.all.exp-plot}
plot(documentation3.all.exp, ask = FALSE)
```
##### Posterior predictive check
```{r variation.all.exp-pp}
pp_check(documentation3.all.exp, nsamples = 200, type = "bars")
```
### Final model
* Fitting the model to all data point did not significantly damage the model and will be used as is a more fair representation of reality.
* Adding the experience predictors did not significantly damage the model and will be used as it provides useful insight.
This means that our final model, with all data points and experience predictors, is `documentation3.all.exp`
## Interpreting the model
To begin interpreting the model we look at how it's parameters were estimated. As our research is focused on how the outcome of the model is effected we will mainly analyze the $\beta$ parameters.
### $\beta$ parameters
#### No documentation
```{r interpret-beta-plot, warning=FALSE, message=FALSE}
mcmc_areas(documentation3.all.exp, pars = c(
"b_muNone_high_debt_versionfalse",
"b_muNone_work_experience_programming.s",
"b_muNone_workplace_peer_reviewfalse",
"b_muNone_groupconsultants",
"b_muNone_groupfriends",
"b_muNone_groupopen",
"b_muNone_groupproductMcompany",
"b_muNone_groupprofessionalMcontact",
"b_muNone_groupstudents",
"b_muNone_work_domainApp",
"b_muNone_work_domainAutomotive",
"b_muNone_work_domainDevops",
"b_muNone_work_domainEMCommerce",
"b_muNone_work_domainEmbedded",
"b_muNone_work_domainFinance",
"b_muNone_work_domainMixed",
"b_muNone_work_domainMusic",
"b_muNone_work_domainNone",
"b_muNone_work_domainRetail",
"b_muNone_work_domainTelecom",
"b_muNone_work_domainWeb"
), prob = 0.95) + scale_y_discrete() +
scale_y_discrete(labels=c(
"High debt version: false",
"Professional programming experience",
"Group: consultants",
"Group: frinds",
"Group: open",
"Group: product-company",
"Group: professional-contacts",
"Group: students",
"Domain: App",
"Domain: Automotive",
"Domain: Dev-ops",
"Domain: E-Commerce",
"Domain: students",
"Domain: Embedded",
"Domain: Finance",
"Domain: Mixed",
"Domain: Music",
"Domain: None",
"Domain: Retail",
"Domain: Telecom",
"Domain: Web"
)) +
ggtitle("Beta parameters densities for no documentation", subtitle = "Shaded region marks 95% of the density. Line marks the median")
```
#### Incorrect documentation
```{r interpret-beta-plot-2, warning=FALSE, message=FALSE}
mcmc_areas(documentation3.all.exp, pars = c(
"b_muIncorrect_high_debt_versionfalse",
"b_muIncorrect_work_experience_programming.s",
"b_muIncorrect_workplace_peer_reviewfalse",
"b_muIncorrect_groupconsultants",
"b_muIncorrect_groupfriends",
"b_muIncorrect_groupopen",
"b_muIncorrect_groupproductMcompany",
"b_muIncorrect_groupprofessionalMcontact",
"b_muIncorrect_groupstudents",
"b_muIncorrect_work_domainApp",
"b_muIncorrect_work_domainAutomotive",
"b_muIncorrect_work_domainDevops",
"b_muIncorrect_work_domainEMCommerce",
"b_muIncorrect_work_domainEmbedded",
"b_muIncorrect_work_domainFinance",
"b_muIncorrect_work_domainMixed",
"b_muIncorrect_work_domainMusic",
"b_muIncorrect_work_domainNone",
"b_muIncorrect_work_domainRetail",
"b_muIncorrect_work_domainTelecom",
"b_muIncorrect_work_domainWeb"
), prob = 0.95) + scale_y_discrete() +
scale_y_discrete(labels=c(
"High debt version: false",
"Professional programming experience",
"Group: consultants",
"Group: frinds",
"Group: open",
"Group: product-company",
"Group: professional-contacts",
"Group: students",
"Domain: App",
"Domain: Automotive",
"Domain: Dev-ops",
"Domain: E-Commerce",
"Domain: students",
"Domain: Embedded",
"Domain: Finance",
"Domain: Mixed",
"Domain: Music",
"Domain: None",
"Domain: Retail",
"Domain: Telecom",
"Domain: Web"
)) +
ggtitle("Beta parameters densities for incorrect documentation", subtitle = "Shaded region marks 95% of the density. Line marks the median")
```
### Effects sizes
```{r effect-size, fig.width=8}
scale_programming_experience <- function(x) {
(x - mean(d.completed$work_experience_programming))/ sd(d.completed$work_experience_programming)
}
unscale_programming_experience <- function(x) {
x * sd(d.completed$work_experience_programming) + mean(d.completed$work_experience_programming)
}
post_settings <- expand.grid(
high_debt_version = c("false", "true"),
group = NA,
work_domain = NA,
session = NA,
workplace_peer_review = NA,
work_experience_programming.s = sapply(c(0, 3, 10, 25, 40), scale_programming_experience)
)
post <- posterior_predict(documentation3.all.exp, newdata = post_settings) %>%
melt(value.name = "estimate", varnames = c("sample_number", "settings_id")) %>%
left_join(
rowid_to_column(post_settings, var= "settings_id"),
by = "settings_id"
) %>%
mutate(work_experience_programming = unscale_programming_experience(work_experience_programming.s)) %>%
select(
estimate,
high_debt_version,
work_experience_programming
)
post %>%
mutate_at("high_debt_version",
function(x) case_when(
x == "false" ~ "Low debt",
x == "true" ~ "High debt"
)) %>%
mutate_at("estimate",
function(x) case_when(
x == 1 ~ "Correct",
x == 2 ~ "Incorrect",
x == 3 ~ "Missing"
)) %>%
ggplot(aes(high_debt_version)) +
geom_bar(aes(fill = estimate), position = "fill") +
facet_grid(rows = vars(work_experience_programming)) +
scale_y_reverse() +
scale_fill_manual("Legend", values = c("darkblue", "#7070FF", "lightblue"), guide = guide_legend(reverse = TRUE)) +
labs(title = "Documentation state") +
xlab("Debt version") +
ylab("Ratio of documentation state")
```
We can see that task completion ratios are similar for both high and low debt but that there is some difference in how often they leave incorrect documentation and will therefore proceed to calculate some probabilities of leaving incorrect documentation.
```{r, class.source = 'fold-show'}
d <- post %>% filter(estimate == 2)
d.high <- d %>% filter(high_debt_version == "true") %>% pull(estimate)
d.low <- d %>% filter(high_debt_version == "false") %>% pull(estimate)
x <- length(d.high) / length(d.low)
x
```
Given all the simulated cases we find that developers are `r scales::label_percent()(x - 1)` more likely to leave incorrect documentation in the high debt version of the scenarios.
```{r, class.source = 'fold-show'}
d <- post %>% filter(estimate == 2, work_experience_programming == 10)
d.high <- d %>% filter(high_debt_version == "true") %>% pull(estimate)
d.low <- d %>% filter(high_debt_version == "false") %>% pull(estimate)
x <- length(d.high) / length(d.low)
x
```
Given developers with 10 years of professional programming experience we find that they are `r scales::label_percent()(x - 1)` more likely to leave incorrect documentation in the high debt version of the scenarios.
```{r, class.source = 'fold-show'}
d <- post %>% filter(estimate == 2, work_experience_programming == 25)
d.high <- d %>% filter(high_debt_version == "true") %>% pull(estimate)
d.low <- d %>% filter(high_debt_version == "false") %>% pull(estimate)
x <- length(d.high) / length(d.low)
x
```
Given developers with 25 years of professional programming experience we find that they are `r scales::label_percent()(x - 1)` more likely to leave incorrect documentation in the high debt version of the scenarios.