Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fred_transform

FRED transformation and subset helper


Description

Apply transformations given by FRED-MD or FRED-QD and generate rectangular subsets. See fred_qd for information on data and the Details section for information on the transformations. Call without arguments to retrieve available codes / all FRED suggestions.

Usage

fred_transform(
  data,
  type = c("fred_qd", "fred_md"),
  codes,
  na.rm = TRUE,
  lag = 1L,
  scale = 100
)

fred_code(vars, type = c("fred_qd", "fred_md"), table = FALSE)

Arguments

data

A data.frame with FRED-QD or FRED-MD time series. The column names are used to find the correct transformation.

type

Character scalar. Whether data stems from the FRED-QD or the FRED-MD database.

codes

Integer vector. Transformation code(s) to apply to data. Overrides automatic lookup of transformation codes.

na.rm

Logical scalar. Whether to subset to rows without any NA values. A warning is thrown if rows are non-sequential.

lag

Integer scalar. Number of lags to apply when taking differences. See diff.

scale

Numeric scalar. Scaling to apply to log differences.

vars

Character vector. Names of the variables to look for.

table

Logical scalar. Whether to return a table of matching transformation codes instead of just the codes.

Details

FRED-QD and FRED-MD include a transformation code for every variable. All codes are provided in system.file("fred_trans.csv", package = "BVAR"). The transformation codes are as follows:

  1. 1 - no transformation;

  2. 2 - first differences - Delta x;

  3. 3 - second differences - Delta2 x;

  4. 4 - log transformation - log x;

  5. 5 - log differences - Delta log x;

  6. 6 - log second differences - Delta2 log x;

  7. 7 - percent change differences - Delta x / lag-x - 1;

Note that the transformation codes of FRED-MD and FRED-QD may differ for the same series.

Value

fred_transform returns a data.frame object with applied transformations. fred_code returns transformation codes, or a data.frame of matching transformation codes.

See Also

Examples

# Transform a subset of FRED-QD
fred_transform(fred_qd[, c("GDPC1", "INDPRO", "FEDFUNDS")])

# Get info on transformation codes for unemployment variables
fred_code("UNRATE", table = TRUE)

# Get the transformation code for GDPC1
fred_code("GDPC1", type = "fred_qd")

# Transform all of FRED-MD
## Not run: 
fred_transform(fred_md, type = "fred_md")

## End(Not run)

BVAR

Hierarchical Bayesian Vector Autoregression

v1.0.1
GPL-3 | file LICENSE
Authors
Nikolas Kuschnig [aut, cre] (<https://orcid.org/0000-0002-6642-2543>), Lukas Vashold [aut] (<https://orcid.org/0000-0002-3562-3414>), Michael McCracken [dtc], Serena Ng [dtc]
Initial release
2020-09-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.