epiworld-methods {epiworldR}R Documentation

Methods for epiworldR objects

Description

The functions described in this section are methods for objects of class epiworld_model. Besides of printing and plotting, other methods provide access to manipulate model parameters, getting information about the model and running the simulation.

Usage

queuing_on(x)

queuing_off(x)

verbose_off(x)

verbose_on(x)

run(model, ndays, seed = sample.int(10000, 1))

## S3 method for class 'epiworld_model'
summary(object, ...)

get_states(x)

get_param(x, pname)

set_param(x, pname, pval)

set_name(x, mname)

get_name(x)

get_n_viruses(x)

get_n_tools(x)

get_ndays(x)

get_n_replicates(x)

size(x)

set_agents_data(model, data)

get_agents_data_ncols(model)

get_virus(model, virus_pos)

get_tool(model, tool_pos)

initial_states(model, proportions)

clone_model(model)

Arguments

x

An object of class epiworld_model.

model

Model object.

ndays

Number of days (steps) of the simulation.

seed

Seed to set for initializing random number generator.

object

Object of class epiworld_model.

...

Additional arguments.

pname

String. Name of the parameter.

pval

Numeric. Value of the parameter.

mname

String. Name of the model.

data

A numeric matrix.

virus_pos

Integer. Relative location (starting from 0) of the virus in the model

tool_pos

Integer. Relative location (starting from 0) of the tool in the model

proportions

Numeric vector. Proportions in which agents will be distributed (see details).

Details

The verbose_on and verbose_off functions activate and deactivate printing progress on screen, respectively. Both functions return the model (x) invisibly.

epiworld_model objects are pointers to an underlying C++ class in epiworld. To generate a copy of a model, use clone_model, otherwise, the assignment operator will only copy the pointer.

Value

Examples


model_sirconn <- ModelSIRCONN(
name                = "COVID-19",
n                   = 10000,
prevalence          = 0.01,
contact_rate        = 5,
transmission_rate   = 0.4,
recovery_rate       = 0.95
)

# Queuing - If you wish to implement the queuing function, declare whether 
# you would like it "on" or "off", if any. 
queuing_on(model_sirconn)
queuing_off(model_sirconn)
run(model_sirconn, ndays = 100, seed = 1912)

# Verbose - "on" prints the progress bar on the screen while "off" 
# deactivates the progress bar. Declare which function you want to implement, 
# if any. 
verbose_on(model_sirconn)
verbose_off(model_sirconn)
run(model_sirconn, ndays = 100, seed = 1912)

get_states(model_sirconn) # Returns all unique states found within the model.

get_param(model_sirconn, 'Contact rate') # Returns the value of the selected 
                                         # parameter within the model object.
                                         # In order to view the parameters, 
                                         # run the model object and find the 
                                         # "Model parameters" section. 

set_param(model_sirconn, 'Contact rate', 2) # Allows for adjustment of model 
                                            # parameters within the model 
                                            # object. In this example, the 
                                            # Contact rate parameter is 
                                            # changed to 2. You can now rerun 
                                            # the model to observe any 
                                            # differences.
                                            
set_name(model_sirconn, 'My Epi-Model') # This function allows for setting 
                                        # a name for the model. Running the 
                                        # model object, the name of the model
                                        # is now reflected next to "Name of 
                                        # the model". 
                                        
get_name(model_sirconn) # Returns the set name of the model. 

get_n_viruses(model_sirconn) # Returns the number of viruses in the model. 
                              # In this case, there is only one virus:
                              # "COVID-19". 
                              
get_n_tools(model_sirconn) # Returns the number of tools in the model. In 
                           # this case, there are zero tools.  
                           
get_ndays(model_sirconn) # Returns the length of the simulation in days. This
                         # will match "ndays" within the "run" function. 
                         
get_n_replicates(model_sirconn) # Returns the number of replicates of the 
                                # model. 
                                
size(model_sirconn) # Returns the population size in the model. In this case, 
                    # there are 10,000 agents in the model. 
# Set Agents Data
# First, your data matrix must have the same number of rows as agents in the 
# model. Below is a generated matrix which will be passed into the 
# "set_agents_data" function. 
data <- matrix(data=runif(20000, min=0, max=100), nrow=10000, ncol=2)                   
set_agents_data(model_sirconn, data)
get_agents_data_ncols(model_sirconn) # Returns number of columns 

get_virus(model_sirconn, 0) # Returns information about the first virus in 
                            # the model (index begins at 0).

add_tool(model_sirconn, tool("Vaccine", .9, .9, .5, 1), proportion = .5)                            
get_tool(model_sirconn, 0) # Returns information about the first tool in the 
                           # model. In this case, there are no tools so an 
                           # error message will occur. 

[Package epiworldR version 0.1-0 Index]