Skip to content

Your first run

This page shows how to create a project with simulated data, run the analysis and open the report. It takes about ten minutes. The example project is also a useful template for your own study.

1. Move to a working folder

Open a terminal and move to the folder where you want to store your analyses, for example Documents:

cd ~/Documents
cd $HOME\Documents

You can use any folder. A project is an ordinary folder and can be moved or copied later. For more information, see Terminal basics.

2. Create the example project

layerbn init my-study

If layerbn is not found

Use python3 -m layerbn init my-study (Windows: python -m layerbn init my-study; with Python 3.14 next to a newer version: python3.14 -m layerbn init my-study). Use the same form for the other commands on this page. See Install.

The output is:

Created a worked example in my-study:
  settings.yml          how to analyse (open it in a text editor)
  variables.xlsx        the variables and their layers (open it in Excel)
  data/demo_cohort.csv  simulated data for 800 participants

Try it:
  cd my-study
  layerbn run --fast            about 20 seconds
Then open results/report.html in your browser.

The project folder has this structure:

my-study/
├── settings.yml          analysis settings
├── variables.xlsx        variables and layers
└── data/
    └── demo_cohort.csv   data

settings.yml and variables.xlsx are the only files you edit. For your own study, you fill them in as described in Your own study.

3. Run the analysis

Move into the project folder and start the run:

cd my-study
layerbn run --fast

The terminal shows the progress of each step. The last lines are:

Writing the report

Done. Open .../my-study/results/report.html

--fast uses 20 bootstrap resamples instead of 100. This is sufficient for a first look. The report is labelled as a trial run.

4. Open the report

open results/report.html
start results\report.html

You can also double-click report.html in the results folder. The report opens in a browser. Each section starts with a short explanation of how to read it.

Section Contents
Design The layers and variables, before any model is fitted
Data and bins How each continuous variable was divided into groups
Network The learned network, the stability of each arc, and the variables most associated with the outcome
Profiles The probability of the outcome in groups that you define
Sweep The probability of the outcome across the range of one variable
Comparison of networks Arc stability per network, if more than one network is fitted
Methods A draft methods paragraph based on the settings
Reproducibility Software versions, seed and file checksums

Open the example report

The example study

The simulated data follow a common cohort design: characteristics measured at baseline and an outcome at follow-up. The variable names are generic.

Layer Variables Measured
Background AGE, SEX baseline
Exposures EXPOSURE_A (a score), EXPOSURE_B (yes/no) baseline
Baseline measures MEASURE_1, MEASURE_2, MEASURE_3 baseline
Outcome OUTCOME (yes/no), the target follow-up

The network of the example

Network learned from the example data. Each row is a layer, from top to bottom. Each card shows the distribution of one variable in the fitted network. The percentage on an arc is the proportion of 100 bootstrap resamples in which the arc was learned.

Simulated data

The data were generated from a known network, so the learned network can be compared with the true one. The data do not describe real participants and cannot be used for scientific conclusions.

5. Use the interactive explorer

For each network, the run also creates an interactive page, results/networks/all_variables_explorer.html. The explorer for the example is shown below. Click a state, for example Yes under Exposure B, to set it as evidence. The other distributions are updated. A grey tick marks each distribution before the evidence was set.

Open in full screen

Next steps

  • Analyse your own data

    The six steps from preparing the data to the final run.

    Your own study

  • Interpret the figures

    What each figure and table shows, and its limitations.

    Reading the results