Learn R Programming

stagedtrees

Citation

To cite stagedtrees in publications use:

Carli F, Leonelli M, Riccomagno E, Varando G (2022). “The R Package stagedtrees for Structural Learning of Stratified Staged Trees.” Journal of Statistical Software, 102(6), 1-30. doi: 10.18637/jss.v102.i06 (URL: https://doi.org/10.18637/jss.v102.i06).

@Article{,
    title = {The {R} Package {stagedtrees} for Structural Learning of Stratified Staged Trees},
    author = {Federico Carli and Manuele Leonelli and Eva Riccomagno and Gherardo Varando},
    journal = {Journal of Statistical Software},
    year = {2022},
    volume = {102},
    number = {6},
    pages = {1--30},
    doi = {10.18637/jss.v102.i06},
  }

Overview

stagedtrees is a package that implements staged event trees, a class of probability models for categorical random variables.

Installation

# Install stable version from CRAN:
install.packages("stagedtrees")

# Or the development version from GitHub:
remotes::install_github("stagedtrees/stagedtrees")

Usage

With the stagedtrees package it is possible to estimate (stratified) staged event trees from data, use them to compute probabilities, make predictions, visualize and compare different models.

library("stagedtrees")

tree <- Titanic |> full() |> stages_bhc() |> stndnaming(uniq = TRUE)

prob(tree, c(Survived="Yes"), conditional_on = c(Age="Adult"))
#> [1] 0.3107124

palette("Okabe-Ito")
par(mfrow = c(1,2))
plot(tree, col = "stages")
barplot(tree, var = "Survived", main = "P(Survived|-)", col = "stages")

Copy Link

Version

Install

install.packages('stagedtrees')

Monthly Downloads

176

Version

2.3.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Gherardo Varando

Last Published

February 14th, 2024

Functions in stagedtrees (2.3.0)

generate_xor_dataset

Generate a xor dataset
igraph-conversion

igraph conversion
get_stage

Get stage or path
join_stages

Join stages
join_positions

join positions in a staged tree model
noisy_xor

noisy xor function
generate_linear_dataset

Generate a random binary dataset for classification
generate_random_dataset

Generate a random binary dataset
join_unobserved

Join situations with no observations
logLik.sevt

Log-Likelihood of a staged event tree
path_probability

Compute probability of a path from root
lr_test

Likelihood Ratio Test for staged trees models
make_ctables

Distribute counts along tree
predict.sevt

Predict method for staged event tree
random_sevt

Generate a random (fitted) sevt
node

Plot a node
new_label

New label
search_best

Optimal Order Search
full_indep

Full and independent staged event tree
sample_from

Sample from a staged event tree
random_parentslist

Generate a random parentslist object (DAG)
probdist

Distances between probabilities
erase_fit

Erase the sevt fit
find_stage

Find the stage of the path
plot.ceg

igraph's plotting for CEG
plot.sevt

Plot method for staged event trees
stagedtrees

Staged event trees.
inclusions_stages

Inclusions of stages
sevt_simplify

Simplify a staged tree model
split_stage_random

Split randomly a stage
as.character.parentslist

Print a parentslist object
sevt_fit

Fit a staged event tree
sevt_varnames

Variable names
print.sevt

Print a staged event tree
rename_stage

Rename stage(s) in staged event tree
subtree

Extract subtree
stages_bhcr

Backward random hill-climbing
stages

The stages of a staged event tree
stages_bj

Backward joining of stages
stages_bhc

Backward hill-climbing
uni_idx

Unique id from named list
stndnaming

Standard renaming of stages
sevt_nvar

Number of variables
prob

Probabilities for a staged event tree
sevt_df

Number of parameters of a staged event tree
summary.sevt

Summarizing staged event trees
stages_kmeans

Learn a staged tree with k-means clustering
search_greedy

Greedy Order Search
sevt_add

Add a variable to a staged event tree
stages_simplebhc

Backward hill-climbing for simple staged trees
tree_string

Tree string
text.sevt

Add text to a staged event tree plot
tree_idx

return path index
trajectories

Hospital trajectories
sevt

Staged event tree (sevt) class
stages_csbhc

Context-specific Backward hill-climbing
stages_fbhc

Fast backward hill-climbing
which_class

Find maximum value
stages_hc

Hill-climbing
stages_hclust

Learn a staged tree with hierarchical clustering
write_tikz

Export the staged tree or CEG graph to tikz
expand_prob

Expand probabilities of a staged event tree
as_adj_matrix

Convert to an adjacency matrix
Pokemon

Pokemon Go Users
confint.sevt

Confidence intervals for staged event tree parameters
as_parentslist

Obtain the equivalent DAG as list of parents
as_bn

Convert to a bnlearn object
compare_stages

Compare two staged event tree
barplot.sevt

Bar plots of stage probabilities
cid

Context specific interventional discrepancy
as_sevt

Coerce to sevt
ci_matrices

Conditional independences matrices of stages
edge

Plot an edge
Asym

Asym dataset
distance_mat_stages

Compute the distance matrix
PhDArticles

PhD Students Publications
depsubtree

Extract dependency subtree
ceg

Chain event graph (CEG)
has_ctables

Check sevt objects
covid_patients

Trajectories of hospitalized SARS-CoV-2 patients