 # Is there a CHIME mode for COVID-19 by R-Studio?

There is a Mode for "COVID-19 Hospital Impact Model for Epidemics (CHIME)", here is the link for it:
https://penn-chime.phl.io/

The code for this model can be found here:

But, it is python code and has to be run at linux environment, is there a similar model that can be run by R-Studio? Thank you!

RStudio can run `Python`!

If you decide to go that way, please post a new question on `reticulate` related matters if you run into difficulties. I've been away from `Python` for longer than I realized before thinking about it just now.

Thank you! I will try.

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

Hi, Jerry,

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. Also, in the `reprex` it's good etiquette to use

``````require(deSolve) # in place of install.packages("deSolve")
``````

The parameters are user selected arguments to the `sir_values_1` function, which self destructs with

``````sir_values_1 <- as.data.frame(sir_values_1)
``````

You probably want to do something like

``````run1 <-  as.data.frame(sir_values_1)
``````

So, to recover those

``````# require(deSolve) # in place of install.packages(deSolve)

### snip

parameters_values<- c(
beta = 0.001, # infectious contact rate (/person/day)
gamma = 0.015 # recovery rate (/day)
)

### snip

### added to show where to find beta and gamma parameters; none others used except for starting values

parameters_values
#>  beta gamma
#> 0.001 0.015
``````

Created on 2020-04-05 by the reprex package (v0.3.0)

The choice of which parameter values is domain specific. All assumptions within the permitted range of a function to be given as arguments are equally valid from a data science computational stance; whether they are equally reasonable is a matter of the analyst's judgment about the subject matter.

This community may have some epidemiologists from time-to-time, but I imagine that most of them are, sadly, too busy now to offer advice. I suggest moving the types of questions beyond the mechanics and going into the realm of subject matter expertise into more general online discussions.

Good luck! And, thanks for sharing `Chimes`! Extremely interesting.