2 · Order the variables¶
The order of the variables is a substantive decision that you make based on knowledge of the study. layerbn does not estimate it from the data.
A layer is a group of variables at the same position in the assumed order. The layers are ordered, and an arc can only point to a variable in the same layer or a later layer. Arcs to earlier layers are not allowed. The structure learning determines which of the allowed arcs are included.
flowchart LR
subgraph L1["Background"]
AGE["Age"]
SEX["Sex"]
end
subgraph L2["Exposures"]
EA["Exposure A"]
end
subgraph L3["Baseline measures"]
M1["Measure 1"]
end
subgraph L4["Outcome"]
O["Outcome"]
end
AGE --> EA
EA --> M1
M1 --> O
AGE --> O
O -. "not allowed" .-> AGE
linkStyle 4 stroke:#b2182b,stroke-dasharray:4
style L1 fill:#e4eef7,stroke:#2166ac
style L2 fill:#eef6fa,stroke:#7db8d7
style L3 fill:#fcefe9,stroke:#ec9374
style L4 fill:#f6e3e5,stroke:#b2182b
classDef node fill:#ffffff,stroke:#c4cbd3,color:#1f2328
class AGE,SEX,EA,M1,O node
The order is an assumption
All arcs in the result depend on the order. Describe the order in the methods section and the reasons for it. If the order is incorrect for a pair of variables, the result for that pair is also incorrect, and the data cannot reveal this.
Choosing the order¶
Place a variable in a later layer than another variable if the other variable can influence it, but not the reverse.
-
Time
A variable measured later cannot influence a variable measured earlier. Baseline variables precede follow-up variables.
-
Fixed characteristics
Characteristics such as age and sex are not influenced by other variables in the study. Place them in the first layer.
-
Outcomes
Exposures precede outcomes. Place the outcome in the last layer.
-
Variables measured at the same time
Decide which variable can influence the other, or place both in the same layer if the direction is unknown.
Example¶
| Layer | Variables | Measured | Arcs within the layer |
|---|---|---|---|
| Background | age, sex | baseline | allowed |
| Exposures | exposure A, exposure B | baseline | allowed |
| Baseline measures | measure 1, measure 2, measure 3 | baseline | allowed |
| Outcome | outcome | follow-up | not allowed |
Arcs within a layer¶
Within a layer, the data can show whether two variables are connected, but often not the direction of the arc, because several directions fit the data equally well. Do not interpret the direction of such an arc unless there is external evidence for it.
To prevent arcs within a layer, set arcs_within to no for that layer. This is useful
for items of the same questionnaire, or for a layer of outcomes.
Do not place a variable later because you expect it to be important
The order defines which variables can influence which. It does not express how important a variable is. That is estimated by the analysis.