convertToWideFormat: Reshaping microsimulation output into wide format

View source: R/convertToWide.r

convertToWideFormatR Documentation

Reshaping microsimulation output into wide format

Description

The function reshapes the output given by micSim or by micSimParallel into wide format. In wide format, the data comprises for each episode which an individual experiences additional column entries.

Usage

convertToWideFormat(pop)

Arguments

pop

The data frame pop contains the whole synthetic population considered during simulation including all events generated. For each individidual pop contains as many rows as the individual performed transitions during simulation.

Value

A data frame comprising the microsimulation output in wide format.

- ID is the unique numerical person identifier of an individual.

- birthDate is the birth date of an individual.

- initState is the state in which an individual initially entered the virtual population of the simulation.

- ns gives the number of (completed) episodes an individual has passed.

- The variables From.i and To.i mark the start und the arrival state of the transition corresponding to episode i. The variables transitionTime.i and transitionAge.i give the corresponding transition time and age. The enumerator i ranges from 1 to the maximal number of transitions which an individual experienced during simulation. Only completed episodes are counted.

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)
popWide <- convertToWideFormat(pop)

## End(Not run)


MicSim documentation built on Jan. 9, 2023, 5:05 p.m.