diff --git a/README.Rmd b/README.Rmd index efd5c55..e511d26 100644 --- a/README.Rmd +++ b/README.Rmd @@ -24,6 +24,12 @@ An R package for building and simulating deterministic discrete-time compartment ## Installation +You can install `denim` from [CRAN](https://cran.r-project.org) with: + +``` r +install.packages("denim") +``` + You can install the development version of denim from [GitHub](https://github.com/) with: ``` r @@ -33,7 +39,7 @@ devtools::install_github("thinhong/denim") ## Example -This is a basic example to illustrate the specification of a simple SIR model, which contains three compartments susceptible (S), infected (I) and recovered (R). The recovery probabilities of infected individuals are gamma distributed in this example: +This is a basic example to illustrate the specification of a simple SIR epidemiological model, which contains three compartments: susceptible (S), infected (I) and recovered (R). The durations spent in the I compartment are gamma distributed and this is specified on the `I -> R` transition: ```{r example} library(denim) diff --git a/vignettes/denim.Rmd b/vignettes/denim.Rmd index 6260cbd..662ffb7 100644 --- a/vignettes/denim.Rmd +++ b/vignettes/denim.Rmd @@ -45,7 +45,7 @@ $$S_{t+1} - S_{t} = -\lambda S_{t} = -\frac{\beta I_{t}}{N}S_{t}$$ $$I_{t+1} - I - $\beta$: the product of contact rates and transmission probability; usually we define $\lambda =\frac{\beta I_{t}}{N}$ as the force of infection - $\gamma$: recovery rate -Usually to solve the model easier we make an assumption that the recovery rate $\gamma$ is constant, this will leads to an exponentially distributed length of stay i.e most individuals recover after 1 day being infected. +Usually to solve the model more easily we make an assumption that the recovery rate $\gamma$ is constant, this will leads to an exponentially distributed length of stay in the I compartment i.e. most individuals recover after 1 day being infected and a few individuals can stay in this compartment for a very long time. ```{r, echo=FALSE} @@ -57,12 +57,13 @@ y3 <- dexp(x = x, rate = rates[3]) col_codes <- c("#374F77", "#EF9F32", "#6ECBD7") plot(x, y, type = "l", col = col_codes[1], lty = 1, lwd = 3, - xlab = "Length of stay (days)", ylab = "", - ylim = c(0, 1.5), yaxt = 'n') + xlab = "Length of stay (days)", ylab = "density of probability", + ylim = c(0, 1.5)) lines(x, y2, col = col_codes[2], lty = 1, lwd = 3) lines(x, y3, col = col_codes[3], lty = 1, lwd = 3) -legend("right", legend = c(0.5, 1.0, 1.5), - col = col_codes, lty = 1, lwd = 3, bty = "\n") +legend("topright", legend = paste(c(0.5, 1.0, 1.5), "/day"), + title = expression(paste("recovery rate ", gamma)), + col = col_codes, lty = 1, lwd = 3, bty = "n") ``` A more realistic length of stay distribution can look like this, of which most patients recovered after 4 days. We defined this using a gamma distribution with shape = 3 and scale = 2. @@ -72,7 +73,7 @@ x <- seq(0, 20, 0.001) y <- dgamma(x = x, shape = 3, scale = 2) plot(x, y, type = "l", col = col_codes[1], lty = 1, lwd = 3, - xlab = "Length of stay (days)", ylab = "", yaxt = 'n') + xlab = "Length of stay (days)", ylab = "density of probability") ``` The model now look like this: @@ -219,7 +220,7 @@ For a given length of stay distribution, we identify the maximum length of stay ## 3. Waiting time distribution -Current available distribution in this package including: +The distributions currently available in this package are: - `d_exponential(rate)`: Discrete **exponential distribution** with parameter `rate` @@ -398,5 +399,5 @@ mod <- sim(transitions = transitions, parameters = parameters, simulationDuration = simulationDuration, timeStep = timeStep) -mod +head(mod) ```