as.grain: Convert to grain.

Description Usage Arguments Details Value See Also Examples

View source: R/query.R

Description

This is an interface to the package gRain. We supply a Bayesian Network, its parameters, and the raw data. An object of class 'grain' is returned. This object can be queried

Usage

1
  as.grain(x, net, dat)

Arguments

x

A list of multinomial parameters, in the form output by ml

net

a Bayesian Network. An object of class 'bn'

dat

A data.frame with factors in columns. The columns should correspond to the nodes of net, and the parameters of x.

Details

Specifically, this function is a wrapper around cptable, extractCPT and grain.

Value

An object of class "grain".

See Also

querygrain for querying the result. For queries involving conditioning, use setFinding before running querygrain. marginalGivenOthers, marginalGivenIntervention, queryFinding

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
d <- data.frame(
  a = factor(c(1, rep(3,2), rep(1, 7))),
  b = factor(c(2, rep(1, 4), rep(2, 5))),
  c = factor(c(2, rep(2, 3), rep(1, 6)))
)

net <- bn(integer(0), integer(0), c(1,2))
out <- ml(net, d)

as.grain(out, net, d)

rjbgoudie/structmcmc documentation built on Nov. 3, 2020, 3:41 a.m.