library(agena.ai)
#Creating the variables, all of which are binary False/True nodes
<- new("Node", id="A", name="Visit to Asia?")
A <- new("Node", id="S", name="Smoker?")
S
<- new("Node", id="T", name="Has tuberculosis")
TB <- new("Node", id="L", name="Has lung cancer")
L <- new("Node", id="B", name="Has bronchitis")
B
<- new("Node", id="TBoC", name="Tuberculosis or cancer")
TBoC
<- new("Node", id="X", name="Positive X-ray?")
X <- new("Node", id="D", name="Dyspnoea?") D
#Creating the arcs between parent and child nodes by adding parents
$add_parent(A)
TB#> Node A has been added to the parents list of T
#> NPT values for T are reset to uniform
$add_parent(S)
L#> Node S has been added to the parents list of L
#> NPT values for L are reset to uniform
$add_parent(S)
B#> Node S has been added to the parents list of B
#> NPT values for B are reset to uniform
$add_parent(TB)
TBoC#> Node T has been added to the parents list of TBoC
#> NPT values for TBoC are reset to uniform
$add_parent(L)
TBoC#> Node L has been added to the parents list of TBoC
#> NPT values for TBoC are reset to uniform
$add_parent(TBoC)
X#> Node TBoC has been added to the parents list of X
#> NPT values for X are reset to uniform
$add_parent(TBoC)
D#> Node TBoC has been added to the parents list of D
#> NPT values for D are reset to uniform
$add_parent(B)
D#> Node B has been added to the parents list of D
#> NPT values for D are reset to uniform
$set_probabilities(list(0.99, 0.01))
A$set_probabilities(list(c(0.99,0.01),c(0.95,0.05)),by_rows = FALSE)
TB$set_probabilities(list(c(0.9,0.1),c(0.99,0.01)),by_rows = FALSE)
L$set_probabilities(list(c(0.7,0.3), c(0.4,0.6)),by_rows = FALSE)
B$set_probabilities(list(c(1,0),c(0,1),c(0,1),c(0,1)),by_rows = FALSE)
TBoC$set_probabilities(list(c(0.95,0.05), c(0.02,0.98)),by_rows = FALSE)
X$set_probabilities(list(c(0.9,0.1),c(0.2,0.8),c(0.3,0.7),c(0.1,0.9)),by_rows = FALSE) D
= new("Network", id="asia_net", nodes=c(A,S,TB,L,B,TBoC,X,D))
asia_net = new("Model", networks = list(asia_net)) asia_model
$to_cmpx() asia_model