convertToLongFormat {MicSim} | R Documentation |
Reshaping microsimulation output into long format
Description
The function reshapes the output given by micSim or by micSimParallel into long format. In long format, the data comprises for each episode which an individual experiences one row.
Usage
convertToLongFormat(pop,migr=FALSE)
Arguments
pop |
The data frame |
migr |
A logical variable indicating whether the simulation model considers immigration. The default setting is "no immigration considered": |
Details
convertToLongFormat
uses information from the definition of the microsimulation model. In particular, it uses stateSpace
, absTransitions
, allTransitions
, simHorizon
, and optionally immigrPop
. (For a description of these objects see micSim.) stateSpace
, absTransitions
, allTransitions
, simHorizon
, and immigrPop
are globally defined, i.e., they are already part of the workspace. Thus, they do not have to be given to convertToLongFormat
as extra input parameters.
Value
A data frame comprising the microsimulation output in long format.
- ID
is the unique numerical person identifier of an individual.
- birthDate
is the birth date of an individual.
- The variables Tstart
and Tstop
mark the start und the ending dates of episodes.
- statusEntry
specifies whether the entry into an episode has been observed. Value "1" marks an observed entry and "0" marks a left truncated episode.
- statusExit
specifies whether a transition between two states or right censoring completed an episode. Value "1" indicates a transition and "0" a censoring event.
- OD
names the transition which completed an episode. Here, right censoring is marked by "cens".
- ns
gives the number of episodes an individual has passed.
- Episode
enumerates the episodes an individual has passed.
- The last columns of the data frame contain for each individual and episode the values of the state variables during that episode such as ‘sex’, ‘education’, etc.
- Birth and transition times are given as calendar dates in form of chron objects.
Author(s)
Sabine Zinn
Examples
# Run microsimulation before, e.g., the complex example described on the
# help page of the function "micSim".
## Not run:
pop <- micSim(initPop, immigrPop, transitionMatrix, absStates, initStates, initStatesProb,
maxAge, simHorizon, fertTr)
popLong <- convertToLongFormat(pop,migr=TRUE)
## End(Not run)