reporting_triangle object from a data.frameThis method takes a data.frame containing case counts indexed by reference
date and report date and creates a reporting_triangle object.
See as_reporting_triangle.matrix() for other data
input options.
# S3 method for data.frame
as_reporting_triangle(
data,
delays_unit = "days",
reference_date = "reference_date",
report_date = "report_date",
count = "count",
...
)A reporting_triangle object
Data.frame in a long tidy format with counts by reference date
and report date. Must contain the following columns:
. - Column of type date or character with the dates of
the primary event occurrence (reference date).
Column of type date or character with the dates of
report of the primary event (report_date).
Column of numeric or integer indicating the new confirmed counts pertaining to that reference and report date (count). Additional columns can be included but will not be used. The input dataframe for this function must contain only a single strata, there can be no repeated reference dates and report dates.
Character string specifying the temporal granularity of
the delays. Options are "days", "weeks", "months", "years".
Default is "days".
Character string indicating the name of the column which represents the reference date, or the date of the primary event occurrence.
Character string indicating the name of the column which represents the date the primary event was reported.
Character string indicating the name of the column containing the number of incident cases on each reference and report date.
Additional arguments not used.
Reporting triangle construction and validation
[.reporting_triangle(),
[<-.reporting_triangle(),
as.data.frame.reporting_triangle(),
as.matrix.reporting_triangle(),
as_ChainLadder_triangle(),
as_reporting_triangle(),
as_reporting_triangle.matrix(),
as_reporting_triangle.triangle(),
assert_reporting_triangle(),
get_delays_from_dates(),
get_delays_unit(),
get_max_delay(),
get_mean_delay(),
get_quantile_delay(),
get_reference_dates(),
get_report_dates(),
get_reporting_structure(),
head.reporting_triangle(),
is_reporting_triangle(),
new_reporting_triangle(),
print.reporting_triangle(),
reporting_triangle-class,
summary.reporting_triangle(),
tail.reporting_triangle(),
truncate_to_delay(),
truncate_to_quantile(),
validate_reporting_triangle()
# Filter to reasonable max_delay for faster example
data_as_of_df <- syn_nssp_df[
syn_nssp_df$report_date <= "2026-04-01" &
(syn_nssp_df$report_date - syn_nssp_df$reference_date) <= 25,
]
as_reporting_triangle(data = data_as_of_df)
Run the code above in your browser using DataLab