MicSim-concepts: Concepts and notation used throughout MicSim

MicSim-conceptsR Documentation

Concepts and notation used throughout MicSim

Description

A glossary of the terms and symbols that appear in MicSim's documentation and source code.

State space

state variable (substate)

A categorical attribute used to describe an individual in the model, with a set of possible values. For example, an education variable might take the values "none", "primary" and "secondary". Another variable might record the number of children ever born, also called parity. A state variable need not change during a person's simulated life course.

composite state

The combination of one value from each state variable, describing an individual's current situation. With variables for sex, nationality and parity, "f/DE/1" could describe a German woman with one child. MicSim joins the values with "/", in the order the variables were supplied.

transient state

A state that can be left again.

absorbing state

A state from which the model allows no further transitions. Death is a common example; leaving the study population permanently is another. In micsim_model(), a transition destination outside the transient state space is treated as absorbing. Its label need not be "dead".

role

A condition on the state variables, such as sex == "female", by which a model or a subsystem says what a state means. No label has a built-in meaning; see move().

subsystem

An additional rule for events that ordinary transitions alone cannot describe. A birth changes the mother's state but also adds a child to the population: fertility() supplies that extra action. school_enrolment() adjusts event dates to follow a specified school-enrolment calendar. Use add_subsystem() to add these rules to a model.

Random numbers

random number stream

Each individual has their own random-number stream, derived from the run's seed and the individual's ID; a newborn's stream comes from the mother's. Each time an individual's next event is scheduled, one uniform is drawn for every possible destination, also for destinations whose rate is zero or infinite.

common random numbers

A consequence of the random number streams is that results do not depend on the number of cores or on who else is simulated, and two scenarios simulated with the same seed use the same random numbers for every individual whose rates do not differ (common random numbers).

Rates and waiting times

transition rate, hazard rate, transition intensity

A measure of how quickly a particular transition can occur, written \lambda(t). In MicSim, rates are expressed per year. A rate is not a probability and can exceed one.

integrated hazard (cumulative hazard)

The rate accumulated over a period of time. If the rate stays at 2 per year for half a year, the integrated hazard is 2 * 0.5 = 1. When the rate changes over time, the calculation accounts for those changes. For example, a rate of 0.2 per year for one year, followed by 0.4 per year for another, gives an integrated hazard of 0.6.

This accumulated risk is written as \Lambda(\tau) = \int_0^{\tau} \lambda(s)\,\mathrm{d}s, where \tau is the interval's length in years. It represents the individual's total exposure to the risk of this particular transition over that interval.

waiting time (sojourn time)

How long the individual stays in the current state before a transition occurs.

inverse-transform sampling

A method for turning a random draw into a waiting time that follows the supplied rate. For an ordinary finite rate, MicSim draws a positive random threshold, then calculates when the integrated hazard reaches it. That time is the candidate waiting time. For example, with a constant rate of 2 per year and a threshold of 1, the candidate is half a year away. If the threshold is not reached within the remaining observation period, there is no candidate event in that period.

The threshold, written u, is drawn from an exponential distribution with mean one. The calculation finds \tau such that \Lambda(\tau) = u. Each draw generally gives a different threshold and hence a different waiting time.

forced transition

A transition whose rate is Inf at some point, encoding an event that happens on a known date rather than at random. Elementary-school enrolment is a common example.

Competing risks

Several transitions may be possible from the same state. For example, someone who is a former smoker might resume smoking or die. These possibilities compete because whichever happens first ends the current stay in that state.

MicSim draws a candidate waiting time for each possible destination, as if that transition were the only one possible. If the draw places relapse two years away and death five years away, MicSim schedules relapse. After relapse, it draws new candidates from the person's new state, including a new candidate for death if that transition is allowed. A school-calendar rule adjusts the relevant candidates before the earliest is selected.

The random draws for the different candidates are independent. This is part of the sampling method; it does not claim that real-world causes are unrelated.

Time scales

A transition rate can use three ways of measuring time:

age

Time since the individual's birth.

calendar time

When something happens in the study period, such as 2020 rather than 2010. A rate using calTime can therefore represent changes over historical time, such as falling mortality.

duration

Time since the last change of the state variable that the transition would change. If quitting moves someone from "current_smoker" to "former_smoker" during the simulation, a relapse rate can use duration to measure time since quitting.

All three advance together as time passes. Someone aged 35 who quit two years earlier in the simulation will be 36 with three years since quitting after another year of abstinence. Calendar time also advances by one year. If they resume smoking and later quit again, the new abstinent spell starts with duration zero. Until the first simulated change in a state variable, MicSim measures its duration from birth.

Observation scheme

episode

One uninterrupted stay in a state during observation, recorded with a start and an end date. A person who starts childless, has a first child and then remains in the one-child state until observation ends has two episodes.

left truncation

We know the individual was in a state at the start of observation but not when they entered it. Every member of the starting population is left-truncated.

right censoring

Observation ends before the state is left. Everyone still alive at the end of the simulation horizon is right-censored.

occurrence-exposure rate

The number of relevant events divided by the total time individuals were able to experience them. That time is called exposure or person-time at risk. For a first-birth rate, for example, count first births and sum the observed time spent in the eligible childless states.

Ten events during 200 person-years give 10 / 200 = 0.05 events per person-year. One person observed for two years contributes two person-years, as do two people observed for one year each. This estimates a rate, not the proportion of individuals with an event. It can be compared with the supplied rate when sufficient events and exposure are available. Sampling variation and how rates change within the estimation intervals affect this comparison.

Simulation machinery

discrete-event simulation

A simulation that processes events in time order instead of updating everyone at fixed time steps. If the next scheduled event is on 5 March, the engine advances directly to it rather than processing each intervening day. Individuals remain in their current states between events, although their ages and transition rates can change.

event queue

The list of events already scheduled but not yet processed. Each entry identifies a person, a destination state and an event time. The queue lets the engine find the next event across the whole population. A person has at most one active pending event, chosen from their competing candidates.

global clock

The date of the soonest pending event. It only ever moves forward.

Notation

Symbol Meaning Name in the code
\lambda(x) transition rate x years from now lambda
\Lambda(\tau) rate accumulated over tau years integrated_hazard
u standard-exponential draw u
\tau waiting time, in years tau_years
E number of events in a run -
N number of individuals -

Units in variable names

Many internal names end with a suffix that helps identify the value:

⁠_days⁠

Days since 1970-01-01 for dates, or elapsed days for ages and durations. Values may include fractions of a day.

⁠_years⁠

Time in fractional years, using 365.25 days per year.

⁠_ymd⁠

A date written as year, month and day without separators, for example 20201103 for 3 November 2020.

⁠_idx⁠

A state's number in the internal mapping between labels and numbers.

⁠_slot⁠

A person's row number in the internal person store.

⁠_id⁠

A person identifier used in the inputs or output, such as ID or motherID. It need not equal their row number in the store.


MicSim documentation built on Dec. 2, 2026, 1:09 a.m.