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:
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¶
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:
The terminal shows the progress of each step. The last lines are:
--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¶
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 |
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 |

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.
Next steps¶
-
Analyse your own data
The six steps from preparing the data to the final run.
-
Interpret the figures
What each figure and table shows, and its limitations.