Skip to main content

Discrete Network | Manual Construction Tutorial

In this tutorial we will manually construct the simple discrete Bayesian network shown below.

info

This network is also included as a sample network with Bayes Server called Causal Inference Simple

Causal Inference Simple

The steps to build the network are listed below, along with their data driven alternatives.

  1. Manually add nodes (alternatively we can Add nodes from data)
  2. Manually add links (alternatively we can use Structural Learning)
  3. Manually specify the node distributions (alternatively we can use Parameter learning)
info

You can mix and match the above steps. For example you could 1. Add nodes from data, 2. Add links manually and then 3. Learn the node distributions from data. Futhermore you could learn some node distributions from data while specifying some manually.

Create a new model

  • Either click File->New from the main menu, or from the Start Page click New Empty Network.

Add Comorbidity Node

  • From the Build tab on the main menu, click Node->Discrete.

  • Change the Name to Comorbidity.

  • Ensure the node has 2 states added, and name them False and True by double clicking on each state name.

The New Node dialog should look like this:

New node | Comorbidity

  • Click Ok to add the new node.

Add Drug and Recovered Nodes

  • Repeat the previous step twice using the following names instead:
    • Drug
    • Recovered

Position nodes

  • For each node, click and drag to position similar to below:

Position nodes

Node chart type

  • From the Display tab on the main menu, click Select -> All Nodes.
  • From the Display tab on the main menu, click Node Chart -> Clustered Column.
  • To see the result of the previous action, from the Query tab, click Add -> All nodes to query the network.
  • From the Display tab on the main menu, click Select -> All Nodes.
  • Resize one of the nodes, by dragging the thumbnail on one corner of the node, to match the image below.

Resized nodes

info

You can also select one or more nodes by holding down the Ctrl (⌘ on mac) or Shift keys when clicking nodes, or clicking in whitespace and dragging a bounding box.

Now that the nodes have been added we can manually add some links.

  • From the Build tab on the main menu, click Link -> Add link.
  • Choose Comorbidity in the From dropdown.
  • Choose Drug in the To dropdown.
  • Click Ok.
  • Repeat for the following links
    • Drug -> Recovered
    • Comorbidity -> Recovered
info

You can select a pair of nodes before launching the New Link dialog, and this will auto-populate the From and To fields.

The network should now look like:

Structure complete

Define the distribution for Comorbidity

  • Click the Comorbidity node to select it.
  • From the Build tab of the main menu, click Distributions -> Edit Distribution(s).
  • Click Auto-fit so the labels are easier to see.
  • Double click in each cell to edit, changing the probabilities to the values in the table below.
Comorbidity=FalseComorbidity=True
0.510.49

The dialog should look similar to the following:

P(Comorbidity)

Define the distribution for Drug

  • Click the Drug node to select it.
  • From the Build tab of the main menu, click Distributions -> Edit Distribution(s).
  • Click Auto-fit so the labels are easier to see.
  • Double click in each cell to edit, changing the probabilities to the values in the table below.
ComorbidityDrug=FalseDrug=True
False0.75630252100840330.24369747899159663
True0.233236151603498530.7667638483965015

The dialog should look similar to the following:

P(Drug | Comorbidity)

Define the distribution for Recovered

  • Click the Recovered node to select it.
  • From the Build tab of the main menu, click Distributions -> Edit Distribution(s).
  • Click Auto-fit so the labels are easier to see.
  • Double click in each cell to edit, changing the probabilities to the values in the table below.
ComorbidityDrugRecovered=FalseRecovered=True
FalseFalse0.130.87
FalseTrue0.070.93
TrueFalse0.310.69
TrueTrue0.270.73

The dialog should look similar to the following:

P(Recovered | Drug, Comorbidity)

Verify the network is complete

At this point, the Bayesian network should be fully specified and ready to be queried.

Although this tutorial does not cover querying in any depth, we will quickly add some queries to demonstrate that the network is working as expected.

  • From the Query tab on the main menu, click Add -> All Nodes.
info

You can also add queries by clicking an icon on the Node Toolbar. Also, when you open a network, by default all nodes are queried automatically.

The network should look similar to the following:

Query no evidence)

  • Click on the visual bar representing Recovered=False to set evidence.

The network should look similar to the following:

Query with evidence)