Transitions of a sequence network, one row per transition
Source:R/transition_regression.R
transition_data.RdTurns a transition network into a table with one row per observed
transition: the state it leaves, the state it enters, the covariates of its
sequence and its position. This is the table transition_regression()
fits, and it is returned so the data the model sees can be inspected.
Arguments
- net
A network built from sequences: a
netobjectof counts (build_ftna()) or row proportions (build_tna()), anetobject_group(build_network(group = ),cluster_network()) or anet_clustering(build_clusters()). A group or cluster becomes a covariate column named after the grouping (attr(net, "group_col"), e.g."cluster").- covariate_data
Optional data frame of covariates kept outside the network, such as one row per student, joined to the transitions by
by.- by
Character. The key column(s) shared by the network's metadata and
covariate_data. Each key must appear once incovariate_data.- session_progress
Optional
c(session = , within = ), two column names. Addssession_progress: the position of a session among the sessions of itswithinunit, divided by their number. Sessions are ordered by the number that ends their id.
Value
A data frame with one row per transition: sequence, position
(1 = first transition of the sequence), from, to (factors over the
network's states), the network's metadata, the columns of
covariate_data, progress (position divided by the number of
transitions of the sequence) and session_progress when requested.
Details
The network's weights must be the counts or the row proportions of
its adjacent transitions; any other weighting (attention, co-occurrence,
windows, start or end states) raises an error of class
nestimate_not_transition_counts. A key in by without a row in
covariate_data gives missing covariates and a message; duplicated keys
(nestimate_duplicate_key), missing or absent key columns
(nestimate_bad_key) and covariate columns already in the metadata
(nestimate_column_clash) are errors. Several grouping columns are
restored by splitting the group names on "-"; a value that contains
"-" raises nestimate_ambiguous_group.
Examples
net <- build_ftna(group_regulation_long, action = "Action", actor = "Actor",
time = "Time")
head(transition_data(net))
#> sequence position from to Actor Achiever Group Course progress
#> 1 1 1 cohesion consensus 1 High 1 A 0.1428571
#> 2 1 2 consensus discuss 1 High 1 A 0.2857143
#> 3 1 3 discuss synthesis 1 High 1 A 0.4285714
#> 4 1 4 synthesis adapt 1 High 1 A 0.5714286
#> 5 1 5 adapt consensus 1 High 1 A 0.7142857
#> 6 1 6 consensus plan 1 High 1 A 0.8571429