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 - no transformation;
2 - first differences - Deltax;
3 - second differences - Delta2x;
4 - log transformation - logx;
5 - log differences - Deltalogx;
6 - log second differences - Delta2logx;
7 - percent change differences - Deltax/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-QDfred_transform(fred_qd[, c("GDPC1","INDPRO","FEDFUNDS")])# Get info on transformation codes for unemployment variablesfred_code("UNRATE", table =TRUE)# Get the transformation code for GDPC1fred_code("GDPC1", type ="fred_qd")# Transform all of FRED-MD## Not run:fred_transform(fred_md, type ="fred_md")## End(Not run)