stages_kmeans: Learn a staged tree with k-means clustering

View source: R/4-model-selection.R

stages_kmeansR Documentation

Learn a staged tree with k-means clustering

Description

Build a stage event tree with k stages for each variable by clustering (transformed) probabilities with k-means.

Usage

stages_kmeans(
  object,
  k = length(object$tree[[1]]),
  algorithm = "Hartigan-Wong",
  transform = sqrt,
  ignore = object$name_unobserved,
  limit = length(object$tree),
  scope = NULL,
  nstart = 1
)

Arguments

object

an object of class sevt with fitted probabilities and data, as returned by full or sevt_fit.

k

integer or (named) vector: number of clusters, that is stages per variable. Values will be recycled if needed.

algorithm

character: as in kmeans.

transform

function applied to the probabilities before clustering.

ignore

vector of stages which will be ignored and left untouched, by default the name of the unobserved stages stored in object$name_unobserved.

limit

the maximum number of variables to consider.

scope

names of the variables to consider.

nstart

as in kmeans

Details

kmenas_sevt performs k-means clustering to aggregate the stage probabilities of the initial staged tree object. Different values for k can be specified by supplying a (named) vector to k. kmeans from the stats package is used internally and arguments algorithm and nstart refer to the same arguments as kmeans.

Value

A staged event tree.

Examples

data("Titanic")
model <- stages_kmeans(full(Titanic, join_unobserved = TRUE, lambda = 1), k = 2)
summary(model)

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