This project implements a SEITR (Susceptible, Exposed, Infected, Treated, Recovered) model for network analysis using R. The model simulates the spread of a disease through a network of individuals, allowing for various network types and parameters.
To use this project, you need to have R installed on your system. You can install the required packages using the following commands:
install.packages(c("igraph", "deSolve", "ggplot2", "dplyr"))
You can install the SEITR Network Analysis package directly from GitHub using the devtools package. First, make sure you have devtools installed:
install.packages("devtools")
Then, use the install_github
function to install the package:
devtools::install_github("skaraoglu/SEITRNet")
After installing the package, you can load it using the library function:
library(SEITRNet)
The SEITR_network function performs SEITR network analysis.
-
n: (int) Number of nodes in the network.
-
network_type: (str) The type of network to create. This can be one of the following:
- ER: Erdős-Renyi random graph
- BA: Barabasi-Albert scale-free network
- WS: Watts-Strogatz small-world network
- LN: Lattice network
- RR: Random regular network
-
n_par1: (float) First network parameter. Assigned for "p" argument in Erdős-Renyi and Watts-Strogatz graphs, assigned for "k" argument for Lattice and Random regular, n * n_par1 is used as "m" for Barabási-Albert networks.
-
n_par2: (float) Second network parameter that is only needed for Watts-Strogatz networks to assign "k" argument.
-
Lambda: (float) Birth rate.
-
alpha1: (float) Treatment rate
-
alpha2: (float) Recovery rate from treatment
-
delta_I: (float) Death rate from infection
-
delta_T: (float) Death rate from treatment
-
mu: (float) Natural death rate
-
beta1: (float) The infection rate parameter.
-
beta2: (float) The exposure rate parameter.
-
beta3: (float) The recovery rate parameter.
-
initial_statuses: (int) The initial status of the nodes in the network. Where each status can be one of the following:
S: Susceptible, E: Exposed, I: Infected, T: Treatment, R: Recovered
-
t: (int) Time period.
-
num_exp: (int) The number of experiments to run.
-
verbose: (bool) Verbose output.
SEITR_network <- function(network_type="ER", n=100, n_par1=.9, n_par2=10, Lambda=1.1, beta1=.8, beta2=.18, beta3=.02, alpha1=.1, alpha2=.055, delta_I=.03, delta_T=.03, mu=.01, S=85, E=5, I=10, Tt=0, R=0, N=100, t=100, num_exp = 10, verbose = F, state = NULL, parameters = NULL) {
# Function implementation
}
The compare_experiment_sets function compares the results of multiple experiment sets. Currently inactive.
Here are some examples of how to use the functions in this project:
# Perform SEITR network analysis
ws_p.1_k20 <- SEITR_network("WS", n_par1=0.1, n_par2=20, num_exp = 3)
er_p.2 <- SEITR_network("ER", n_par1=0.2, num_exp = 3)
ba_m.75 <- SEITR_network("BA", n_par1=0.75, num_exp = 3)
# Compare the results of multiple experiment sets
compare_experiment_sets(list(ws_p.1_k20, er_p.2, ba_m.75))
Here we present the mathematical model used to analyze the disease transmission dynamics. This model is an extension of the classic Susceptible-Infectious-Recovered model.
The model is an extension of the classic Susceptible-Infectious-Recovered (SIR) model with Exposed and Recovered statuses. The model consists of a system of non-linear ordinary differential equations (ODEs) expressing the transmission dynamics:
- Susceptible (S): These are individuals who are susceptible to the disease. The rate of change of S is given by the equation:
$$\frac{dS}{dt}= \Lambda-\frac{\beta_1 SI}{N}-\eta S$$ Here,$\Lambda$ is the birth rate,$\beta_1$ is the transmission rate of the disease, I is the number of infectious individuals, N is the total population, and$\eta$ is the natural death rate. - Exposed (E): These are individuals who have been infected but are not yet infectious. The rate of change of E is given by the equation:
$$\frac{dE}{dt}= \frac{\beta_1SI}{N}-(\gamma_2+\eta) E$$ Here,$\gamma_2$ is the rate at which exposed individuals become infectious. - Infectious (I): These are individuals who are infectious. The rate of change of I is given by the equation:
$$\frac{dI}{dt}=\gamma_2 E-(\gamma_3+\eta+d_I+\kappa_1)I$$ Here,$\gamma_3$ is the recovery rate,$dI$ is the disease-induced death rate, and$\kappa_1$ is the rate at which infectious individuals are treated. - Treated (T): These are individuals who have been infected and are receiving treatment. The rate of change of T is given by the equation:
$$\frac{dT}{dt}=\kappa_1 I-(\eta+d_T+\kappa_2)T$$ Here,$dT$ is the treatment-induced death rate, and$\kappa_2$ is the rate at which treated individuals recover. - Recovered (R): These are individuals who have recovered from the disease. The rate of change of R is given by the equation:
$$\frac{dR}{dt}= \gamma_3 I+\kappa_2 T-\eta R$$
with non-negative initial conditions;
The model also includes two equilibrium points: the disease-free equilibrium and the endemic equilibrium. The disease-free equilibrium represents the state where the disease has been eradicated, while the endemic equilibrium represents the state where the disease persists in the population. The reproduction number
Disease-Free Equilibrium:
Endemic Equilibrium:
The reproduction number
The model is locally asymptotically stable (LAS) and globally asymptotically stable (GAS) at the disease-free equilibrium point
Input: Network Type ER
, n=100, n_par1=.9, n_par2=10, Lambda=1.1, beta1=.8, beta2=.18, beta3=.02, alpha1=.1, alpha2=.055, delta_I=.03, delta_T=.03, mu=.01,
S=85, E=5, I=10, Tt=0, R=0, N=100, t=100, num_exp = 10, verbose = F
Output: avgs 'Average results of the num_exp experiments"
- For each experiment in num_exp experiments:
- Create network 'g' with given parameters
- Assign statuses to nodes randomly with given parameters
- For each time step t in the simulation:
- Save the current status of each node.
- For each type of removal (Infection, Treatment, natural death):
- Calculate the number of nodes to remove
nodes_to_remove_count
- Separate
nodes_to_remove_count
into a floor valuefloor_value
and a fractional partfractional_part
- if
floor_value
> 0 then- Remove
floor_value
number of nodes
- Remove
- if
fractional_part
> 0 then- Remove an additional node with a probability equal to
fractional_part
- Remove an additional node with a probability equal to
- Calculate the number of nodes to remove
- Calculate the number of nodes to add
nodes_to_add_count
- Separate
nodes_to_add_count
into a floor valuefloor_value
and a fractional partfractional_part
- if
floor_value
> 0 then- Add
floor_value
number of nodes - Add connections to the new nodes according to Network Type
- Add
- if
fractional_part
> 0 then- Add an additional node with a probability equal to
fractional_part
- Add connections to the new nodes according to Network Type
- Add an additional node with a probability equal to
- for each node in the graph do
- Get the current status of the node.
- Generate a random number
rand
- If the node is Susceptible and
rand
<beta1
*I
/N
, change the status to Exposed - If the node is Exposed and
rand
<beta2
, change the status to Infected - If the node is Infected:
- Generate another random number
rand2
- If
rand
<beta3
, change the status to Recovered - If
rand2
<alpha1
, change the status to Treatment
- Generate another random number
- If the node is under Treatment and
rand
<alpha2
, change the status to Recovered
- Count the number of nodes in each status and store these counts in
S_count
,E_count
,I_count
,Tt_count
,R_count
,N_count
- Calculate various network metrics and store these metrics in
degree_dist
,clustering_coeff
,avg_path_length
,largest_comp_size
- Store the experiment result
- Calculate and store the averages of num_exp experiments
- Return averages
Contributions are welcome! Please feel free to submit a Pull Request or open an issue if you have any suggestions or improvements.
This project is licensed under the GPL-3 License. See the LICENSE file for details.