settings.yml¶
All settings except data: file have a default value. An unknown setting results in an
error with a suggested correction. The file created by layerbn init describes each setting
in a comment.
The complete file, with each setting and its default value or an example:
settings_version: 3
name: text # shown in the report
description: text # shown in the report
output_dir: results # relative to this file, or a full path
data:
file: data/cohort.csv # relative to this file, or a full path
variables_file: variables.xlsx # default: variables.xlsx or variables.csv beside this file
missing: error # error | category | drop_rows
column_pattern: "{variable}_{time}"
discretisation:
method: quantile # quantile | uniform
bins: 4 # at least 2
categorical_max_levels: 10 # numeric variables with at most this many values are not binned
learning:
score: K2 # K2 | BIC | BDeu
search: tabu # tabu | greedy
max_parents: 5
seed: 42
bootstrap:
resamples: 200
constraints:
within_layers: true # default for layers without their own arcs_within
forbid: [ {from: A, to: B}, {from_layer: X, to_layer: Y} ]
require: [ {from: C, to: D} ]
no_parents: [A]
no_children: [B]
networks:
- name: all_variables
description: text
exclude_layers: [Layer name]
exclude_variables: [VARIABLE]
resamples: 50 # overrides bootstrap: resamples
analyses:
importance:
targets: [VARIABLE]
profiles:
network: all_variables
resamples: 200
targets: [VARIABLE]
groups:
"Group name": {VARIABLE: value, OTHER: value}
sweep:
network: all_variables
resamples: 200
variable: VARIABLE
fixed: {OTHER: value}
targets: [VARIABLE]
data¶
| Setting | Description |
|---|---|
file |
The data file. Can instead be given with --data on the command line. |
missing |
error: stop and list the variables with missing values. category: model missing values as a separate state Missing. drop_rows: exclude participants without a value and report the number excluded. The missing column in the variables table takes precedence for individual variables. See Missing values. |
column_pattern |
Only for repeated layers: the naming pattern of the data column of a variable at a time point, using {variable} and {time}. Default: {variable}_{time}. |
discretisation¶
Continuous variables are divided into bins. quantile creates bins with approximately equal
numbers of participants; uniform creates bins of equal width. A numeric variable with at
most categorical_max_levels distinct values is treated as categorical. Settings for
individual variables on the variables sheet take precedence.
learning¶
| Setting | Description |
|---|---|
score |
The score maximised by the structure learning. K2 and BDeu are Bayesian scores with their own prior. BIC penalises complexity more strongly and results in sparser networks. For BIC only, a smoothing prior is added, so that a combination of parent states that does not occur in a resample has a small probability instead of zero. |
search |
tabu searches more thoroughly than greedy hill climbing, but is slower. |
max_parents |
The maximum number of parents of a variable. Each additional parent multiplies the size of the probability table of the variable. |
seed |
The random seed, for reproducibility. Resample i uses the seed seed + i. |
bootstrap¶
resamples is the number of bootstrap resamples. In each resample, participants are drawn
with replacement, the structure and parameters are learned again with the bins of the
complete data, and the arcs are recorded. The run time is approximately proportional to this
number.
constraints¶
Rules restrict the arcs allowed by the layer order further. They cannot allow an arc that conflicts with the order; requiring such an arc results in an error.
| Setting | Description |
|---|---|
within_layers |
Whether arcs between variables in the same layer are allowed. The arcs_within setting of a layer takes precedence. |
forbid |
Arcs that are not allowed. Each end is a variable (from, to) or a layer (from_layer, to_layer), and both can be combined. A layer refers to all its variables. |
require |
Arcs that must be included. They are checked against the layer order, the other rules and each other. A rule for a variable that is not in a network is ignored for that network. |
no_parents |
Variables that cannot have parents (roots). |
no_children |
Variables that cannot have children (sinks). |
networks¶
Each entry defines a network that is learned and bootstrapped separately. Without this
block, one network named main with all variables is learned. exclude_layers and
exclude_variables remove variables from a network; the order of the remaining layers is
unchanged. A network must contain at least two variables.
analyses¶
| Analysis | Network | Description |
|---|---|---|
importance |
every network | The mutual information of each variable with each target, and its relation to the target in the learned network. |
profiles |
one network (network:, default the first) |
The probability of each state of the targets for each group, with a bootstrap interval. |
sweep |
one network (network:, default the first) |
The probability of the targets as variable varies across its states, with the fixed values held constant. |
Values in groups and fixed can be a number (assigned to the bin that contains it), a
category name, or a bin label from the bins table ("≥ 27"). A value that cannot be assigned
is reported and omitted from the profile.