Builds a theory from model code as DAGitty writes it, such as
dag { x -> m -> y; x <-> y }, with or without the graph type and its
braces. Each variable becomes a construct whose id and label are its name,
in order of first appearance, and whose definition is left empty for the
author to write. Each arrow becomes a proposition: a -> b and
b <- a relate a to b by relation,
"causes" by default or "increases" or "decreases" when
every arrow has that sign, and a <-> b is an association, a common
cause the diagram leaves unexplained. A chain such as a -> b -> c
gives one proposition per arrow, and a group in braces, as in
a -> {b c}, one per member. Propositions are numbered p1,
p2 and so on in order of appearance, and a repeated edge is kept
once. Bracketed attributes such as [exposure], [latent] or
pos="0,1", and graph settings such as bb="0,0,1,1", are read
and ignored, except that a variable marked [latent] keeps the mark as
x_latent: true. It stays a construct whose relations the theory
states. tf_entailments() never adjusts for it, while tf_implications()
may write a statement that holds it fixed, which needs a measure of it
before data can test it. tf_diagram() with type = "causal_dag"
writes the mark back.
Usage
tf_read_dagitty(
text,
id = "dagitty-import",
title = "Causal diagram imported from DAGitty",
relation = "causes"
)Details
The theory is at draft maturity and records the import in its
provenance. It does not pass tf_validate() until each construct has a
definition, which a diagram cannot supply. tf_diagram() with
type = "causal_dag" writes the propositions back as DAGitty code.
The function stops when relation is not one of the three above, when
the diagram holds an undirected edge (--), which theoryforge has no
relation for, or is a MAG or a PAG, whose edge marks it cannot hold, when a
variable is marked [selected], when an edge lacks a variable at one
end, and when a quotation mark, an attribute list or a brace is left open.
References
Textor, J., van der Zander, B., Gilthorpe, M. S., Liśkiewicz, M., & Ellison, G. T. H. (2016). Robust causal inference using directed acyclic graphs: The R package 'dagitty'. International Journal of Epidemiology, 45(6), 1887-1894. doi:10.1093/ije/dyw341