cpt {gRain}R Documentation

Create conditional probability tables (CPTs)

Description

Creates conditional probability tables of the form p(v|pa(v)).

Usage

cptable(v, pa = NULL, values = NULL, gmData=NULL, normalize = TRUE, smooth = 0, levels=NULL)
cptspec(x)

Arguments

v Variable
pa Possible parents
gmData Name of gmData object (where to look for v and pa)
values Probabilities; recycled if necessary
normalize See 'details' below.
smooth See 'details' below.
levels See 'details' below.
x A list of cpts

Details

If normalize=TRUE then for each configuration of the parents, "pa", the probabilities are normalized to sum to one.

If smooth is non–zero then zero entries of values are replaced with smooth before normalization takes place.

If no gmData object is given, then levels (giving the levels of 'v') must be given. Otherwise levels is ignored.

Value

If a gmData object is given, then 'cpt' returns an object of class 'ctab' (which is a general representation of a table).
If no gmData object is given, then 'cpt' returns an object of class 'cptTemplate'.
'cptspec' returns an object of class 'cptspec' (which is just a list with a special class attribute).

Author(s)

Søren Højsgaard, sorenh@agrsci.dk

Examples

g <- newgmData(letters[1:5],nLevels=2)

t1 <- cptable("a",pa="b", gmData=g,values=1:4)

t2 <- cptable("a",pa=c("b","c"), levels=c("y","n"),values=1:4)


[Package gRain version 0.4.1 Index]