logical: Conditional probability tables based on logical dependencies

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Generate conditional probability tables based on the logical expressions AND and OR.

Usage

1
2
3
4
5
6
7
8
9
booltab(vpa, levels = c(TRUE, FALSE), op = `&`)

andtab(vpa, levels = c(TRUE, FALSE))

ortab(vpa, levels = c(TRUE, FALSE))

andtable(vpa, levels = c(TRUE, FALSE))

ortable(vpa, levels = c(TRUE, FALSE))

Arguments

vpa

Node and two parents; as a formula or a character vector.

levels

The levels (or rather labels) of v, see 'examples' below.

op

A logical operator.

Details

Regarding the form of the argument vpa: To specify P(a|b,c) one may write ~a|b+c or ~a+b+c or ~a|b:c or ~a:b:c or c("a","b","c"). Internally, the last form is used. Notice that the + and : operator are used as separators only. The order of the variables is important so + does not commute.

Value

An array.

Note

andtable and ortable are aliases for andtab and ortab and are kept for backward compatibility.

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/.

See Also

cptable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Logical OR:

## A variable v is TRUE if either of its parents pa1 and pa2 are TRUE:
ortab( c("v", "pa1", "pa2") ) %>% ftable(row.vars="v")
## TRUE and FALSE can be recoded to e.g. yes and no:
ortab( c("v", "pa1", "pa2"), levels=c("yes", "no") ) %>% ftable(row.vars="v")

## Logical AND:

## Same story here:
andtab( c("v", "pa1", "pa2") ) %>% ftable(row.vars="v")
andtab( c("v", "pa1", "pa2"), levels=c("yes", "no") ) %>% ftable(row.vars="v")

## Combined approach

booltab(c("v", "pa1", "pa2"), op=`&`) %>% ftable(row.vars="v") ## AND
booltab(c("v", "pa1", "pa2"), op=`|`) %>% ftable(row.vars="v") ## OR

booltab(~v+pa1+pa2, op=`&`) %>% ftable(row.vars="v") ## AND
booltab(~v+pa1+pa2, op=`|`) %>% ftable(row.vars="v") ## OR

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