Discrete Network | Manual Construction Tutorial
In this tutorial we will manually construct the simple discrete Bayesian network shown below.
This network is also included as a sample network with Bayes Server called Causal Inference Simple
The steps to build the network are listed below, along with their data driven alternatives.
- Manually add nodes (alternatively we can Add nodes from data)
- Manually add links (alternatively we can use Structural Learning)
- Manually specify the node distributions (alternatively we can use Parameter learning)
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:
- 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:
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.
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.
Add Links
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
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:
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=False | Comorbidity=True |
---|---|
0.51 | 0.49 |
The dialog should look similar to the following:
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.
Comorbidity | Drug=False | Drug=True |
---|---|---|
False | 0.7563025210084033 | 0.24369747899159663 |
True | 0.23323615160349853 | 0.7667638483965015 |
The dialog should look similar to the following:
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.
Comorbidity | Drug | Recovered=False | Recovered=True |
---|---|---|---|
False | False | 0.13 | 0.87 |
False | True | 0.07 | 0.93 |
True | False | 0.31 | 0.69 |
True | True | 0.27 | 0.73 |
The dialog should look similar to the following:
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.
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:
- Click on the visual bar representing Recovered=False to set evidence.
The network should look similar to the following: