# NOT RUN {
## Network for Bernulli experiment; two nodes: X and thetaX
yn <- c("yes", "no") # Values for X
thX.val <- c(.3, .5, .7) # Values for thetaX
prX.val <- rep(1, length(thX.val)) # Probabilities for thetaX values
thX <- cptable(~thetaX, values=prX.val, levels=thX.val)
X <- cptable(~X|thetaX, values=rbind(thX.val,1-thX.val), levels=yn)
cptlist <- compileCPT( list(thX, X) )
bn <- compile( grain( cptlist ) )
querygrain( setEvidence(bn, nodes="X", states="yes") )
## To insert a new prior distribution we may do as follows
## (where we can omit the process of recompiling the network)
prX.val2 <- c(.2,.3,.5)
thX2 <- cptable(~thetaX, values=prX.val2, levels=thX.val)
bn2 <- update(bn, CPTlist=compileCPT( list(thX2, X)))
querygrain( setEvidence(bn2, nodes="X", states="yes") )
# }
Run the code above in your browser using DataLab