| as_long | R Documentation |
as_long() gives one row per episode, which is the layout event-history and
survival analysis expect. as_wide() gives one row per individual.
as_long(x, ...)
## S3 method for class 'micsim_result'
as_long(x, migr = !is.null(x$model$immigrants), ...)
as_wide(x, ...)
## S3 method for class 'micsim_result'
as_wide(x, ...)
x |
A |
... |
Passed to methods. |
migr |
Whether immigrants' first episodes begin on their arrival date.
Defaults to |
Neither needs arguments. The result already carries the model, and the model knows the state space, the horizon, the absorbing states and the immigrants, which is everything these two converters need.
Both take the result as their first argument, so they can be put in
a pipe easily: simulate(model, seed = 234) |> as_long().
A data frame.
as_long() gives one row per episode, with the columns ID,
birthDate, Tstart, Tstop, statusEntry, statusExit, OD,
ns, Episode, and one column per state variable (a state such as
"f/DE/1" is split into columns for sex, nationality and parity).
Dates use yyyymmdd format. statusEntry is 1 if the start of the
episode was observed and 0 if it was left truncated; statusExit is 1
if its end was observed and 0 if it was right censored. OD says how
the episode ended: the name of an absorbing state such as "dead",
"cens" if it was still running when observation ended, or the
values that changed, such as "0->1". ns is the number of episodes
of the individual, and Episode numbers them in order.
as_wide() gives one row per individual, with the columns ID,
birthDate, initState, ns (the number of transitions, 0 for
someone who never moved) and numbered groups From.1, To.1,
transitionTime.1, transitionAge.1, From.2, and so on. motherID
is not included; join it from as.data.frame(result) by ID if you
need it.
simulate.micsim_model(), MicSim-concepts
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.