Skip to content

Bins and sample size

Bins

The network uses categorical variables. Continuous variables are therefore divided into bins, and all results depend on the bins. Review the bins figure and table first.

Situation Consequence
A bin contains few participants Its probabilities are imprecise, and arcs to the variable are less likely to be learned.
A variable has few, wide bins Associations within a bin cannot be detected. Use more bins or set cutpoints; this reduces the number of participants per bin.
Quantile bins have no clinical meaning Set cutpoints to established thresholds, for example -1.5 for a z-score. See Clinical cut-off values.
Two cohorts are compared Quantile bins differ between samples. Set cutpoints so that both cohorts use the same bin edges.
A bin is reported The bin labels are rounded. The exact edges are in the Exact edges column of the bins table.
discretisation:
  method: quantile          # equal numbers of participants per bin; or uniform: equal widths
  bins: 4
  categorical_max_levels: 10

You can set bins, cutpoints or type for individual variables in variables.xlsx.

Bin edges depend on the software version

Quantile edges for the same data can differ slightly between versions of pyAgrum or scikit-learn, for example 36.25 and 36.275. Report the software versions and the exact edges. For this reason, layerbn only accepts specific versions of these packages.

Sample size

The size of the probability table of a variable increases with the number of its states and the number of states of its parents. With few participants, the tables are estimated with low precision, fewer arcs are learned, and the learned arcs are less stable.

Recovery of the structure in the example

The example data were generated from a known network of 8 variables with 4 bins each. In 8 simulated samples, layerbn learned about 75% of the true arcs with 400 participants and about 80% with 800 participants. About 85% of the learned arcs were true arcs. Most errors were arcs within a layer in the reverse direction, which the data cannot distinguish. Results for other data will differ.

For a small sample, reduce the number of variables, bins and max_parents.

Missing data and loss to follow-up

Missing values can be modelled as a separate state, Missing, the participants concerned can be excluded, or the values can be imputed before the analysis. See Missing values for guidance on these options and on the interpretation of a Missing state.

Loss to follow-up that depends on the outcome is not modelled by default. To include it, add a variable such as lost to follow-up (yes/no) to a layer after the outcome, and use rules to specify which variables it can depend on. Alternatively, model a missing outcome as Missing with missing: category.