prune: Prune States and/or Transitions

pruneR Documentation

Prune States and/or Transitions

Description

Simplifies an EMM and/or the clustering by removing all clusters/states and/or transitions which have a count of equal or smaller than a given threshold.

Usage

## S4 method for signature 'EMM'
prune(x, count_threshold, clusters = TRUE, transitions = FALSE,
    copy = TRUE, compact = TRUE)

rare_clusters(x, count_threshold, ...)
rare_transitions(x, count_threshold, ...)

Arguments

x

an object of class "EMM"

count_threshold

all states/edges with a count of less or equal to the threshold are removed from the model.

clusters

logical; prune clusters?

transitions

logical; prune transitions?

copy

logical; make a copy of x before reclustering? Otherwise the function will change x!

compact

logical; tries make the data structure used for the temporal model more compact after pruning.

...

further arguments (currently not used).

Value

prune returns invisibly an object of class EMM. If copy=FALSE then it returns a reference to the changes object passed as x.

rare_clusters returns a vector of names of rare clusters.

rare_transitions returns a data.frame of rare transitions.

See Also

remove_transitions, remove_clusters, compact

Examples

data("EMMTraffic")

## For the example we use a very high learning rate
emm_l <- EMM(threshold=0.2, measure="eJaccard", lambda = 1)
build(emm_l, EMMTraffic)

## show state counts and transition counts
cluster_counts(emm_l)
transition_matrix(emm_l, type="counts")

## rare state/transitions
rare_clusters(emm_l, count_threshold=0.1)
rare_transitions(emm_l, count_threshold=0.1)

## remove all states with a threshold of 0.1
emm_lr <- prune(emm_l, count_threshold=0.1)

## compare graphs
op <- par(mfrow = c(1, 2), pty = "m")
plot(emm_l, main = "EMM with high learning rate")
plot(emm_lr, main = "Simplified EMM")
par(op)


rEMM documentation built on May 29, 2024, 4:35 a.m.