S4 getter and replacement methods for the detection slot on a
SeverityEstimateModel, plus chainable helpers to set and
validate detection readiness.
Usage
detection(x)
detection(x) <- value
# S4 method for class 'SeverityEstimateModel'
detection(x)
has_detection(x)
# S4 method for class 'SeverityEstimateModel'
has_detection(x)
# S4 method for class 'SeverityEstimateModel'
detection(x) <- value
require_detection(model, mode = "error")
set_detection(model, name, map = c(active = "active", passive = "passive"))Arguments
- x
- value
A named list with entries
nameandmap.- model
- mode
How
require_detection()should respond when detection is not set. One oferror,warn,silent.- name
The name of the detection column, which must be present in
line_list.- map
A named character vector mapping detection column values to either
activeorpassive.
Value
detection(x) returns the current detection specification.
detection(x) <- value returns x modified to include the detection
specification.
has_detection(x) returns TRUE if detection has been set, FALSE
otherwise.
require_detection(model, mode) returns model. If detection is unset, the
behavior depends on mode.
set_detection(model, ...) returns model modified to include the detection
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_detection(
"detection",
map = c("Active" = "active", "Passive" = "passive")
)
model
#> Severity Estimate Model:
#>
#> Data:
#> dataset rows columns
#> line_list 3 5
#> population 3 2
#>
#> Detection Probability Priors:
#> active prior: beta(1.0, 1.0) (default)
#> passive_asymptomatic prior: beta(1.0, 1.0) (default)
#> passive_symptomatic prior: beta(1.0, 1.0) (default)
#>
#> Timesteps:
#> not set
#>
#> Detection:
#> column: detection
#> active: 2 cases (values: Active)
#> passive: 1 cases (values: Passive)
#>
#> Outcome:
#> not set
#>
#> Strata:
#> none