knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE,
  results = 'asis'
)

knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
librarian::shelf('tidyverse', 'zoo', 'TTR', 'tsibble', 'targets', 'tarchetypes', 'lubridate', "moodymudskipper/safejoin",
                 'alistaire47/pipecleaner', 'glue', 'validate', 'fim', 'dplyover', 'tsibble', 'gt', 'readxl')
df <- read_data() %>%
    define_variables() %>%

    #  Override growth rates
    create_override(
      var = state_purchases_growth,
      start = yearquarter('2020 Q4'),
      end = yearquarter('2022 Q1'),
      values = c(rep(0.0025, 3), 0.005, 0.0075, 0.01)
    )  %>%
    create_override(
      var = federal_social_benefits_growth,
      start = yearquarter('2021 Q1'),
      end = yearquarter('2022 Q3'),
      values = c(rep(-0.0075, 3), rep(0.015,4))
    ) %>% 
    growth_assumptions() %>%
    reallocate_legislation() %>%  
    mutate(
      across(c(ppp, aviation, paid_sick_leave, employee_retention),
             ~ coalesce(.x, 0)),
      federal_subsidies = federal_subsidies - ppp - aviation - paid_sick_leave - employee_retention,
      subsidies = federal_subsidies + state_subsidies
    )
df %>% 
  forecast2(federal_social_benefits, federal_subsidies)


malcalakovalski/fim documentation built on July 30, 2024, 8:37 a.m.