Description Usage Arguments Value See Also Examples
Calculate the transition rates between states. If cluster_labels are provided then transition rates are calculated by cluster.
1 2 3 4 5 6 | transition_matrix(
seq_def_tidy,
period_min = min(seq_def_tidy$sequenchr_seq_id),
period_max = max(seq_def_tidy$sequenchr_seq_id),
cluster_labels = NULL
)
|
seq_def_tidy |
a tidy tibble generated from sequenchr::tidy_sequence_data |
period_min |
the minimum period to include in the transition calculation |
period_max |
the maxmium period to include in the transition calculation |
cluster_labels |
optional. A vector of cluster assignments |
a tidy tibble containing the transition rates (per cluster)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(TraMineR)
data(mvad)
seqstatl(mvad[, 17:86])
mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school",
"training")
mvad.labels <- c("employment", "further education", "higher education",
"joblessness", "school", "training")
mvad.seq <- seqdef(mvad, 17:86, alphabet = mvad.alphabet,
labels = mvad.labels, xtstep = 6)
seq_def_tidy <- tidy_sequence_data(mvad.seq)
trans_tidy <- transition_matrix(seq_def_tidy)
dist_matrix <- TraMineR::seqdist(seqdata = mvad.seq, method = "DHD")
cluster_model <- hclust(d = as.dist(dist_matrix), method = 'ward.D2')
cluster_labels <- stats::cutree(cluster_model, k = 5)
trans_tidy <- transition_matrix(seq_def_tidy, cluster_labels = cluster_labels)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.