Skip to contents

This function converts a reporting_triangle object to a vintages object in the wide format used by the reviser package. reviser provides tools for analysing data revisions and vintages, including state space nowcasting models and methods for assessing when releases become stable. Converting to reviser format enables use of those methods alongside baselinenowcast's nowcasting functionality.

Usage

as_reviser_vintages(x, ...)

Arguments

x

A reporting_triangle object to convert.

...

Additional arguments passed to reviser::vintages_wide().

Value

A tibble of class tbl_pubdate with a time column for the reference dates and one column per publication date containing the cumulative reported value as known on that publication date.

Details

A reporting_triangle stores incremental counts at each delay column, while a reviser vintages object stores the cumulative reported value at each publication date. The conversion takes the row-wise cumulative sum of the reporting triangle and maps each (reference date, delay) cell to a publication date reference_date + delay in the triangle's delay unit. The long form is then pivoted to wide format using reviser::vintages_wide().

NA values in the triangle propagate through the cumulative sum, so any unobserved cells in the original triangle remain NA in the vintages output.

To convert back to a reporting_triangle object, use as_reporting_triangle.tbl_pubdate().

Examples

# Create a reporting triangle from synthetic NSSP data
data_as_of_df <- syn_nssp_df[syn_nssp_df$report_date <= "2026-04-01", ]
rep_tri <- as_reporting_triangle(data = data_as_of_df)
#>  Using max_delay = 154 from data

# Convert to reviser vintages (wide) format
vintages <- as_reviser_vintages(rep_tri)
print(vintages)
#> # Vintages data (publication date format):
#> # Time periods:                            159
#> # Vintages:                                159
#>    time       `2025-10-25` `2025-10-26` `2025-10-27` `2025-10-28`
#>    <date>            <dbl>        <dbl>        <dbl>        <dbl>
#>  1 2025-10-25          194          248          274          287
#>  2 2025-10-26           NA          198          251          280
#>  3 2025-10-27           NA           NA          167          225
#>  4 2025-10-28           NA           NA           NA          145
#>  5 2025-10-29           NA           NA           NA           NA
#>  6 2025-10-30           NA           NA           NA           NA
#>  7 2025-10-31           NA           NA           NA           NA
#>  8 2025-11-01           NA           NA           NA           NA
#>  9 2025-11-02           NA           NA           NA           NA
#> 10 2025-11-03           NA           NA           NA           NA
#> # ℹ 149 more rows
#> # ℹ 155 more variables: `2025-10-29` <dbl>, `2025-10-30` <dbl>,
#> #   `2025-10-31` <dbl>, `2025-11-01` <dbl>, `2025-11-02` <dbl>,
#> #   `2025-11-03` <dbl>, `2025-11-04` <dbl>, `2025-11-05` <dbl>,
#> #   `2025-11-06` <dbl>, `2025-11-07` <dbl>, `2025-11-08` <dbl>,
#> #   `2025-11-09` <dbl>, `2025-11-10` <dbl>, `2025-11-11` <dbl>,
#> #   `2025-11-12` <dbl>, `2025-11-13` <dbl>, `2025-11-14` <dbl>, …