There are fundamentally three ways to get the DAG:
- Prior knowledge
- Discovery algorithms
The production of Directed Acyclic Graphs (DAGs) is based on subject matter knowledge. Usually experts who understand the underlying data generating process can draw the causal structural graph that can be used as a starting point for causal inference.
Judea Pearl says people should use "common sense" to come up with a DAG.
Currently, human expertise is at the centre of causal discovery. but, there is a growing field of Causal Discovery, where algorithms are being used to determine the causal structure of the data.
A popular causal discovery algorithm is the PC Algorithm. It learns the the structure of a causal Bayesian network. With a data set, for a pair of variables or nodes $(X,Y)$, the PC algorithm tests their conditional independence given the other variables, and it claims the non-existence of a causal relationship between $X$ and $Y$, i.e. no edge to be drawn between $X$ and $Y$, once it finds that $X$ and $Y$ are independent given some other variables.