ASIA10 model { asia ~ dcat(p.asia[]); #Visit to Asia? smoking ~ dcat(p.smoking[]); #Patient is a Smoker? tuberculosis ~ dcat(p.tuberculosis[asia,]); #Patient has TBC? lung.cancer ~ dcat(p.lung.cancer[smoking,]); #Patient has Lung Cancer? bronchitis ~ dcat(p.bronchitis[smoking,]); #Patient has Bronchitis? either <- max(tuberculosis,lung.cancer); #Abnormality in Chest? xray ~ dcat(p.xray[either,]); #X-Ray Positive? dyspnoea ~ dcat(p.dyspnoea[either,bronchitis,]) #Patient has Shortness of Breath? } DATA IN: list( dyspnoea=2, xray = 1, #put hard evidence here... #next are distributions of initial nodes: p.smoking = c(0.50,0.50), p.asia = c(0.99,0.01), #tand he rest are conditional probability distributions: p.tuberculosis = structure(.Data = c(0.99,0.01,0.95,0.05), .Dim = c(2,2)), p.bronchitis = structure(.Data = c(0.70,0.30,0.40,0.60), .Dim = c(2,2)), p.lung.cancer = structure(.Data = c(0.99,0.01,0.90,0.10), .Dim = c(2,2)), p.xray = structure(.Data = c(0.95,0.05,0.02,0.98), .Dim = c(2,2)), p.dyspnoea = structure(.Data = c(0.9,0.1, 0.2,0.8, 0.3,0.7, 0.1,0.9), .Dim = c(2,2,2))) Just Generate Initials by "gen inits"