Learn R Programming

gRain (version 1.3-0)

update.CPTgrain: Update a Bayesian network

Description

Update a Bayesian network

Usage

# S3 method for CPTgrain
update(object, ...)

Arguments

object

A Bayesian network of class CPTgrain

If CPTlist is a name in the dotted list, then the object will be update with this value (which is assumed to be a list of conditional probabilities). here~~

Value

A new Bayesian network. If it is a LIST, use

References

S<U+00F8>ren H<U+00F8>jsgaard (2012). Graphical Independence Networks with the gRain Package for R. Journal of Statistical Software, 46(10), 1-26. http://www.jstatsoft.org/v46/i10/.

Examples

Run this code
# 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