% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare.R
\name{obr_actual_vs_forecast}
\alias{obr_actual_vs_forecast}
\title{Pair OBR forecasts with PFD outturn}
\usage{
obr_actual_vs_forecast(
  series = c("PSNB", "PSND", "expenditure"),
  refresh = FALSE
)
}
\arguments{
\item{series}{Forecast series. One of \code{"PSNB"}, \code{"PSND"}, \code{"expenditure"}.
Defaults to \code{"PSNB"}.}

\item{refresh}{Logical. If \code{TRUE}, re-download underlying files.}
}
\value{
An \code{obr_tbl} with columns \code{forecast_date}, \code{period} (fiscal year
being forecast), \code{period_type}, \code{series}, \code{unit}, \code{value_forecast}
(from HFD), \code{value_actual} (from PFD outturn), and \code{error}
(\code{value_forecast - value_actual}). Provenance points at the HFD;
the PFD source URL is recorded in \code{notes}.
}
\description{
Joins the long-format Historical Forecasts Database for a given series
against the Public Finances Databank outturn for the same series.
Returns one row per (forecast vintage, fiscal year) where both an OBR
forecast value and an ONS outturn value exist, with the forecast error
(\code{value_forecast - value_actual}) computed.
}
\details{
Useful for forecast-evaluation studies, similar in shape to the OBR's
own Forecast Evaluation Report decomposition.

Currently supports series for which a clean \code{gbp_bn} outturn function
exists in this package: \code{"PSNB"}, \code{"PSND"}, \code{"expenditure"}. Other
series (CPI, GDP, percentages of GDP) need outturn from external
packages and will error.
}
\examples{
\donttest{
op <- options(obr.cache_dir = tempdir())
try({
  eval <- obr_actual_vs_forecast("PSNB")

  # 1-year-ahead forecast errors only:
  # take the forecast vintage closest to the start of each fiscal year
  eval2425 <- eval[eval$period == "2024-25", ]
  eval2425[order(eval2425$forecast_date), ]
})
options(op)
}

}
\seealso{
Other forecasts: 
\code{\link{get_forecast_revisions}()},
\code{\link{get_forecasts}()},
\code{\link{list_forecast_series}()},
\code{\link{obr_compare_vintages}()},
\code{\link{obr_forecast_panel}()}
}
\concept{forecasts}
