move: Select the transitions that change one state variable

View source: R/selectors.R

moveR Documentation

Select the transitions that change one state variable

Description

move() describes a change from one value of a state variable to another, keeping every other variable fixed. Use it in transition() to declare transitions, or in a subsystem to select which transitions it acts on, as in school_enrolment(move("edu", "none", "primary")).

moves_of() selects declared transitions in which var is the only state variable that changes. Subsystems use it to identify relevant transitions, for example fertility(births = moves_of("parity")). It does not declare new transitions.

Usage

move(var, from, to, where = NULL)

moves_of(var, where = NULL)

Arguments

var

Name of the state variable that changes, as a string.

from, to

Its origin and destination values, as different strings.

where

Optional condition on the origin state, written in terms of the state variables, e.g. sex == "female" & nat == "DE".

Details

Suppose the state variables are sex = c("male", "female") and edu = c("none", "primary"). Then move("edu", "none", "primary") describes both "male/none" -> "male/primary" and "female/none" -> "female/primary".

where restricts the origin states. For example, move("parity", "0", "1", where = sex == "female") selects that parity change only for female origin states. The condition is evaluated against the model's table of transient states when the selector is resolved.

Value

A selector object. move() can be used in transition() or by a subsystem; moves_of() can only select declared transitions.

See Also

transition(), add_subsystem(), MicSim-concepts

Examples

# Entry into primary education, regardless of other state variables.
move("edu", from = "none", to = "primary")

# The change from parity 0 to 1 applies only to female origin states.
move("parity", from = "0", to = "1", where = sex == "female")

# Treat all declared changes in parity alone as births.
fertility(
  births = moves_of("parity"),
  newborn = newborn_rule(sex = c(female = 0.5, male = 0.5),
                         parity = "0")
)


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