Skip to contents

S4 getter and replacement methods for the timesteps slot on a SeverityEstimateModel, plus a chainable set_timesteps() helper for pipeline ergonomics.

Usage

timesteps(x)

timesteps(x) <- value

# S4 method for class 'SeverityEstimateModel'
timesteps(x)

has_timesteps(x)

# S4 method for class 'SeverityEstimateModel'
has_timesteps(x)

# S4 method for class 'SeverityEstimateModel'
timesteps(x) <- value

require_timesteps(model, mode = "error")

set_timesteps(model, name, levels = NULL)

Arguments

x

A SeverityEstimateModel.

value

A named list with entries name and levels.

model

A SeverityEstimateModel.

mode

How require_timesteps() should respond when timesteps are not set. One of error, warn, silent.

name

The name of the timestep column, which must be present in line_list.

levels

The levels for the timestep, or NULL to infer from line_list.

Value

timesteps(x) returns the current timestep specification.

timesteps(x) <- value returns x modified to include the timestep specification.

has_timesteps(x) returns TRUE if timesteps have been set, FALSE otherwise.

require_timesteps(model, mode) returns model. If timesteps are unset, the behavior depends on mode.

set_timesteps(model, ...) returns model modified to include the timestep specification.

Examples

line_list <- data.frame(
  patient = 1L:3L,
  week = c(1L, 1L, 2L),
  age = c("Youth", "Adult", "Senior"),
  detection = c("Active", "Passive", "Active"),
  outcome = c("Asymptomatic", "Death", "Symptomatic")
)
population <- data.frame(
  age = c("Youth", "Adult", "Senior"),
  amount = rep(987L, 3L)
)
model <- SeverityEstimateModel(line_list, population) |>
  set_timesteps("week")
timesteps(model)
#> $name
#> [1] "week"
#> 
#> $levels
#> [1] 1 2
#>