| ptable {gRbase} | R Documentation |
General representation of multidimensional
tables (by ptable objects).
ptable(varNames, levels, values = 1, normalize = c("none", "first", "all"), smooth = 0)
as.ptable <- function(values, normalize=c("none","first","all"), smooth=0)
tableMarginPrim(t1, margin, normalize=FALSE)
## S3 method for class 'ptable':
varNames(x)
## S3 method for class 'ptable':
nLevels(x)
## S3 method for class 'ptable':
valueLabels(x)
varNames |
Names of variables defining table |
levels |
Either vector with number of levels of the factors in varNames or list vith specification of the levels of the factors in varNames. See 'examples' below. |
values |
Table values |
x |
Objects of class "ptable" |
t1 |
Objects of class "ptable" |
margin |
Set of nodes to marginalize onto |
normalize |
Should result be normalized, see 'Details' below. |
smooth |
Should values be smoothed, see 'Details' below. |
A ptable object represents a table defined by a set of variables and their levels, together with the values of the table. E.g. f(a,b,c) can be a table with a,b,c representing levels of binary variable
If normalize="first" then for each configuration of the parents,
"pa", the probabilities are normalized to sum to one. Thus f(a,b,c)
becomes a conditional probability table of the form p(a|b,c). If
normalize="all" then the sum over all entries of f(a,b,c) is
one.
If smooth is positive then smooth is added to
values before normalization takes place.
as.ptable can be used for coercing a an array to a ptable
object.
An object of class ptable.
Søren Højsgaard, sorenh@agrsci.dk
t1 <- ptable(c("gender","answer"),list(c('male','female'),c('yes','no')), values=1:4)
t1 <- ptable(~gender+answer,list(c('male','female'),c('yes','no')), values=1:4)
t1 <- ptable(~gender+answer,c(2,2), values=1:4)
t2 <- ptable(c("answer","category"), list(c('yes','no'),c(1,2)), values=1:4+10)
t3 <- ptable(c("category","foo"), c(2,2), values=1:4+100)
varNames(t1)
nLevels(t1)
valueLabels(t1)