Sim_bio {VirtualPop} | R Documentation |
Generic Function to Generate Single Life History
Description
The function generates a single life history from age-specific transition rates (rates$ratesM) and an initial state. RatesM is an object with the rates in the proper format for multistate modelling. The user supplies the starting age and ending age of the simulation.
Usage
Sim_bio(datsim, ratesM)
Arguments
datsim |
Dataframe with, for each individual, ID, date of birth, starting and ending times (ages) of the simulation, and the state occupied at the start of the simulation (see vignette "Tutorial"). |
ratesM |
Multistate transition rates in standard (multistate) format |
Details
The function is called from the function VirtualPop::Children(). It uses the rpexp() function of the msm package.
Value
age_startSim |
Age at start of simulation |
age_endSim |
Age at end of simulation |
nstates |
Number of states |
path |
path: sequence of states occupied |
ages_trans |
Ages at transition |
Examples
# Fertily history is simulated from starting age to ending age
# Individual starts in state "par0"
utils::data(rates,package="VirtualPop")
popsim <- data.frame(ID=1,born=2000.450,start=0,end=80,st_start="par0")
ch <- VirtualPop::Sim_bio (datsim=popsim,ratesM=rates$ratesM)