Title: | Forecasting Functions for the Transport Accident Commission |
---|---|
Description: | Functions to make hierarchical time series forecasts of attendant care hours easier. |
Authors: | Rob Hyndman [aut, cre, cph] |
Maintainer: | Rob Hyndman <[email protected]> |
License: | GPL-3 |
Version: | 0.0.1 |
Built: | 2024-11-12 02:55:28 UTC |
Source: | https://github.com/robjhyndman/TACforecasting |
Generate forecasts from ETS and ARIMA models, reconcile them, and combine them. Return a fable object containing the forecasts.
get_forecasts(data, h, nsim)
get_forecasts(data, h, nsim)
data |
Data set computed from |
h |
Forecast horizon. |
nsim |
Number of simulated future sample paths per model. |
Artificial Transport Accident Commission attendant care data
Time series of class 'tsibble'
group_costs
is a daily 'tsibble' with index 'billing_period' and
two values:
adjusted_hours: | Total attendant care hours |
nclaims: | Number of active claims |
The data is disaggregated using two keys:
age_group: | Age group of client at the time of accident |
injury_group: | Injury sustained by client due to accident |
Synthetic data
group_costs
group_costs
Produce a time plot of attendant care hours per billing period for specific disaggregations.
plot_forecasts( forecasts, data, show_age_group = "<aggregated>", show_injury_group = "<aggregated>" )
plot_forecasts( forecasts, data, show_age_group = "<aggregated>", show_injury_group = "<aggregated>" )
forecasts |
A fable object created by |
data |
The data used to construct the forecasts. This should be a tsibble object of the same form as |
show_age_group |
A character string specifying either a specific age group or "<aggregated>" meaning the total across all age groups. |
show_injury_group |
A character string specifying either a specific injury group or "<aggregated>" meaning the total across all injury groups. |
Rob J Hyndman
## Not run: group_costs |> get_forecasts(h=13, nsim=100) |> plot_forecasts(group_costs) ## End(Not run)
## Not run: group_costs |> get_forecasts(h=13, nsim=100) |> plot_forecasts(group_costs) ## End(Not run)
Produce a time plot of attendant care hours per billing period disaggregated by the given 'variable'
plot_total_hours(group_costs, variable = NULL, include_average = TRUE)
plot_total_hours(group_costs, variable = NULL, include_average = TRUE)
group_costs |
A tsibble containing costs optionally split by a variable |
variable |
Name of disaggregation variable. If NULL, aggregated costs are shown |
include_average |
Should the average cost per billing period be shown? |
Rob J Hyndman
group_costs |> plot_total_hours(age_group)
group_costs |> plot_total_hours(age_group)
This function takes two csv files as inputs: one containing the claims header and the other containing the attendant hours. It returns total hours per age group and injury group by billing period.
read_tac_data(claims_file, costs_file)
read_tac_data(claims_file, costs_file)
claims_file |
CSV file containing claims header |
costs_file |
CSV file containing attendant hours |
A tsibble object containing total attendant care adjusted hours for each billing period, disaggregated by age group and injury group. The column 'nclaims' shows the number of "active" claims in each billing period.
Rob J Hyndman
## Not run: group_costs <- read_tac_data( claims_file = "T086_claim_header.csv", costs_file = "T086_attendant_care_hours.csv" ) ## End(Not run)
## Not run: group_costs <- read_tac_data( claims_file = "T086_claim_header.csv", costs_file = "T086_attendant_care_hours.csv" ) ## End(Not run)
Compute accuracy statistics
tac_accuracy(forecasts, actuals)
tac_accuracy(forecasts, actuals)
forecasts |
A fable object with forecasts, usually the output from |
actuals |
A tsibble with actual values. For example, the output from |
A tibble with accuracy statistics
Compute forecasts with a rolling origin and return accuracy statistics
tscv_accuracy(group_costs, h, nsim, init, step)
tscv_accuracy(group_costs, h, nsim, init, step)
group_costs |
A tsibble with actual values. For example, the output from |
h |
The forecast horizon |
nsim |
The number of simulations used in each forecast for each model. |
init |
The number of initial observations to use for the first fold. |
step |
The number of observations to skip between each fold. |
A tibble with accuracy statistics.