| Title: | Simple Variables to States to Sequences to Trajectories |
|---|---|
| Description: | A small, pipe-friendly implementation of the VaSSTra workflow for longitudinal multivariate data. It provides explicit steps to turn variables into states, states into aligned sequences, and sequences into trajectory groups, followed by tidy trajectory descriptions. A single call runs the complete analysis with transparent, overridable automation of data roles and cluster counts, and an evaluation verb compares the fitted clustering against its alternatives. 'Nestimate' provides the default sequence-clustering backend and all sequence plots. No 'TraMineR' dependency is required. |
| Authors: | Mohammed Saqr [aut, cre, cph], Sonsoles López-Pernas [aut] |
| Maintainer: | Mohammed Saqr <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.0 |
| Built: | 2026-10-12 16:39:18 UTC |
| Source: | https://github.com/sonsoleslp/vasstra |
Convert a VaSSTra Analysis to a Tidy Table
## S3 method for class 'vasstra' as.data.frame( x, row.names = NULL, optional = FALSE, ..., unit = c("subject", "observation", "state_profile", "trajectory") )## S3 method for class 'vasstra' as.data.frame( x, row.names = NULL, optional = FALSE, ..., unit = c("subject", "observation", "state_profile", "trajectory") )
x |
A |
row.names, optional
|
Passed to |
... |
Additional arguments passed to |
unit |
Analysis unit to return: one row per |
A data frame at the requested analysis unit.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) head(as.data.frame(fit)) as.data.frame(fit, unit = "trajectory")data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) head(as.data.frame(fit)) as.data.frame(fit, unit = "trajectory")
Analysis-ready data from the VaSSTra chapter. The object preserves the
chapter's eight raw state indicators and adds _z versions standardized
within course_id. It also carries VaSSTra role metadata, so id, time,
variables, standardization, and indicator missingness do not need to be
repeated in common package calls.
engagementengagement
A data frame with 1,136 observations and 19 variables:
Pseudonymous student identifier.
Pseudonymous course identifier used for standardization.
Course position from 1 through 8.
Raw course-view frequency.
Raw forum-consumption frequency.
Raw forum-contribution frequency.
Raw lecture-view frequency.
Raw course-view regularity.
Raw session count.
Raw total activity duration.
Raw number of active days.
The eight indicators standardized within
course_id using the sample standard deviation. Three singleton
courses create 24 intentional missing values; VaSSTra's attached
metadata requests within-time median imputation.
Learning Analytics Methods, Chapter 11 and the lamethods data repository.
data(engagement) str(engagement) states <- step1_states(engagement, n_states = 3)data(engagement) str(engagement) states <- step1_states(engagement, n_states = 3)
Compares the fitted number of states or trajectories against the alternative counts for the same clustering method and reports per-cluster quality. The result contains one tidy candidate row per compared count, with the fitted and recommended solutions marked, and one tidy row per fitted cluster with its size and mean silhouette width.
evaluate(x, ...) ## S3 method for class 'vasstra_states' evaluate(x, n_states = NULL, ...) ## S3 method for class 'vasstra_trajectories' evaluate(x, n_trajectories = NULL, ...) ## S3 method for class 'vasstra' evaluate(x, ...)evaluate(x, ...) ## S3 method for class 'vasstra_states' evaluate(x, n_states = NULL, ...) ## S3 method for class 'vasstra_trajectories' evaluate(x, n_trajectories = NULL, ...) ## S3 method for class 'vasstra' evaluate(x, ...)
x |
A |
... |
Method-specific arguments. |
n_states |
Candidate state counts to compare. Defaults to the stored automatic comparison when one exists, otherwise 2 through 6. |
n_trajectories |
Candidate trajectory counts to compare. Defaults to the stored automatic comparison when one exists, otherwise 2 through 6. |
A vasstra_evaluation object (or a vasstra_evaluations pair for
a complete fit). as.data.frame() returns the candidate comparison;
summary() returns the per-cluster quality table.
set.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states(data, n_states = 3) evaluate(states)set.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states(data, n_states = 3) evaluate(states)
Returns the fit statistics of the selected clustering as one tidy row,
or one row per compared candidate with compare = TRUE. LPA solutions
report the complete information-criterion family (log-likelihood, AIC,
BIC, SABIC, CAIC, AWE, CLC, KIC, ICL — all on the conventional
lower-is-better scale), normalized entropy, and the smallest and largest
average posterior class probabilities. Hard clustering methods report
their own objectives (total within-cluster sum of squares, PAM
objective). Silhouette and group sizes are always included, and columns
that do not apply to the fitted method are dropped.
fit_indices(x, ...) ## S3 method for class 'vasstra_states' fit_indices(x, compare = FALSE, n_states = NULL, ...) ## S3 method for class 'vasstra_trajectories' fit_indices(x, compare = FALSE, n_trajectories = NULL, ...) ## S3 method for class 'vasstra' fit_indices(x, step = c("states", "trajectories"), compare = FALSE, ...)fit_indices(x, ...) ## S3 method for class 'vasstra_states' fit_indices(x, compare = FALSE, n_states = NULL, ...) ## S3 method for class 'vasstra_trajectories' fit_indices(x, compare = FALSE, n_trajectories = NULL, ...) ## S3 method for class 'vasstra' fit_indices(x, step = c("states", "trajectories"), compare = FALSE, ...)
x |
A |
... |
Method-specific arguments. |
compare |
Return one row per compared candidate instead of only the fitted solution. |
n_states |
Candidate state counts used when |
n_trajectories |
Candidate trajectory counts used when
|
step |
Which clustering of a complete fit to summarize:
|
A vasstra_fit_indices data frame: one row for the fitted
solution, or one row per candidate (with best and fitted markers)
when compare = TRUE.
set.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states(data, n_states = 3) fit_indices(states) fit_indices(states, compare = TRUE)set.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states(data, n_states = 3) fit_indices(states) fit_indices(states, compare = TRUE)
Fits a candidate from state_choices(), selected by candidate_id, by
any combination of n_states, method, and lpa_model, or — when
nothing is specified — the recommended candidate.
fit_state_choice( choices, candidate_id = NULL, labels = NULL, state = "state", n_states = NULL, method = NULL, lpa_model = NULL )fit_state_choice( choices, candidate_id = NULL, labels = NULL, state = "state", n_states = NULL, method = NULL, lpa_model = NULL )
choices |
A |
candidate_id |
Optional explicit candidate number to fit. |
labels |
Optional state labels ordered from low to high profile. |
state |
Name of the state column created in the returned data. |
n_states |
Optional state count used to select the candidate. |
method |
Optional clustering method used to select the candidate. |
lpa_model |
Optional LPA covariance model used to select the candidate. |
A vasstra_states object from step1_states() with the selected
candidate and complete comparison table recorded in diagnostics.
data <- expand.grid(student = 1:12, course = 1:3) group <- rep(rep(1:3, each = 4), times = 3) data$views <- group * 5 + data$course * 0.01 data$duration <- group * 10 - data$course * 0.01 choices <- state_choices( data, "student", "course", c("views", "duration"), n_states = 2:3, method = "kmeans" ) fit_state_choice(choices) # the recommended candidate fit_state_choice(choices, n_states = 3)data <- expand.grid(student = 1:12, course = 1:3) group <- rep(rep(1:3, each = 4), times = 3) data$views <- group * 5 + data$course * 0.01 data$duration <- group * 10 - data$course * 0.01 choices <- state_choices( data, "student", "course", c("views", "duration"), n_states = 2:3, method = "kmeans" ) fit_state_choice(choices) # the recommended candidate fit_state_choice(choices, n_states = 3)
Fits a candidate from trajectory_choices(), selected by
candidate_id, by any combination of n_trajectories,
dissimilarity, and method, or — when nothing is specified — the
recommended candidate.
fit_trajectory_choice( choices, candidate_id = NULL, labels = NULL, n_trajectories = NULL, dissimilarity = NULL, method = NULL )fit_trajectory_choice( choices, candidate_id = NULL, labels = NULL, n_trajectories = NULL, dissimilarity = NULL, method = NULL )
choices |
A |
candidate_id |
Optional explicit candidate number to fit. |
labels |
Optional trajectory labels. |
n_trajectories |
Optional trajectory count used to select the candidate. |
dissimilarity |
Optional sequence distance used to select the candidate. |
method |
Optional clustering method used to select the candidate. |
A vasstra_trajectories object with the selected candidate and
complete comparison table recorded in diagnostics.
sequences <- step2_sequences( data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = rep(c("A", "A", "A", "B", "B", "B"), each = 3) ), "id", "time", "state" ) choices <- trajectory_choices( sequences, n_trajectories = 2, dissimilarity = "hamming", method = "pam" ) fit_trajectory_choice(choices)sequences <- step2_sequences( data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = rep(c("A", "A", "A", "B", "B", "B"), each = 3) ), "id", "time", "state" ) choices <- trajectory_choices( sequences, n_trajectories = 2, dissimilarity = "hamming", method = "pam" ) fit_trajectory_choice(choices)
Draws how subjects move between states from one time point to the next,
using cograph::plot_alluvial() for aggregated bands and
cograph::plot_trajectories() for individually tracked lines. Sequence
index, distribution, and heatmap views remain with plot() and
Nestimate; flow_plot() answers the complementary question of where
movement goes, which a sequence plot ordered by similarity cannot show.
flow_plot(x, ...) ## S3 method for class 'vasstra_sequences' flow_plot( x, type = c("alluvial", "individual"), colors = NULL, main = NULL, color_by = NULL, bundle = "auto", bundle_max = 50, ... ) ## S3 method for class 'vasstra_trajectories' flow_plot( x, type = c("alluvial", "individual"), colors = NULL, main = NULL, color_by = NULL, bundle = "auto", bundle_max = 50, group = NULL, ... ) ## S3 method for class 'vasstra' flow_plot(x, ...)flow_plot(x, ...) ## S3 method for class 'vasstra_sequences' flow_plot( x, type = c("alluvial", "individual"), colors = NULL, main = NULL, color_by = NULL, bundle = "auto", bundle_max = 50, ... ) ## S3 method for class 'vasstra_trajectories' flow_plot( x, type = c("alluvial", "individual"), colors = NULL, main = NULL, color_by = NULL, bundle = "auto", bundle_max = 50, group = NULL, ... ) ## S3 method for class 'vasstra' flow_plot(x, ...)
x |
A |
... |
Additional arguments passed to |
type |
|
colors |
Optional colors, one per state, in state order. Defaults to the shared VaSSTra palette. |
main |
Optional plot title. A type-specific title is used by default. |
color_by |
State that gives a flow its color: |
bundle |
Line bundling for |
bundle_max |
Largest number of lines drawn before |
group |
Optional trajectory label. Restricts the plot to the subjects of one trajectory, which is how a single group's movement is inspected; flow plots draw one panel and cannot be faceted. |
State colors, state order, and time labels are taken from the fitted object, so a flow plot is directly comparable with the sequence heatmap and the state profiles.
A ggplot object. Unlike the base-graphics plot() methods,
which draw immediately and return their tidy data invisibly, this is
returned visibly so that it prints at the console.
plot.vasstra_sequences() for the Nestimate sequence views.
if (requireNamespace("cograph", quietly = TRUE)) { data("engagement", package = "VaSSTra") fit <- vasstra( engagement, state_labels = c("Disengaged", "Average", "Active") ) flow_plot(fit) flow_plot(fit, type = "individual") flow_plot(fit, group = "Trajectory 1") }if (requireNamespace("cograph", quietly = TRUE)) { data("engagement", package = "VaSSTra") fit <- vasstra( engagement, state_labels = c("Disengaged", "Average", "Active") ) flow_plot(fit) flow_plot(fit, type = "individual") flow_plot(fit, group = "Trajectory 1") }
Opens a Shiny application that runs the complete VaSSTra workflow
interactively: load data, map the subject, time, and indicator roles,
fit states and trajectories with automated or explicit counts, inspect
evaluation panels and tidy fit indices, rename groups, and export every
tidy table. The app requires the suggested shiny and DT packages.
launch_app(...)launch_app(...)
... |
Passed to |
Called for its side effect of running the app.
if (interactive()) { launch_app() }if (interactive()) { launch_app() }
Plot a Complete VaSSTra Analysis
## S3 method for class 'vasstra' plot(x, which = c("trajectories", "states", "sequences"), ...)## S3 method for class 'vasstra' plot(x, which = c("trajectories", "states", "sequences"), ...)
x |
A |
which |
One of |
... |
Passed to the selected step's plot method. Sequence and
trajectory plots are rendered by Nestimate. For the trajectory step,
|
The selected plot method's invisible result.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(fit) plot(fit, which = "states", type = "profile") plot(fit, which = "sequences") if (requireNamespace("cograph", quietly = TRUE)) { plot(fit, type = c("transition", "index", "distribution")) }data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(fit) plot(fit, which = "states", type = "profile") plot(fit, which = "sequences") if (requireNamespace("cograph", quietly = TRUE)) { plot(fit, type = c("transition", "index", "distribution")) }
Draws the selection curve, per-cluster silhouette widths, and cluster
sizes for one evaluate() result. The default "summary" layout places
the three panels side by side.
## S3 method for class 'vasstra_evaluation' plot( x, type = c("summary", "curve", "silhouette", "sizes"), colors = NULL, main = NULL, ... )## S3 method for class 'vasstra_evaluation' plot( x, type = c("summary", "curve", "silhouette", "sizes"), colors = NULL, main = NULL, ... )
x |
A |
type |
One of |
colors |
Optional colors, one per fitted cluster. The selection curve uses the first color. |
main |
Optional plot title. A panel-specific title is used by default. |
... |
Additional graphical arguments passed to the panel functions. |
The tidy data drawn by the requested panel, invisibly. The
"summary" layout returns both the candidate and cluster tables.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) evaluation <- evaluate(fit$trajectories) plot(evaluation) plot(evaluation, type = "silhouette")data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) evaluation <- evaluate(fit$trajectories) plot(evaluation) plot(evaluation, type = "silhouette")
Draws one row of evaluation panels per clustering step: the state clustering on top and the trajectory clustering below.
## S3 method for class 'vasstra_evaluations' plot(x, colors = NULL, ...)## S3 method for class 'vasstra_evaluations' plot(x, colors = NULL, ...)
x |
A |
colors |
Optional colors recycled within each evaluation row. By
default the state row reuses the palette pinned on the fit
( |
... |
Additional graphical arguments passed to the panel functions. |
The evaluated candidate and cluster tables, invisibly.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(evaluate(fit))data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(evaluate(fit))
Delegates sequence index, distribution, and heatmap rendering to
Nestimate::sequence_plot().
## S3 method for class 'vasstra_sequences' plot( x, type = c("heatmap", "distribution", "index"), colors = NULL, main = NULL, sort = "lcs", na = x$diagnostics$n_missing > 0L, ... )## S3 method for class 'vasstra_sequences' plot( x, type = c("heatmap", "distribution", "index"), colors = NULL, main = NULL, sort = "lcs", na = x$diagnostics$n_missing > 0L, ... )
x |
A |
type |
One of |
colors |
Optional colors, one per state, passed to Nestimate as
|
main |
Plot title. A type-specific title is used by default. |
sort |
Sequence ordering passed to |
na |
Show missing cells as a separate distribution band. By default,
this is |
... |
Additional arguments passed to |
The value returned by Nestimate::sequence_plot().
flow_plot() for alluvial and individual flow views.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(fit$sequences) plot(fit$sequences, type = "distribution")data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(fit$sequences) plot(fit$sequences, type = "distribution")
Draws a compact model-selection plot from state_choices(). Each line is
one clustering method (and LPA covariance model). A ring marks the optimal
eligible value of the plotted metric within each group; hollow points mark
candidates that fail the requested size constraints.
## S3 method for class 'vasstra_state_choices' plot( x, metric = c("silhouette", "bic", "aic", "classification_entropy", "mean_uncertainty", "min_size", "size_ratio", "bic_native", "icl_native"), colors = NULL, main = NULL, groups = NULL, show_legend = TRUE, ... )## S3 method for class 'vasstra_state_choices' plot( x, metric = c("silhouette", "bic", "aic", "classification_entropy", "mean_uncertainty", "min_size", "size_ratio", "bic_native", "icl_native"), colors = NULL, main = NULL, groups = NULL, show_legend = TRUE, ... )
x |
A |
metric |
Candidate metric to plot. |
colors |
Optional colors, one per displayed method/model. |
main |
Optional plot title. |
groups |
Optional character vector of method/model labels to display,
such as |
show_legend |
Show the group and marker legends. |
... |
Additional arguments passed to |
The tidy candidate data used in the plot, invisibly.
data("engagement", package = "VaSSTra") options <- state_choices(engagement, n_states = 2:4, method = "kmeans") plot(options) plot(options, metric = "silhouette")data("engagement", package = "VaSSTra") options <- state_choices(engagement, n_states = 2:4, method = "kmeans") plot(options) plot(options, metric = "silhouette")
Plot Estimated VaSSTra States
## S3 method for class 'vasstra_states' plot( x, colors = NULL, main = NULL, ..., type = c("profile", "heatmap", "bars", "sizes", "variables", "all"), scale = c("standardized", "original"), by_time = TRUE )## S3 method for class 'vasstra_states' plot( x, colors = NULL, main = NULL, ..., type = c("profile", "heatmap", "bars", "sizes", "variables", "all"), scale = c("standardized", "original"), by_time = TRUE )
x |
A |
colors |
Optional colors, one per state. Used by profile, bar, and size plots; heatmaps use a value-based sequential or diverging palette. |
main |
Optional plot title. A type-specific title is used by default. |
... |
Additional graphical arguments passed to |
type |
One of |
scale |
Show state profiles on the |
by_time |
Used only by |
For profile, bar, heatmap, and overview plots, the plotted
indicator-by-state matrix, invisibly. For a size plot, a tidy
state-size data frame. For type = "variables", a tidy
time-by-variable-by-state table of medians, invisibly.
data("engagement", package = "VaSSTra") states <- step1_states(engagement, n_states = 3) plot(states) plot(states, type = "sizes") plot(states, type = "variables") plot(states, type = "variables", by_time = FALSE) plot(states, type = "all")data("engagement", package = "VaSSTra") states <- step1_states(engagement, n_states = 3) plot(states) plot(states, type = "sizes") plot(states, type = "variables") plot(states, type = "variables", by_time = FALSE) plot(states, type = "all")
Delegates grouped sequence index, distribution, and heatmap rendering to
Nestimate::sequence_plot() and per-trajectory transition networks to
transition_plot().
## S3 method for class 'vasstra_trajectories' plot( x, type = c("index", "distribution", "heatmap", "transition"), colors = NULL, main = NULL, sort = "start", na = x$source$diagnostics$n_missing > 0L, ... )## S3 method for class 'vasstra_trajectories' plot( x, type = c("index", "distribution", "heatmap", "transition"), colors = NULL, main = NULL, sort = "start", na = x$source$diagnostics$n_missing > 0L, ... )
x |
A |
type |
One or more of |
colors |
Optional colors, one per state, passed to Nestimate as
|
main |
Plot title for the single faceted view. Ignored by the grid, where each row is titled with its trajectory label. |
sort |
Sequence ordering passed to |
na |
Show missing cells as a separate distribution band. By default,
this is |
... |
Additional arguments passed to the sequence panels
( |
A single view (the default) is drawn as one faceted figure with a panel
per trajectory. Passing several views, or the "transition" network,
instead lays out a grid with one row per trajectory and one column per
requested view (in the order given), which reproduces the familiar
per-cluster VaSSTra figure of a transition network beside its sequence
index and state-distribution plots. A single shared legend is drawn along
the bottom; pass legend = "none" (or legend = FALSE) to omit it.
For a single view, the value returned by
Nestimate::sequence_plot(). For the grid, NULL invisibly.
flow_plot() for alluvial and individual flow views,
transition_plot() for a single transition network.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(fit$trajectories) plot(fit$trajectories, type = "distribution") if (requireNamespace("cograph", quietly = TRUE)) { # One row per trajectory; columns are the requested views. plot(fit$trajectories, type = c("transition", "index", "distribution")) }data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) plot(fit$trajectories) plot(fit$trajectories, type = "distribution") if (requireNamespace("cograph", quietly = TRUE)) { # One row per trajectory; columns are the requested views. plot(fit$trajectories, type = c("transition", "index", "distribution")) }
Draws a compact Nestimate model-selection plot from
trajectory_choices(). Each line is one distance-method combination.
A ring marks the optimal eligible value of the plotted metric within each
group; hollow points mark candidates that fail the requested size
constraints.
## S3 method for class 'vasstra_trajectory_choices' plot( x, metric = c("silhouette", "mean_within_distance", "min_size", "size_ratio"), colors = NULL, main = NULL, groups = NULL, show_legend = TRUE, ... )## S3 method for class 'vasstra_trajectory_choices' plot( x, metric = c("silhouette", "mean_within_distance", "min_size", "size_ratio"), colors = NULL, main = NULL, groups = NULL, show_legend = TRUE, ... )
x |
A |
metric |
One of |
colors |
Optional colors, one per displayed distance-method pair. |
main |
Optional plot title. |
groups |
Optional character vector of distance-method labels to
display, such as |
show_legend |
Show the group and marker legends. |
... |
Additional arguments passed to |
The tidy candidate data used in the plot, invisibly.
data("engagement", package = "VaSSTra") sequences <- step2_sequences(step1_states(engagement, n_states = 3)) options <- trajectory_choices(sequences, n_trajectories = 2:4) plot(options)data("engagement", package = "VaSSTra") sequences <- step2_sequences(step1_states(engagement, n_states = 3)) options <- trajectory_choices(sequences, n_trajectories = 2:4) plot(options)
Renames the groups of an already-fitted object and propagates the new
labels through every derived table. Supply either a complete label
vector ordered from the first to the last group, or named renames such
as c("State 1" = "Disengaged") to change only some labels.
set_labels(x, ...) ## S3 method for class 'vasstra_states' set_labels(x, labels, ...) ## S3 method for class 'vasstra_trajectories' set_labels(x, labels, ...) ## S3 method for class 'vasstra' set_labels(x, states = NULL, trajectories = NULL, ...)set_labels(x, ...) ## S3 method for class 'vasstra_states' set_labels(x, labels, ...) ## S3 method for class 'vasstra_trajectories' set_labels(x, labels, ...) ## S3 method for class 'vasstra' set_labels(x, states = NULL, trajectories = NULL, ...)
x |
A |
... |
Method-specific arguments. |
labels |
New labels: a complete vector or named partial renames. |
states |
New state labels for a complete fit (complete vector or named renames). The rename is propagated in place through the fitted states, sequences, trajectories, and description — including the recorded positive and negative states — without changing any fitted value. |
trajectories |
New trajectory labels for a complete fit. |
The relabeled object, with the same class as x.
set.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states(data, n_states = 3) states <- set_labels(states, c("Low", "Average", "High")) summary(states)set.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states(data, n_states = 3) states <- set_labels(states, c("Low", "Average", "High")) summary(states)
Fits a tidy grid of state solutions. No solution is silently selected.
Hard-clustering recommendations maximize silhouette within each method;
LPA recommendations use the explicit lpa_criterion, subject to the
requested size constraints. Use fit_state_choice() with a candidate_id
after inspecting the table.
state_choices( data, id = NULL, time = NULL, variables = NULL, n_states = 2:6, method = c("lpa", "kmeans", "pam", "ward.D2"), lpa_model = "EEI", lpa_criterion = c("bic", "aic", "silhouette", "icl_native"), standardize = NULL, missing = NULL, time_levels = NULL, n_start = 25L, seed = 123L, minimum_size = 2L, minimum_proportion = 0, maximum_size_ratio = Inf )state_choices( data, id = NULL, time = NULL, variables = NULL, n_states = 2:6, method = c("lpa", "kmeans", "pam", "ward.D2"), lpa_model = "EEI", lpa_criterion = c("bic", "aic", "silhouette", "icl_native"), standardize = NULL, missing = NULL, time_levels = NULL, n_start = 25L, seed = 123L, minimum_size = 2L, minimum_proportion = 0, maximum_size_ratio = Inf )
data |
A data frame with one row per subject and time point. |
id |
Name of the subject identifier column. May be omitted when the data carry VaSSTra role metadata. |
time |
Name of the time or ordering column. May be omitted when the data carry VaSSTra role metadata. |
variables |
Character vector naming numeric state indicators. May be omitted when the data carry VaSSTra role metadata. |
n_states |
Whole-number candidate state counts. |
method |
State-clustering methods to compare. See |
lpa_model |
Optional mclust covariance models evaluated when
|
lpa_criterion |
Criterion used only to mark LPA recommendations:
conventional |
standardize, missing, time_levels, n_start, seed
|
Passed to
|
minimum_size |
Minimum acceptable number of observations in every state. |
minimum_proportion |
Minimum acceptable proportion in every state. |
maximum_size_ratio |
Maximum acceptable largest-to-smallest state-size ratio. |
A vasstra_state_choices object. as.data.frame() returns one
tidy row per candidate; $recommendations contains one transparent
recommendation per method and LPA model.
data <- expand.grid(student = 1:12, course = 1:3) group <- rep(rep(1:3, each = 4), times = 3) data$views <- group * 5 + data$course * 0.01 data$duration <- group * 10 - data$course * 0.01 choices <- state_choices( data, id = "student", time = "course", variables = c("views", "duration"), n_states = 2:4, method = c("kmeans", "pam") ) choices states <- fit_state_choice( choices, candidate_id = choices$recommendations$candidate_id[[1L]] )data <- expand.grid(student = 1:12, course = 1:3) group <- rep(rep(1:3, each = 4), times = 3) data$views <- group * 5 + data$course * 0.01 data$duration <- group * 10 - data$course * 0.01 choices <- state_choices( data, id = "student", time = "course", variables = c("views", "duration"), n_states = 2:4, method = c("kmeans", "pam") ) choices states <- fit_state_choice( choices, candidate_id = choices$recommendations$candidate_id[[1L]] )
Summarises each clustering indicator within each state, the numeric
companion to plot(x, which = "states", type = "variables"). By default the
indicators are pooled over time; by_time = TRUE reports one block per time
point.
state_descriptives(x, ...) ## S3 method for class 'vasstra_states' state_descriptives( x, scale = c("standardized", "original"), by_time = FALSE, ... ) ## S3 method for class 'vasstra' state_descriptives(x, ...)state_descriptives(x, ...) ## S3 method for class 'vasstra_states' state_descriptives( x, scale = c("standardized", "original"), by_time = FALSE, ... ) ## S3 method for class 'vasstra' state_descriptives(x, ...)
x |
A |
... |
Not used. |
scale |
Indicator scale: |
by_time |
Break the summary down per time point ( |
A tidy data frame with one row per state and indicator (and time
point when by_time = TRUE): the grouping columns followed by n,
mean, sd, median, min, and max. States are ordered by the fit's
state order and indicators by their clustering order.
plot.vasstra_states() with type = "variables" for the matching
boxplots.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3) state_descriptives(fit) state_descriptives(fit, scale = "original") state_descriptives(fit, by_time = TRUE)data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3) state_descriptives(fit) state_descriptives(fit, scale = "original") state_descriptives(fit, by_time = TRUE)
Standardizes numeric indicators and clusters each subject-time observation.
The default method is Gaussian-mixture latent profile analysis (LPA);
reproducible k-means, PAM, and hierarchical clustering are available
through method. Clusters are ordered by their average standardized
indicator level, then optionally given user-supplied labels.
step1_states( data, id = NULL, time = NULL, variables = NULL, n_states = "auto", labels = NULL, state_order = NULL, state_colors = NULL, state = "state", standardize = NULL, missing = NULL, time_levels = NULL, n_start = 25L, seed = 123L, method = c("lpa", "kmeans", "pam", "clara", "fanny", "diana", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), lpa_model = "EEI" )step1_states( data, id = NULL, time = NULL, variables = NULL, n_states = "auto", labels = NULL, state_order = NULL, state_colors = NULL, state = "state", standardize = NULL, missing = NULL, time_levels = NULL, n_start = 25L, seed = 123L, method = c("lpa", "kmeans", "pam", "clara", "fanny", "diana", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), lpa_model = "EEI" )
data |
A data frame with one row per subject and time point. |
id |
Name of the subject identifier column. May be omitted when the data carry VaSSTra role metadata. |
time |
Name of the time or ordering column. May be omitted when the data carry VaSSTra role metadata. |
variables |
Character vector naming numeric state indicators. May be omitted when the data carry VaSSTra role metadata. |
n_states |
Number of states to estimate. One number fits exactly
that count, several numbers (for example |
labels |
Optional unique labels, ordered from the lowest to the highest average standardized profile. |
state_order |
Optional character vector giving the order the states should appear in every plot. It must list the same labels rearranged; the state column is stored as a factor in this order. Defaults to the profile (discovery) order. |
state_colors |
Optional state palette stored on the result and reused by every plot. A named vector (matched by state) or one colour per state in state order. |
state |
Name of the state column created in the returned data. |
standardize |
How to z-score the indicators before clustering:
|
missing |
One of |
time_levels |
Explicit chronological time values. Required for character or unordered-factor time columns. |
n_start |
Number of random k-means starts. |
seed |
Reproducible random seed. |
method |
State-clustering method. Choose |
lpa_model |
Covariance model used only by |
A vasstra_states object. Its data element is the original data
with a factor state column; profiles is a tidy state-by-indicator table.
set.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states( data, id = "student", time = "course", variables = c("views", "duration"), labels = c("Low", "Average", "High") ) statesset.seed(1) data <- expand.grid(student = 1:12, course = 1:3) level <- rep(c(2, 8, 16), length.out = nrow(data)) data$views <- level + rnorm(nrow(data), sd = 0.4) data$duration <- level * 3 + rnorm(nrow(data), sd = 0.4) states <- step1_states( data, id = "student", time = "course", variables = c("views", "duration"), labels = c("Low", "Average", "High") ) states
Aligns every subject on the same observed time axis and returns wide sequences plus tidy long data, state distributions, and transitions.
step2_sequences( data, id = NULL, time = NULL, state = NULL, state_order = NULL, state_colors = NULL, time_levels = NULL, missing = c("error", "explicit", "keep"), missing_label = "Missing" )step2_sequences( data, id = NULL, time = NULL, state = NULL, state_order = NULL, state_colors = NULL, time_levels = NULL, missing = c("error", "explicit", "keep"), missing_label = "Missing" )
data |
A |
id |
Subject identifier column. Inferred from |
time |
Time or ordering column. Inferred from |
state |
State column. Inferred from |
state_order |
Optional character vector giving the order the states should appear in every plot. It must list exactly the observed states, rearranged. Defaults to the state factor's levels, or alphabetical order for a character state column. |
state_colors |
Optional state palette stored on the result and reused
by every plot. A named vector (matched by state) or one colour per state
in state order. Inherited from a |
time_levels |
Explicit chronological values. Required for character or
unordered-factor time when |
missing |
Structural-gap policy: |
missing_label |
Label used when |
A vasstra_sequences object with data (wide state sequences),
long_data, meta_data, distribution, and transitions.
states <- data.frame( student = rep(1:3, each = 3), course = rep(1:3, 3), engagement = c("Low", "Average", "High", "Average", "Average", "High", "Low", "Low", "Average") ) sequences <- step2_sequences( states, id = "student", time = "course", state = "engagement" ) sequencesstates <- data.frame( student = rep(1:3, each = 3), course = rep(1:3, 3), engagement = c("Low", "Average", "High", "Average", "Average", "High", "Low", "Low", "Average") ) sequences <- step2_sequences( states, id = "student", time = "course", state = "engagement" ) sequences
Clusters aligned state sequences with Nestimate sequence distances and
clustering methods. The default Hamming plus PAM combination follows the
Nestimate and Carm sequence-clustering interface. Set
dissimilarity = "lcs" and method = "ward.D2" to follow the worked
VaSSTra chapter.
step3_trajectories( data, n_trajectories = "auto", dissimilarity = c("hamming", "osa", "lv", "dl", "lcs", "qgram", "cosine", "jaccard", "jw"), method = c("pam", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), backend = c("Nestimate", "base"), labels = NULL, seed = 123L )step3_trajectories( data, n_trajectories = "auto", dissimilarity = c("hamming", "osa", "lv", "dl", "lcs", "qgram", "cosine", "jaccard", "jw"), method = c("pam", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), backend = c("Nestimate", "base"), labels = NULL, seed = 123L )
data |
A |
n_trajectories |
Number of trajectory groups. One number fits
exactly that count, several numbers (for example |
dissimilarity |
One of |
method |
One of |
backend |
|
labels |
Optional unique trajectory labels. |
seed |
Reproducible random seed passed to the clustering backend. |
A vasstra_trajectories object with tidy membership, cluster
sizes, silhouette, and the complete distance matrix.
sequences <- step2_sequences( data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = c( "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "A", "C", "C", "C", "C", "C", "B" ) ), id = "id", time = "time", state = "state" ) trajectories <- step3_trajectories(sequences, n_trajectories = 3) trajectoriessequences <- step2_sequences( data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = c( "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "A", "C", "C", "C", "C", "C", "B" ) ), id = "id", time = "time", state = "state" ) trajectories <- step3_trajectories(sequences, n_trajectories = 3) trajectories
Produces tidy per-subject sequence indices and trajectory-level state, distribution, and transition summaries. Entropy is normalized Shannon entropy. Complexity is the geometric mean of entropy and transition rate, matching the common sequence complexity formulation. Integrative potential and negative exposure are time-weighted state proportions.
step4_describe(data, positive_states = NULL, negative_states = NULL, omega = 1)step4_describe(data, positive_states = NULL, negative_states = NULL, omega = 1)
data |
A |
positive_states |
Optional states considered positive. |
negative_states |
Optional states considered negative. |
omega |
Positive exponent controlling how strongly later time points are weighted for integrative potential and negative exposure. |
A vasstra_description object with tidy indices,
trajectory_summary, mean_time, distribution, and transitions.
long <- data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = c( "Low", "Low", "Low", "Low", "Low", "Average", "Average", "Average", "Average", "Average", "Average", "Low", "High", "High", "High", "High", "High", "Average" ) ) trajectories <- long |> step2_sequences(id = "id", time = "time", state = "state") |> step3_trajectories(n_trajectories = 3) description <- step4_describe( trajectories, positive_states = "High", negative_states = "Low" ) descriptionlong <- data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = c( "Low", "Low", "Low", "Low", "Low", "Average", "Average", "Average", "Average", "Average", "Average", "Low", "High", "High", "High", "High", "High", "Average" ) ) trajectories <- long |> step2_sequences(id = "id", time = "time", state = "state") |> step3_trajectories(n_trajectories = 3) description <- step4_describe( trajectories, positive_states = "High", negative_states = "Low" ) description
Uses Nestimate::cluster_choice() to compare a tidy grid of sequence
distances, clustering methods, and trajectory counts. Recommendations are
made within each distance-method pair; no distance or algorithm is silently
chosen for the user.
trajectory_choices( data, n_trajectories = 2:6, dissimilarity = c("hamming", "lcs"), method = c("pam", "ward.D2"), seed = 123L, minimum_size = 2L, minimum_proportion = 0, maximum_size_ratio = Inf )trajectory_choices( data, n_trajectories = 2:6, dissimilarity = c("hamming", "lcs"), method = c("pam", "ward.D2"), seed = 123L, minimum_size = 2L, minimum_proportion = 0, maximum_size_ratio = Inf )
data |
A |
n_trajectories |
Whole-number candidate trajectory counts. |
dissimilarity |
Sequence distances to compare. |
method |
Clustering methods to compare. |
seed |
Reproducible seed passed to Nestimate. |
minimum_size |
Minimum acceptable number of sequences in every group. |
minimum_proportion |
Minimum acceptable proportion in every group. |
maximum_size_ratio |
Maximum acceptable largest-to-smallest group-size ratio. |
A vasstra_trajectory_choices object with one tidy candidate row
per Nestimate fit and transparent recommendations within method-distance
combinations.
sequences <- step2_sequences( data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = rep(c("A", "A", "A", "B", "B", "B"), each = 3) ), "id", "time", "state" ) choices <- trajectory_choices( sequences, n_trajectories = 2:3, dissimilarity = "hamming", method = c("pam", "ward.D2") ) choicessequences <- step2_sequences( data.frame( id = rep(1:6, each = 3), time = rep(1:3, 6), state = rep(c("A", "A", "A", "B", "B", "B"), each = 3) ), "id", "time", "state" ) choices <- trajectory_choices( sequences, n_trajectories = 2:3, dissimilarity = "hamming", method = c("pam", "ward.D2") ) choices
Tidy centralities of the state transition network, one row per state.
The network is built by Nestimate::build_tna() and the measures come
from Nestimate::net_centrality(), so they match tna::centralities().
transition_centrality(x, ...) ## S3 method for class 'vasstra_sequences' transition_centrality( x, measures = c("InStrength", "OutStrength"), weights = c("probability", "count"), loops = FALSE, ... ) ## S3 method for class 'vasstra_trajectories' transition_centrality( x, measures = c("InStrength", "OutStrength"), weights = c("probability", "count"), loops = FALSE, group = NULL, ... ) ## S3 method for class 'vasstra' transition_centrality(x, ...)transition_centrality(x, ...) ## S3 method for class 'vasstra_sequences' transition_centrality( x, measures = c("InStrength", "OutStrength"), weights = c("probability", "count"), loops = FALSE, ... ) ## S3 method for class 'vasstra_trajectories' transition_centrality( x, measures = c("InStrength", "OutStrength"), weights = c("probability", "count"), loops = FALSE, group = NULL, ... ) ## S3 method for class 'vasstra' transition_centrality(x, ...)
x |
A |
... |
Not used. |
measures |
Centrality measures to compute, passed to
|
weights |
|
loops |
Include self-transitions in the computation. Default
|
group |
Optional trajectory label restricting the network to one trajectory's subjects. |
In-strength is the total incoming transition weight, so the state with
the largest in-strength is the one the cohort most often moves into.
Self-transitions are excluded by default: with loops = TRUE a
persistent state scores highly merely because its members stay put,
which is a different claim from attracting movement.
A tidy data frame with one row per state and one column per requested measure.
transition_plot() to draw the network.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) transition_centrality(fit) transition_centrality(fit, weights = "count")data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) transition_centrality(fit) transition_centrality(fit, weights = "count")
Draws states as nodes and transitions as directed edges, with node size
encoding a centrality of the transition network. The network comes from
Nestimate::build_tna() and the centralities from
Nestimate::net_centrality(); cograph::splot() draws it, recognising
the Nestimate object and applying TNA styling, node labels, and
initial-probability donuts automatically.
transition_plot(x, ...) ## S3 method for class 'vasstra_sequences' transition_plot( x, size = "InStrength", weights = c("probability", "count"), loops = FALSE, size_range = c(8, 18), sequences = FALSE, colors = NULL, main = NULL, ... ) ## S3 method for class 'vasstra_trajectories' transition_plot( x, size = "InStrength", weights = c("probability", "count"), loops = FALSE, size_range = c(8, 18), sequences = FALSE, colors = NULL, main = NULL, group = NULL, ... ) ## S3 method for class 'vasstra' transition_plot(x, ...)transition_plot(x, ...) ## S3 method for class 'vasstra_sequences' transition_plot( x, size = "InStrength", weights = c("probability", "count"), loops = FALSE, size_range = c(8, 18), sequences = FALSE, colors = NULL, main = NULL, ... ) ## S3 method for class 'vasstra_trajectories' transition_plot( x, size = "InStrength", weights = c("probability", "count"), loops = FALSE, size_range = c(8, 18), sequences = FALSE, colors = NULL, main = NULL, group = NULL, ... ) ## S3 method for class 'vasstra' transition_plot(x, ...)
x |
A |
... |
Additional arguments passed to |
size |
Centrality measure that sets node size, or |
weights |
|
loops |
Include self-transitions in the computation. Default
|
size_range |
Smallest and largest node size. The measure is mapped onto this range anchored at zero, so a state with half the in-strength of the largest draws halfway up the range and sizes stay comparable between plots. |
sequences |
Draw the state sequences beside the network, the
conventional pairing in which the sequences show the raw data and the
network summarises its movement. |
colors |
Optional colors, one per state, in state order. Defaults to the shared VaSSTra palette, so the network matches the sequence and state plots. Colors are matched to states by name, so a trajectory that never reaches a state still colours the rest correctly. |
main |
Optional plot title. |
group |
Optional trajectory label restricting the network to one trajectory's subjects. |
Where flow_plot() shows movement resolved over time,
transition_plot() collapses every time step into one network and asks
which states attract movement overall.
A tidy data frame of the plotted centrality and node size, one row per state, invisibly.
transition_centrality() for the numbers without a plot, and
flow_plot() for time-resolved movement.
if (requireNamespace("cograph", quietly = TRUE)) { data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) transition_plot(fit) transition_plot(fit, weights = "count", size = "OutStrength") transition_plot(fit, sequences = TRUE) }if (requireNamespace("cograph", quietly = TRUE)) { data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) transition_plot(fit) transition_plot(fit, weights = "count", size = "OutStrength") transition_plot(fit, sequences = TRUE) }
The transition counts behind the flow and network views, as a tidy data
frame. By default every consecutive move is aggregated over time (the
numbers transition_plot() draws); by_time = TRUE instead returns one
block per consecutive time pair, matching the alluvial flow_plot().
transition_table(x, ...) ## S3 method for class 'vasstra_sequences' transition_table(x, by_time = FALSE, ...) ## S3 method for class 'vasstra_trajectories' transition_table(x, by_time = FALSE, group = NULL, ...) ## S3 method for class 'vasstra' transition_table(x, ...)transition_table(x, ...) ## S3 method for class 'vasstra_sequences' transition_table(x, by_time = FALSE, ...) ## S3 method for class 'vasstra_trajectories' transition_table(x, by_time = FALSE, group = NULL, ...) ## S3 method for class 'vasstra' transition_table(x, ...)
x |
A |
... |
Not used. |
by_time |
Return per-time-step transitions ( |
group |
Optional trajectory label restricting the table to one trajectory's subjects. |
A tidy data frame. Aggregated: from, to, count, and
probability (row-normalized within from). With by_time = TRUE,
also from_time and to_time, with probability normalized within
each (from_time, from).
transition_plot() and flow_plot() to draw these movements,
transition_centrality() for network centralities.
data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) transition_table(fit) transition_table(fit, by_time = TRUE)data("engagement", package = "VaSSTra") fit <- vasstra(engagement, n_states = 3, n_trajectories = 3) transition_table(fit) transition_table(fit, by_time = TRUE)
A one-call wrapper around step1_states(), step2_sequences(),
step3_trajectories(), and step4_describe(). Every argument has a
working default, so vasstra(data) runs a complete analysis: subject,
time, and indicator roles come from explicit arguments, attached role
metadata, or common column names, and the numbers of states and
trajectories are selected automatically unless given. Every automated
decision is reported with a message and recorded in the fit.
vasstra( data, id = NULL, time = NULL, variables = NULL, state = NULL, n_states = "auto", n_trajectories = "auto", state_labels = NULL, state_order = NULL, state_colors = NULL, trajectory_labels = NULL, state_name = "state", standardize = NULL, indicator_missing = NULL, sequence_missing = c("error", "explicit", "keep"), missing_label = "Missing", time_levels = NULL, dissimilarity = c("hamming", "osa", "lv", "dl", "lcs", "qgram", "cosine", "jaccard", "jw"), cluster_method = c("pam", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), backend = c("Nestimate", "base"), positive_states = NULL, negative_states = NULL, omega = 1, n_start = 25L, seed = 123L, state_method = c("lpa", "kmeans", "pam", "clara", "fanny", "diana", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), lpa_model = "EEI" )vasstra( data, id = NULL, time = NULL, variables = NULL, state = NULL, n_states = "auto", n_trajectories = "auto", state_labels = NULL, state_order = NULL, state_colors = NULL, trajectory_labels = NULL, state_name = "state", standardize = NULL, indicator_missing = NULL, sequence_missing = c("error", "explicit", "keep"), missing_label = "Missing", time_levels = NULL, dissimilarity = c("hamming", "osa", "lv", "dl", "lcs", "qgram", "cosine", "jaccard", "jw"), cluster_method = c("pam", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), backend = c("Nestimate", "base"), positive_states = NULL, negative_states = NULL, omega = 1, n_start = 25L, seed = 123L, state_method = c("lpa", "kmeans", "pam", "clara", "fanny", "diana", "ward.D2", "ward.D", "complete", "average", "single", "mcquitty", "median", "centroid"), lpa_model = "EEI" )
data |
A longitudinal data frame. |
id |
Subject identifier column. May be omitted when the data carry VaSSTra role metadata or use a common identifier name. |
time |
Time or ordering column. May be omitted when the data carry VaSSTra role metadata or use a common time name. |
variables |
Numeric state indicators. Use either |
state |
Existing state column. Use either |
n_states |
Number of states when |
n_trajectories |
Number of trajectory groups: one number, a
candidate vector to compare, or |
state_labels |
Optional labels ordered from low to high profile. |
state_order |
Optional character vector giving the order the states
should appear in every plot (stacking, legends, transition nodes, flow
nodes). It must list exactly the same states as |
state_colors |
Optional state palette stored on the fit and reused by
every plot without repeating |
trajectory_labels |
Optional labels for stable trajectory groups. |
state_name |
Output column name when states are estimated. |
standardize |
State-indicator standardization: |
indicator_missing |
Indicator missingness policy passed to step 1. Analysis-ready package data may provide its own default. |
sequence_missing |
Structural sequence-gap policy passed to step 2. |
missing_label |
Explicit missing-state label. |
time_levels |
Explicit chronological values when needed. |
dissimilarity |
Sequence distance passed to |
cluster_method |
Trajectory clustering method. |
backend |
Clustering backend: |
positive_states |
Optional states considered positive. |
negative_states |
Optional states considered negative. |
omega |
Later-time weighting exponent for step 4. |
n_start |
Number of k-means starts. |
seed |
Reproducible base seed. |
state_method |
State-clustering method passed to |
lpa_model |
mclust covariance model used when
|
A vasstra object containing all four fitted step objects.
set.seed(1) data <- expand.grid(student = 1:15, course = 1:4) latent <- ceiling(data$student / 5) data$views <- latent * 5 + rnorm(nrow(data), sd = 0.4) data$duration <- latent * 10 + rnorm(nrow(data), sd = 0.4) # Fully automated: roles are detected and the counts are selected. fit <- vasstra(data) fit # Labels imply the counts; other choices named explicitly. fit <- vasstra( data, state_labels = c("Low", "Average", "High"), positive_states = "High", negative_states = "Low" ) fitset.seed(1) data <- expand.grid(student = 1:15, course = 1:4) latent <- ceiling(data$student / 5) data$views <- latent * 5 + rnorm(nrow(data), sd = 0.4) data$duration <- latent * 10 + rnorm(nrow(data), sd = 0.4) # Fully automated: roles are detected and the counts are selected. fit <- vasstra(data) fit # Labels imply the counts; other choices named explicitly. fit <- vasstra( data, state_labels = c("Low", "Average", "High"), positive_states = "High", negative_states = "Low" ) fit