envToTibble: envToTibble

View source: R/envToTibble.R

envToTibbleR Documentation

envToTibble

Description

Convert babsim simulation results to tibble data. Input: simmer simulation environment and field data formatted using getRealBeds. The formatted filed date has dim (nxm, 5), the output data has dimension (nxm, 15). The method get_mon_resources function is used to extract information from the babsim.hospital simulation. The function is used by modelResultHospital to prepare the calculation of the error.

Usage

envToTibble(envs, fieldEvents, conf, dontFilter = FALSE)

Arguments

envs

simmer simulation environment. Result from babsim.hospital simulation runs, e.g., output from babsimHospital.

fieldEvents

Real values. Output from getRealBeds, i.e., a (nxm, 5)-dim data.frame with the following variables:

resource

chr: 'bed' 'bed' 'bed' 'bed' ...

time

int: 1 2 3 4 5 6 7 8 9 10 ...

med

int: 2 2 3 3 3 3 3 3 4 4 ...

source

chr: 'GA' 'GA' 'GA' 'GA' ...

date

POSIXct, format: '2020-03-03 01:00:00' '2020-03-04 01:00:00' '2020-03-05 01:00:00' '2020-03-06 01:00:00' ...

conf

list with the following entries (generated with babsimToolsConf):

seed

seed. Change the seed value to get different output for the same input parameters. Default: 123

simRepeats

simmer repeats

parallel

simmer parallel runs. Default: FALSE

perCores

percentage of cores used for parallel simmer simulations. Default: 0.5 (=50 percent)

ICU

use ICU infection data. Default: FALSE

logLevel

log leved (0 or 1). Default: 0 (no output)

maxCapacity

max capacity of resources. Default: 1e6

dataset

char name of the data set. Default: 'GA'

simulationDates

list with StartDate and EndDate. Period that is used for the simulation (babsim, simmer). Default: list(StartDate = '2020-03-03', EndDate = '2020-06-24')

fieldDates

list with StartDate and EndDate. Period when real data is available (resource usage). Default: list(StartDate = '2020-03-03', EndDate = '2020-06-24')

simulationData

data frame. Data used for the simulation. Default: dataCovidBeds20200624

fieldEvents

data frame. Data used for the evaluation (error). Default: GABeds220200624

resource

vector with resource names. Default: c('bed', 'intensiveBed', 'intensiveBedVentilation')

dontFilter

do not filter by date (used in subsimulations)

Details

get_mon_resources returns state changes in resources:

  • 'resource': resources name

  • 'time': time instant of the event that triggered the state change

  • 'server': server count

  • 'queue': queue count

  • 'capacity': capacity

  • 'queue_size': queue size

  • 'system': system count (server + queue). If no queues are used, system values equal server values.

  • 'system_limit': system limit (capacity + queue_size)

Value

This function returns an env data frame (tibble [nxm, 15] (S3: grouped_df/tbl_df/tbl/data.frame)) with the following entries:

resource (chr)

name of the seized resource: 'bed' 'bed' 'bed' 'bed' ...

time (num)

time step: 3 10 12 13 14 15 15 15 15 16 ...

server (int)

server: 1 2 3 2 3 4 3 4 5 6 ...

limit (num)

limit: Inf Inf Inf Inf Inf ...

replication (int)

replication: 1 1 1 1 1 1 1 1 1 1 ...

upper (int)

upper: 1 2 3 2 3 5 5 5 5 7 ...

lower (int)

lower: 1 2 3 2 3 3 3 3 3 5 ...

med (num)

med: 1 2 3 2 3 4 4 4 4 6 ...

date (POSIXct)

time, format: yyyy-mm-dd hh:mm.ss

rwdate (POSIXct)

format: '2020-03-01' '2020-03-08' '2020-03-15' '2020-03-15' ...

source (chr)

name of the simulation that was used: 'babsim' 'babsim' 'babsim' 'babsim' ...

See Also

modelResultHospital

Examples

data <- getSyntheticData()
para <- babsimHospitalPara()
conf <- babsimToolsConf()
conf <- getConfFromData(
  conf = conf,
  simData = data$simData,
  fieldData = data$fieldData
)
arrivalTimes <- getArrivalTimes(data$simData$Infected)
fieldEvents <- getRealBeds(
  data = data$fieldData,
  resource = c("bed", "intensiveBed", "intensiveBedVentilation")
)
envs <- babsimHospital(arrivalTimes = arrivalTimes, conf = conf, para = para)
res <- envToTibble(envs = envs, conf = conf, fieldEvents = fieldEvents)

babsim.hospital documentation built on May 30, 2022, 9:05 a.m.