R/Prehos.daily.R

Defines functions Prehos.daily

Documented in Prehos.daily

#' Prediction of daily hospitalized, ICU and ventilated cases.
#' @description Prediction of daily hospitalized, ICU and ventilated cases based on SIR model.
#' @import stats

#' @param obj Input. Object from function \emph{fitSIR}.
#' @param hosrate Input. Hospitalization rate of infected people (percentage between 0 to 100).
#' @param icurate Input. ICU rate of infected people (percentage between 0 to 100).
#' @param venrate Input. Ventilated rate of infected people (percentage between 0 to 100).
#' @param hms Input. Hospital market share (percentage between 0 to 100).


#' @examples ## To predicte 100 days from today (dayFT=100).
#' @examples casevolumne <- fitSIR(susceptible=4119405, Infected=3733, inihos=14,
#' @examples      hosrate=2.5, hms=15, inidbt=4, mrt=14, sdis=30, dayFT=100)
#' @examples dailyhosp <- Prehos.daily(casevolumne, hosrate=2.5, icurate=0.75, venrate=0.5, hms=15)
#' @examples head(dailyhosp, 21) ## show the first 20 days
#'

#' @export


Prehos.daily <- function(obj, hosrate=2.5, icurate=0.75, venrate=0.5, hms=15) {

  hrate <- (hms/100) * (hosrate/100)
  irate <- (hms/100) * (icurate/100)
  vrate <- (hms/100) * (venrate/100)

  ts <- length(obj$result$susceptible)-1
  allnewinflected <- obj$result$susceptible[1] - tail(obj$result$susceptible,-1)

  ehos <- ceiling(c(0, allnewinflected * hrate))
  eicu <- ceiling(c(0, allnewinflected * irate))
  even <- ceiling(c(0, allnewinflected * vrate))

  reps <- cbind(1:ts, diff(ehos), diff(eicu), diff(even))

  reps <- rbind(c(0, 0, 0, 0), reps)

  reps[reps<0] <- 0

  colnames(reps) <- c("days.from.today","hosp","icu","vent")
  data.frame(reps)

}
cyhsuTN/COVID19 documentation built on April 3, 2020, 4:19 a.m.