getTableStates | R Documentation |
Fetches the names of the parent variables, or the names of the states of the child variable from a conditional probability table.
getTableStates(table)
getTableParents(table)
table |
A conditional probability table expressed as a data frame. |
These functions assume that table
is a conditional probability
table (or a set of hyper-Dirichlet parameters) which is shaped like a
data frame. Columns in the data frame which are factors are assumed
to hold values for the parent (conditioning) variables. Columns in
the data frame which are numeric are assumed to correspond to possible
states of the child (dependent) variable.
For getTableParents()
, a character vector giving the names of
the parent variables (factor columns).
For getTableStates()
, a character vector giving the names of
the child states (numeric columns).
StatShop usually assumes that the states are ordered from the highest to the lowest possible values, for example ‘High’, ‘Med’, ‘Low’.
Russell Almond
rescaleTable
, numericPart
#conditional table
# Note in R 4.0, parents must be explicitly made into factors
X2.ptf <- data.frame(Theta=factor(c("Expert","Novice")),
correct=c(4,2),
incorrect=c(2,4))
#Unconditional table
Theta.ptf <- data.frame(Expert=3,Novice=3)
stopifnot(
identical(getTableStates(X2.ptf), c("correct","incorrect")),
identical(getTableStates(Theta.ptf), c("Expert","Novice")),
identical(getTableParents(X2.ptf), "Theta"),
identical(getTableParents(Theta.ptf), character(0))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.