Skip to content

3 · Fill in variables.xlsx

variables.xlsx specifies which columns of the data are used and to which layer each column belongs. Open the file from the project folder in Excel or LibreOffice. It contains four sheets:

Sheet Use
instructions A summary of this page
layers One row per layer
variables One row per variable
timepoints Only for variables measured at several visits; otherwise leave empty

Fill in the layers sheet first. The layer column on the variables sheet is a dropdown list based on it.

Step A: the layers sheet

Add one row per layer, in the assumed order, with the first layer in the top row. Only the first column is required.

layer label repeated arcs_within colour
Background no
Lifestyle no
Clinical no
Outcome no no
Column Description
layer Required. A short name, used in the figures.
label Optional. A longer name for the figures.
repeated no, unless the same variables were measured at several time points. See Measurements over time.
arcs_within Empty: arcs between variables in this layer are allowed. no: these arcs are not allowed. Use no for an outcome layer with several outcomes.
colour Optional. If empty, the layers are coloured from blue (first layer) to red (last layer).

Step B: the variables sheet

Add one row for each data column to include in the network. Within a layer, the order of the rows determines the order in the figures.

variable label layer type bins cutpoints target
AGE Age (years) Background
SEX Sex Background
SMOKING Smoking Lifestyle
SBP Systolic blood pressure Clinical 120; 140
SCORE_A Score A Clinical 3
EVENT Event during follow-up Outcome yes
Column Description
variable Required. The column name in the data, spelled exactly the same, including upper and lower case. Copy the name from the data file to avoid typing errors.
label Recommended. The name shown in figures and tables, for example Systolic blood pressure instead of SBP.
layer Required. Select the layer from the dropdown list.
type Usually empty; layerbn determines the type from the data. Enter categorical to treat a numeric column as categories (for example, a group coded 1 to 12), or continuous to divide a numeric column with few distinct values into groups.
bins Optional. The number of groups for a continuous variable. The default is 4.
cutpoints Optional. Cut-off values, separated by semicolons. 120; 140 creates three groups: below 120, 120 to below 140, and 140 or higher. Use this for established clinical cut-offs; see Clinical cut-off values.
target yes for the variables of main interest, usually the outcome. Targets have a solid title strip in the figures and are used by default in the analyses.
missing Optional. How to handle empty cells in this variable: category models them as a state Missing, drop_rows excludes the participants concerned, and error stops the run. If empty, the setting in settings.yml is used. See Missing values.

Clinical cut-off values

By default, continuous variables are divided into groups of equal size (quantiles). These groups depend on the sample and have no clinical meaning. If a variable has established thresholds, enter them in the cutpoints column of that variable. The discretisation settings in settings.yml then no longer apply to it.

For example, for test scores expressed as z-scores against normative data:

variable label layer bins cutpoints
SCORE_A_Z Score A (z) Clinical -1.5
SCORE_B_Z Score B (z) Clinical -2; -1
Cut-off values Groups
-1.5 below −1.5 (impaired); −1.5 or higher
-2; -1 below −2; −2 to below −1; −1 or higher

Thresholds of −1, −1.5 and −2 standard deviations are common definitions of below-average performance, impairment and severe impairment. Use the thresholds that are standard in your field.

  • Separate values with semicolons, and use a point or a comma as the decimal mark (-1.5 or -1,5).
  • Leave bins empty. A variable can have bins or cutpoints, not both.
  • A value equal to a cut-off is assigned to the higher group: a z-score of exactly −1.5 is in the group "−1.5 or higher". For a definition such as "−1.5 or lower", use a slightly higher cut-off, for example -1.49.
  • Check the number of participants per group in the bins table of the report. A group with few participants is estimated with low precision, and arcs to the variable are less likely to be learned. In that case, use fewer cut-off values.
  • Fixed cut-off values result in the same groups in every cohort, which makes results comparable between cohorts. Quantile groups differ between samples.

Dropdown lists

The layer, type, target and missing columns are dropdown lists. Selecting values from the lists prevents a layer name from being spelled differently in two places.

Notes

Columns named note or comment are ignored. You can use them to record why a variable is in a particular layer, for use in the methods section.

Step C: save and close the file

Save the workbook as .xlsx under the same name, and close it in Excel before you run layerbn. On Windows, a file that is open in Excel cannot always be read.

Using CSV files instead of a workbook

The same tables can be stored as CSV files in the project folder, variables.csv and layers.csv, with the same column names. See the reference.

Example of a completed workbook

The example project contains a completed variables.xlsx. To create it, run layerbn init my-study (see Your first run).

Next: choose the settings