| transition | R Documentation |
Describes an allowed move from one state to another and supplies the function giving its rate.
transition(from, to, rate)
from |
Origin state label(s), |
to |
Destination state label. Omitted when |
rate |
A function that returns transition rates, supplied as a
function object rather than its name. It may accept any subset of
|
Three ways to say which states:
transition("female/0", "female/1", rate)full state labels.
from may be a vector of labels.
transition(NA, "deceased", rate)NA means every transient
state, which is how mortality is normally written.
transition(move("edu", "none", "primary"), rate)one state
variable changes and everything else stays, for every state (or
those satisfying the edge's where). See move().
A destination that is not a transient state is an absorbing state: the model creates it, under whatever name you give it.
A transition, for passing to transitions().
transitions(), move(), micsim_model()
states <- state_space(
sex = c("female", "male"),
country = c("DE", "AT"),
parity = c("0", "1", "2")
)
states
# Full state labels follow the order of the variables in `states`.
# A constant rate is used for all moves between countries.
# This move from Germany to Austria applies to women with no children.
move_to_at <- function() 0.02
transition(from = "female/DE/0", to = "female/AT/0", rate = move_to_at)
# A move from Austria to Germany applies to everyone living in Austria.
# Only the country changes. All other state variables remain constant.
move_to_de <- function() 0.03
transition(move("country", from = "AT", to = "DE"), rate = move_to_de)
# Two origin states share the same emigration rate, and emigration is
# an absorbing state, as "abroad" is not in the state space.
emigration_rate <- function() 0.01
transition(from = c("female/DE/0", "male/DE/0"),
to = "abroad", rate = emigration_rate)
# First and second births change parity for women in either country.
first_birth <- function(age) ifelse(age >= 18 & age < 45, 0.10, 0)
second_birth <- function(age) ifelse(age >= 18 & age < 45, 0.08, 0)
transition(move("parity", from = "0", to = "1", where = sex == "female"),
rate = first_birth)
transition(move("parity", from = "1", to = "2", where = sex == "female"),
rate = second_birth)
# Mortality applies in every transient state.
mortality <- function(age) 0.00003 * exp(0.1 * age)
transition(from = NA, to = "deceased", rate = mortality)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.