update.micsim_model: Checks rate values before simulating Replace the population...

View source: R/class_model.R

update.micsim_modelR Documentation

Checks rate values before simulating Replace the population of a model

Description

Returns a model with a different starting population, immigrant population, or both. All other settings are retained, and the new populations are checked exactly as micsim_model() checks them.

This allows a model developed on a sample to be applied to the full population without repeating the model specification.

Usage

## S3 method for class 'micsim_model'
update(object, population, immigrants, ...)

Arguments

object

A micsim_model.

population

A new starting population, in the format micsim_model() takes. Leave it out to keep the current one.

immigrants

A new immigrant table, or NULL for none. Leave it out to keep the current one.

...

Must be empty.

Details

Only population and immigrants can be changed with this method. To change the state space, transitions, simulation period, maximum age, exit types or subsystems, rebuild the model with micsim_model() and, where needed, add_subsystem().

Replace populations through update() so that the model is checked. Direct assignment, such as model$population <- ..., bypasses these checks and is not supported.

Value

A micsim_model.

See Also

micsim_model(), add_subsystem()

Examples

mort <- function(age, calTime) 0.0001 * exp(0.085 * age)
pop <- data.frame(ID = 1:200, birthDate = "19700101",
                  initState = rep(c("m", "f"), 100))
sample_model <- micsim_model(state_space(sex = c("m", "f")),
                             transitions(transition(NA, "dead", mort)),
                             pop[1:20, ], c(20000101, 20101231))
full_model <- update(sample_model, population = pop)
nrow(full_model$population)

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