I created a R code below and try to create similar curve for "Susceptible, Infected, and Recovered", like the third graph here: https://penn-chime.phl.io/
But, I don't know how to determine the parameters beta, gamma and others. Can anyone help to generate those parameter based on the information provided from the website? Thank you.
install.packages(deSolve)
library(deSolve)
writing the differential equations in R
sir_equations<- function(time, variables, parameters) {
with(as.list(c(variables, parameters)), {
dS<- -beta * I * S
dI<- beta * I * S - gamma * I
dR<- gamma * I
return(list(c(dS, dI, dR)))
})
}
defining some value for the parameters
parameters_values<- c(
beta = 0.001, # infectious contact rate (/person/day)
gamma = 0.015 # recovery rate (/day)
)
initial values for the variables
initial_values<- c(
S=3599733, # number of susceptibles at time = 0
I=266, # number of infectious at time =0
R=0 # number of recovered (and immune) at time=0
)
time_values<- seq(0, 125) # days
ode() function
sir_values_1 <- ode(
y = initial_values,
times = time_values,
func = sir_equations,
parms = parameters_values
)
sir_values_1 <- as.data.frame(sir_values_1)
plot
with(sir_values_1, {
plot(time, S, type = "l", col = "blue", xlab = "time (days)", ylab = "number of people")
lines(time, I, col = "red")
lines(time, R, col = "darkgreen")
})
legend("right", c("susceptibles", "infectious", "recovered"),
col = c("blue", "red", "darkgreen"), pch = 1, bty = "n")