| cpt {gRain} | R Documentation |
Creates conditional probability tables of the form p(v|pa(v)).
cpt(v, pa = NULL, values = NULL, gmData=NULL, normalize = TRUE, smooth = 0, levels=NULL) cptspec(x)
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 |
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.
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).
Søren Højsgaard, sorenh@agrsci.dk
g <- newgmData(letters[1:5],nLevels=2)
t1 <- cpt("a",pa="b", gmData=g,values=1:4)
t2 <- cpt("a",pa=c("b","c"), levels=c("y","n"),values=1:4)