Prune States and/or Transitions
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.
"prune"(x, count_threshold, clusters = TRUE, transitions = FALSE, copy = TRUE, compact = TRUE)rare_clusters(x, count_threshold, ...) rare_transitions(x, count_threshold, ...)
- an object of class
- all states/edges with a count of less or equal to the threshold are removed from the model.
- logical; prune clusters?
- logical; prune transitions?
- logical; make a copy of x before reclustering? Otherwise the function will change
- logical; tries make the data structure used for the temporal model more compact after pruning.
- further arguments (currently not used).
prunereturns invisibly an object of class
copy=FALSEthen it returns a reference to the changes object passed as
rare_clustersreturns a vector of names of rare clusters.
rare_transitionsreturns a data.frame of rare transitions.
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)