getTableStates: Gets meta data about a conditional probability table.

getTableStatesR Documentation

Gets meta data about a conditional probability table.

Description

Fetches the names of the parent variables, or the names of the states of the child variable from a conditional probability table.

Usage

getTableStates(table)
getTableParents(table)

Arguments

table

A conditional probability table expressed as a data frame.

Details

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.

Value

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).

Note

StatShop usually assumes that the states are ordered from the highest to the lowest possible values, for example ‘High’, ‘Med’, ‘Low’.

Author(s)

Russell Almond

See Also

rescaleTable, numericPart

Examples

#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))
)

ralmond/CPTtools documentation built on Dec. 27, 2024, 7:15 a.m.