Entities in epiworld
are objects that can contain agents.
Usage
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)
Arguments
- model
Model object of class
epiworld_model
.- x
Object of class
epiworld_entities
.- i
Integer index.
- name
Character scalar. Name of the entity.
- prevalence
Numeric scalar. Prevalence of the entity.
- as_proportion
Logical scalar. If
TRUE
,prevalence
is interpreted as a proportion.- to_unassigned
Logical scalar. If
TRUE
, the entity is added to the unassigned pool.- entity
Entity object of class
epiworld_entity
.- agent
Agent object of class
epiworld_agent
.- 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_distribution_entity
.
Value
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).
Details
Epiworld entities are especially useful for mixing models, particularly ModelSIRMixing and ModelSEIRMixing.
Examples
# 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)
#> _________________________________________________________________________
#> Running the model...
#> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done.
#> done.
summary(mymodel)
#> ________________________________________________________________________________
#> ________________________________________________________________________________
#> SIMULATION STUDY
#>
#> Name of the model : Susceptible-Infected-Removed (SIR) with Mixing
#> Population size : 10000
#> Agents' data : (none)
#> Number of entities : 2
#> Days (duration) : 100 (of 100)
#> Number of viruses : 1
#> Last run elapsed t : 66.00ms
#> Last run speed : 14.97 million agents x day / second
#> Rewiring : off
#>
#> Global events:
#> - Update infected individuals (runs daily)
#>
#> Virus(es):
#> - My model
#>
#> Tool(s):
#> (none)
#>
#> Model parameters:
#> - Contact rate : 10.0000
#> - Prob. Recovery : 0.1429
#> - Prob. Transmission : 0.1000
#>
#> Distribution of the population at time 100:
#> - (0) Susceptible : 9990 -> 376
#> - (1) Infected : 10 -> 1
#> - (2) Recovered : 0 -> 9623
#>
#> Transition Probabilities:
#> - Susceptible 0.97 0.03 0.00
#> - Infected 0.00 0.86 0.14
#> - Recovered 0.00 0.00 1.00
#>