cptable {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, levels=NULL, values = NULL, normalize = TRUE, smooth = 0)
cptspec(x)

Arguments

v A vertex
pa The parents of vertex v
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 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.

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


yn <- c("yes","no")
ynm <- c("yes","no","maybe")
a    <- cptable(~asia, values=c(1,99),levels=yn)
t.a  <- cptable(~tub+asia, values=c(5,95,1,99,1,999),levels=ynm)
d.a  <- cptable(~dia+asia, values=c(5,5,1,99,100,999),levels=ynm)
cptspec(list(a,t.a,d.a))


[Package gRain version 0.7.0 Index]