Description Usage Arguments Details Value Note Author(s) References See Also Examples
Creating grain objects (graphical independence network).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | grain(x, ...)
## S3 method for class 'cpt_spec'
grain(x, control = list(), smooth = 0, compile = TRUE, details = 0, ...)
## S3 method for class 'CPTspec'
grain(x, control = list(), smooth = 0, compile = TRUE, details = 0, ...)
## S3 method for class 'pot_spec'
grain(x, control = list(), smooth = 0, compile = TRUE, details = 0, ...)
## S3 method for class 'graphNEL'
grain(
x,
control = list(),
smooth = 0,
compile = TRUE,
details = 0,
data = NULL,
...
)
## S3 method for class 'dModel'
grain(
x,
control = list(),
smooth = 0,
compile = TRUE,
details = 0,
data = NULL,
...
)
|
x |
An argument to build an independence network from. Typically a list of conditional probability tables, a DAG or an undirected graph. In the two latter cases, data must also be provided. |
... |
Additional arguments, currently not used. |
control |
A list defining controls, see 'details' below. |
smooth |
A (usually small) number to add to the counts of a table if the grain is built from a graph plus a dataset. |
compile |
Should network be compiled. |
details |
Debugging information. |
data |
An optional data set (currently must be an array/table) |
If 'smooth' is non-zero then entries of 'values' which a zero are replaced by the value of 'smooth' - BEFORE any normalization takes place.
An object of class "grain"
A change from earlier versions of this package is that grain objects are now compiled upon creation.
Søren Højsgaard, sorenh@math.aau.dk
Søren Hø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/.
cptable
, compile.grain
,
propagate.grain
, setFinding
,
setEvidence
, getFinding
,
pFinding
, retractFinding
,
extractCPT
, extractPOT
,
compileCPT
, compilePOT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ## Asia (chest clinic) network created from conditional probability tables
yn <- c("yes", "no")
a <- cptable(~asia, values=c(1,99), levels=yn)
t.a <- cptable(~tub+asia, values=c(5,95,1,99), levels=yn)
s <- cptable(~smoke, values=c(5,5), levels=yn)
l.s <- cptable(~lung+smoke, values=c(1,9,1,99), levels=yn)
b.s <- cptable(~bronc+smoke, values=c(6,4,3,7), levels=yn)
e.lt <- cptable(~either+lung+tub, values=c(1,0,1,0,1,0,0,1), levels=yn)
x.e <- cptable(~xray+either, values=c(98,2,5,95), levels=yn)
d.be <- cptable(~dysp+bronc+either, values=c(9,1,7,3,8,2,1,9), levels=yn)
chest.cpt <- compileCPT(a, t.a, s, l.s, b.s, e.lt, x.e, d.be)
chest.bn <- grain(chest.cpt)
## Create network from data and graph specification.
## There are different ways; see documentation in the "See all"
## links.
data(lizard, package="gRbase")
# DAG: height <- species -> diam
daG <- dag(~species + height:species + diam:species)
# UG : [height:species][diam:species]
uG <- ug(~height:species + diam:species)
bn.uG <- grain(uG, data=lizard)
bn.daG <- grain(daG, data=lizard)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.