project_beds: Project bed occupancy from admissions

Description Usage Arguments Value Examples

View source: R/project_beds.R

Description

This function projects bed occupancy using admission incidence and a distribution of length of stay (los).

Usage

1
2
3
4
5
6
7
project_beds(x, ...)

## S3 method for class 'projections'
project_beds(x, r_los, n_sim = 10, last_date = NULL, ...)

## S3 method for class 'incidence'
project_beds(x, r_los, n_sim = 10, last_date = NULL, ...)

Arguments

x

Either a projections object storing one or more integer forecasts of admissions or a incidence object of known daily admissions.

...

Additional arguments passed to other methods.

r_los

A function with a single parameter n returning n integer values of lenth of hospital stay (LoS) in days. Ideally, this should come from a discrete random distribution, such as rexp or any distcrete object.

n_sim

The number of times duration of hospitalisation is simulated for each admission. Defaults to 10. Only relevant for low (<30) numbers of initial admissions, in which case it helps accounting for the uncertainty in LoS.

last_date

the last date to simulate until (defaults to the maximum date of x).

Value

A projections object produced from the admission trajectories.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  ## fake LoS; check \code{\link[distcrete:distcrete]{distcrete::distcrete}}
  ## for discretising existing distributions
  r_los <- function(n) rgeom(n, prob = .3)


  # Incidence input

  ## fake data
  dates <- Sys.Date() - 1:10
  admissions <- sample(1:100, 10, replace = TRUE)
  x <- incidence::incidence(rep(dates, admissions))
  x
  plot(x)

  ## project bed occupancy
  beds <- project_beds(x, r_los)
  beds
  plot(beds)


  # Projections input

  ## make fake data - each column after the first is a separate forecast
  admissions <- data.frame(
      date = Sys.Date() - 1:10,
      as.data.frame(replicate(30, sample(1:100, 10, replace = TRUE))))

  x <- build_projections(x = admissions[, -1], dates = admissions$date)
  x
  plot(x)

  ## project bed occupancy
  beds <- project_beds(x, r_los)
  beds
  plot(beds)

tjtnew/bedoc documentation built on April 27, 2020, 3:39 a.m.