View source: R/sequence_terminal.R
| mark_first_state | R Documentation |
Mirror of mark_terminal_state() for left-censored sequence data.
Replaces every cell before each row's first observed state with
the label given by state. The resulting chain has a structurally
recurrent "Start" state that everyone enters from - useful for
cohort-entry analyses where students join at different time points
and you want a uniform pre-observation marker.
mark_first_state(data, state = "Start", cols = NULL)
data |
A wide-format matrix or data.frame (rows = actors,
cols = time steps) of state labels with |
state |
Character. Label to insert in leading-NA cells.
Default |
cols |
Optional state-column names; otherwise all columns. |
Unlike mark_terminal_state(), the marked state is not
absorbing in the resulting transition matrix - every transition
from "Start" goes to one of the original states (the actor's
first observed state), and the "Start" row is row-stochastic
exactly as the data dictates.
A data.frame of the same shape as data with leading
NAs filled by state.
mark_terminal_state(), actor_endpoints()
M <- mark_first_state(trajectories, state = "Start")
# In a chain built from M, "Start" is a transient entry point.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.