fred_as_of: Fetch a series as it appeared on a given vintage date
Description
Returns the values that were available in FRED on date, before any
subsequent revisions. This is the standard real-time data access pattern:
set realtime_start = realtime_end = date. Useful for backtesting
forecasting models against the data that was actually available at the
time, not the revised series we see today.
Usage
fred_as_of(
series_id,
date,
from = NULL,
to = NULL,
units = "lin",
frequency = NULL,
aggregation = "avg",
cache = TRUE
)
Value
A fred_tbl with columns date, series_id, value,
realtime_start, realtime_end.
Arguments
series_id
Character. One or more FRED series IDs.
date
Character or Date. The vintage date ("YYYY-MM-DD").
from, to
Optional observation date range.
units
Character. Raw FRED units code. Default "lin".
frequency, aggregation
Optional frequency aggregation arguments
(see fred_series()).
cache
Logical. Cache results locally. Default TRUE.
Details
Underneath, this calls the series/observations endpoint with the
realtime parameters set. Results are cached separately from the
default (latest-vintage) cache, so calling fred_series("GDP") and
fred_as_of("GDP", "2020-01-15") keep distinct cache entries.
See Also
Other vintages:
fred_all_vintages(),
fred_first_release(),
fred_real_time_panel()
# \donttest{op <- options(fred.cache_dir = tempdir())
try({
# GDP as it looked on 1 March 2020 gdp_2020 <- fred_as_of("GDP", "2020-03-01")
})
options(op)
# }