fred_transform function

FRED transformation and subset helper

FRED transformation and subset helper

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.

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.

Returns

fred_transform returns a data.frame object with applied transformations. fred_code returns transformation codes, or a data.frame of matching transformation 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 - DeltaxDelta x;
  3. 3 - second differences - Delta2xDelta2 x;
  4. 4 - log transformation - logxlog x;
  5. 5 - log differences - DeltalogxDelta log x;
  6. 6 - log second differences - Delta2logxDelta2 log x;
  7. 7 - percent change differences - Deltax/lagx1Delta x / lag-x - 1;

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

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)

See Also

fred_qd

  • Maintainer: Nikolas Kuschnig
  • License: GPL-3 | file LICENSE
  • Last published: 2024-02-16