sevt: Staged event tree (sevt) class

View source: R/1-base-model-function.R

sevtR Documentation

Staged event tree (sevt) class

Description

Structure and usage of S3 class sevt, used to store a staged event tree.

Usage

sevt(x, full = FALSE, order = NULL)

## S3 method for class 'table'
sevt(x, full = FALSE, order = names(dimnames(x)))

## S3 method for class 'data.frame'
sevt(x, full = FALSE, order = colnames(x))

## S3 method for class 'list'
sevt(x, full = FALSE, order = names(x))

Arguments

x

a list, a data frame or table object.

full

logical, if TRUE the full model is created otherwise the independence model.

order

character vector, order of the variables to build the tree, by default the order of the variables in x.

Details

A staged event tree object is a list with components:

  • tree (required): A named list with one component for each variable in the model, a character vector with the names of the levels for that variable. The order of the variables in tree is the order of the event tree.

  • stages (required): A named list with one component for each variable but the first, a character vector storing the stages for the situations related to path ending in that variable.

  • ctables: A named list with one component for each variable, the flat contingency table of that variable given the previous variables.

  • lambda: The smoothing parameter used to compute probabilities.

  • name_unobserved: The stage name for unobserved situations.

  • prob: The conditional probability tables for every variable and stage. Stored in a named list with one component for each variable, a list with one component for each stage.

  • ll: The log-likelihood of the estimated model. If present, logLik.sevt will return this value instead of computing the log-likelihood.

The tree structure is never defined explicitly, instead it is implicitly defined by the list tree containing the order of the variables and the names of their levels. This is sufficient to define a complete symmetric tree where an internal node at a depth related to a variable v has a number of children equal to the cardinality of the levels of v. The stages information is instead stored as a list of vectors, where each vector is indexed as the internal nodes of the tree at a given depth.

To define a staged tree from data (data frame or table) the user can call either full or indep which both construct the staged tree object, attach the data in ctables and compute probabilities. After, one of the available model selection algorithm can be used, see for example stages_hc, stages_bhc or stages_hclust. If, mainly for development, only the staged tree structure is needed (without data or probabilities) the basic sevt constructor can be used.

Value

A staged event tree object, an object of class sevt.

Examples


######### from table
model.titanic <- sevt(Titanic, full = TRUE) 

######### from data frame
DD <- generate_random_dataset(n = 4, 1000)
model.indep <- sevt(DD)
model.full <- sevt(DD, full = TRUE)

######### from list
model <- sevt(list(
  X = c("good", "bad"),
  Y = c("high", "low")
))

stagedtrees documentation built on April 29, 2022, 1:06 a.m.