You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/motivation.Rmd
+14-8Lines changed: 14 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -22,11 +22,11 @@ Why another graph package in R? The `caugi` package was designed to provide a _f
22
22
library(caugi)
23
23
```
24
24
25
-
### Causality
25
+
### Representation of causal graphs
26
26
27
-
Causal graphs are easy to draw and aid us in understanding causal mechanisms by visual representation. In R, representing them can feel clunky. We usually resort to adjacency matrices, edge lists, or packages like `igraph` or `graph`.
27
+
Causal graphs are easy to draw and aid us in understanding causal mechanisms by visual representation. In R, representing them can feel clunky. Historically, users have resorted to adjacency matrices, edge lists, or packages like `igraph` or `graph`.
28
28
29
-
These packages are great and each have their strengths, but they are not built for _causal_ graphs, which often have special edge types and properties. This leads to situations such as representing undirected edges as two directed edges going in each direction, or representing PAG-type edges by opaque matrix formats, as seen in for example `pcalg`, where
29
+
These tools are great and each have their strengths, but they are not built for _causal_ graphs, which often have special edge types and properties. This leads to situations such as representing undirected edges as two directed edges going in each direction, or representing PAG-type edges by opaque matrix formats, as seen in for example `pcalg`, where
30
30
31
31
```{r pcalg-pag}
32
32
nodes <- c("A", "B", "C", "D", "E")
@@ -44,26 +44,32 @@ amat <- matrix(
44
44
amat
45
45
```
46
46
47
-
describes the graph
47
+
represents the graph
48
48
49
-
```{r caugi-pag}
49
+
```{r caugi-pag, eval=FALSE}
50
50
caugi_graph(
51
51
A %-->% B %o->% C %---% E,
52
52
B %o-o% D %---% E,
53
53
A %--o% E
54
54
)
55
55
```
56
56
57
-
Hopefully, it is clear what is easier to read.
57
+
The second form reads like the picture in your head.
58
58
59
-
In general, for people working in causal inference and causal discovery, the lack of readable, well supported formats can lead to clunky, hacky code that is hard to read and maintain. `caugi` aims to fix this with a readable syntax, which mimics how we draw graphs in hand, and gives the user the ability to express complex causal relationships.
59
+
For people working in causal inference and causal discovery, the lack of readable, well supported formats can lead to clunky, hacky code that is hard to read and maintain. `caugi` aims to fix this with a readable syntax, which mimics how we draw graphs in hand, and gives the user the ability to express complex causal relationships.
60
60
61
61
### Safety
62
62
63
63
When makeshift solutions are used to represent causal graphs, it leads to not only bugs, but confusion and wasted time. With `caugi` we aim to make causal graphs safe to work with, so you do not accidentally create invalid graphs, and so you can focus on the causal problems at hand, not on the representation.
64
64
65
+
We have ensured that `caugi` graph object it should not be possible to alter in such a way that the underlying graph class becomes valid. For example, creating a DAG with `caugi`, acyclicity is guaranteed by construction. Trying to add an edge that would create a cycle will throw an error.
66
+
67
+
More generally, all `caugi` aims to be __graph-class safe__. Think of it as type safety, but on a graph class level. This safety comes at some costs; if `caugi` doesn't support the graph type, you are using, then the graph class should be set to `"Unknown"`, and most operations will not be available. However, this is a small price to pay for safety and clarity. In `caugi`, we prefer clarity over silent misinterpretation.
68
+
65
69
We refer to the vignette `vignette("package_use")` to see how to (safely) use `caugi` in your package.
66
70
67
71
### Performance
68
72
69
-
Due to the underlying data structure of `caugi`, the graph objects are fast to query, but slower to initialize than other graph object types might be. The trade-off is favorable, as graphs are typically queried many times after being created once. This makes `caugi` suitable for large graphs, where performance matters. You can read more about performance in `vignette("performance")`.
73
+
Due to the underlying data structure of `caugi`, the graph objects are fast to query, but slower to initialize than other graph object types might be. The trade-off is favorable, as graphs are typically queried many times after being created once. This makes `caugi` suitable for large graphs, where performance matters, but even for small graphs the performance gain is significant to other packages.
74
+
75
+
You can read more about the performance of `caugi` in `vignette("performance")`.
0 commit comments