-
Notifications
You must be signed in to change notification settings - Fork 11
/
multi_dimensional_analysis.Rmd
121 lines (93 loc) · 3.64 KB
/
multi_dimensional_analysis.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
---
title: "bupaR Docs | Multi-dimensional analysis"
output:
html_document:
toc: false
---
```{r echo = F, out.width="25%", fig.align = "right"}
knitr::include_graphics("images/icons/multi.PNG")
```
***
# Multi-dimensional analysis
```{r include = F}
library(bupaverse)
knitr::opts_chunk$set(fig.height=3)
```
```{r eval = F}
library(bupaverse)
```
By combining metrics with [`group_by()`](wrangling.html#group_by) and [`augment()`](augment.html), you can perform analysis that combine multiple perspectives.
For example, let's say we want to compare throughput time (performance) with trace length (control-flow). We start by computing the throughput time per case.
```{r}
traffic_fines %>%
throughput_time(level = "case", units = "weeks") %>%
head()
```
Subsequently, we add this information to the log using `augment()`, and store the result as `tmp`.
```{r}
traffic_fines %>%
throughput_time(level = "case", units = "weeks") %>%
augment(traffic_fines) -> tmp
```
Now, we have 2 options. Option 1 is to calculate the `trace_length()` as well, and adding it again to the log.
```{r}
tmp %>%
trace_length(level = "case") %>%
augment(tmp, prefix = "length") -> tmp2
```
We then have both the performance and coverage information in the log, and can visualize their relationship.
```{r}
library(ggplot2)
tmp2 %>%
ggplot(aes(length_absolute, throughput_time)) +
geom_boxplot(aes(group = length_absolute))
```
However, this requires that we have some knowledge about `ggplot2`. Alternatively, we can use `group_by()` and the default `plot()` method provided by `bupaR`.
Going back to `tmp`, recall we have the continuous _throughput_time_ variable. Let's use `cut()` to create multiple categories of throughput time. We start by looking at the throughput time distribution.
```{r}
tmp %>%
throughput_time(units = "weeks")
```
Let's say use Q1, Q3 and the median to create 4 groups.
```{r}
tmp %>%
mutate(throughput_time_bin = cut(as.numeric(throughput_time), breaks = c(-Inf, 1, 17.85, 85.14, Inf)))
```
Observe that we have now 4 groups under _throughput_time_bin_ with the roughly same number of cases.
```{r}
tmp %>%
mutate(throughput_time_bin = cut(as.numeric(throughput_time), breaks = c(-Inf, 1, 17.85, 85.14, Inf))) %>%
group_by(throughput_time_bin) %>%
n_cases()
```
Now, instead of using `group_by()` and `n_cases()`, we can use `group_by()` followed by `trace_length()`. This gives us the distribution of the trace length, for each of the groups.
```{r}
tmp %>%
mutate(throughput_time_bin = cut(as.numeric(throughput_time), breaks = c(-Inf, 1, 17.85, 85.14, Inf))) %>%
group_by(throughput_time_bin) %>%
trace_length()
```
We plot this new information:
```{r}
tmp %>%
mutate(throughput_time_bin = cut(as.numeric(throughput_time), breaks = c(-Inf, 1, 17.85, 85.14, Inf))) %>%
group_by(throughput_time_bin) %>%
trace_length() %>%
plot()
```
While the resulting default plot might not be ideal for your situation (as here, it doesn't work well with trace lengths discrete characteristic), you can get a first insight without needing any additional visualization expertise.
Note that, if we turn the analysis the other way around (e.g. what is the impact of trace length on throughput time?), things get even easier as the discrete trace length variable can be directly fed to `group_by()`.
```{r}
traffic_fines %>%
trace_length(level = "case") %>%
augment(traffic_fines, prefix = "length") %>%
group_by(length_absolute) %>%
throughput_time() %>%
plot()
```
Finally, note that you are not restricted to combining calculated metrics. You can also combine metrics with data attributes.
```{r}
eventdataR::hospital %>%
group_by(group) %>%
trace_length()
```