View source: R/subsystem_fertility.R
| fertility | R Documentation |
Creates a subsystem for add_subsystem(): whenever one of the births
transitions happens, a child is added to the population, with the
mother recorded and a state drawn from the newborn rule.
fertility(births, newborn, mothers = NULL, name = "fertility")
births |
Declared transitions that create a child: a |
newborn |
The state a child is born into: a |
mothers |
Optional condition on the state variables, e.g.
|
name |
The subsystem's name in the model and in
|
The births themselves are ordinary transitions with ordinary rates, usually a parity variable going up by one:
transition(move("parity", "0", "1", where = sex == "female"), first_birth)
fertility() only says which of those transitions create a child.
Nothing about it depends on what the states are called: there is no
reserved label for women. Whoever has a birth transition is a mother.
If you want that checked, give mothers, and every birth transition
must start in a state satisfying it.
At each birth the subsystem
draws the newborn's state from newborn, given the state the mother
has just moved INTO;
registers the child, born at the event's date, with motherID set
and every duration clock starting at birth;
schedules the child's first event.
The result's pop then carries a motherID column.
A subsystem, for add_subsystem().
After a run, result$extensions[[name]] holds
n_birthsthe number of children born during the run;
birthsone row per birth: motherID, childID, date
(yyyymmdd), motherAge (years, two decimals), transition (the
mother's birth transition, "from -> to") and childState (the
state the child was born into);
by_transitionbirths per birth transition, a named integer vector that lists transitions without births as zero;
by_child_statebirths per state of the newborn.
After a parallel run the identifiers are those of pop.
add_subsystem(), newborn_rule(), moves_of()
fertility(
births = moves_of("parity"),
newborn = newborn_rule(sex = c(male = 0.515, female = 0.485),
parity = "0"),
mothers = sex == "female"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.