Learn R Programming

epiworldR (version 0.8.2.0)

entities: Get entities

Description

Entities in epiworld are objects that can contain agents.

Usage

get_entities(model)

# S3 method for 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)

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).

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.

Details

Epiworld entities are especially useful for mixing models, particularly ModelSIRMixing and ModelSEIRMixing.

Examples

Run this code
# 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)

Run the code above in your browser using DataLab