entities {epiworldR} | R Documentation |
Entities in epiworld
are objects that can contain agents.
get_entities(model)
## S3 method for class 'epiworld_entities'
x[i]
entity(name, prevalence, as_proportion, to_unassigned = TRUE)
get_entity_size(entity)
get_entity_name(entity)
entity_add_agent(entity, agent, model = attr(entity, "model"))
rm_entity(model, id)
add_entity(model, entity)
load_agents_entities_ties(model, agents_id, entities_id)
entity_get_agents(entity)
distribute_entity_randomly(prevalence, as_proportion, to_unassigned = TRUE)
distribute_entity_to_set(agents_ids)
set_distribution_entity(entity, distfun)
model |
Model object of class |
x |
Object of class |
i |
Integer index. |
name |
Character scalar. Name of the entity. |
prevalence |
Numeric scalar. Prevalence of the entity. |
as_proportion |
Logical scalar. If |
to_unassigned |
Logical scalar. If |
entity |
Entity object of class |
agent |
Agent object of class |
id |
Integer scalar. Entity id to remove (starting from zero). |
agents_id |
Integer vector. |
entities_id |
Integer vector. |
agents_ids |
Integer vector. Ids of the agents to distribute. |
distfun |
Distribution function object of class |
Epiworld entities are especially useful for mixing models, particularly ModelSIRMixing and ModelSEIRMixing.
The function entity
creates an entity object.
The function get_entity_size
returns the number of agents in the entity.
The function get_entity_name
returns the name of the entity.
The function entity_add_agent
adds an agent to the entity.
The function rm_entity
removes an entity from the model.
The function load_agents_entities_ties
loads agents into entities.
The function entity_get_agents
returns an integer vector with the agents
in the entity (ids).
# Creating a mixing model
mymodel <- ModelSIRMixing(
name = "My model",
n = 10000,
prevalence = .001,
contact_rate = 10,
transmission_rate = .1,
recovery_rate = 1/7,
contact_matrix = matrix(c(.9, .1, .1, .9), 2, 2)
)
ent1 <- entity("First", 5000, FALSE)
ent2 <- entity("Second", 5000, FALSE)
mymodel |>
add_entity(ent1) |>
add_entity(ent2)
run(mymodel, ndays = 100, seed = 1912)
summary(mymodel)