update.CPTgrain: Update a Bayesian network

Description Usage Arguments Value Note Author(s) References Examples

Description

Update a Bayesian network

Usage

1
2
## S3 method for class '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

Note

There is NO checking that the input matches the settings in the Bayesian network.

Author(s)

S<c3><b8>ren H<c3><b8>jsgaard, [email protected]

References

S<c3><b8>ren H<c3><b8>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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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") )

gRain documentation built on May 30, 2017, 8:20 a.m.