irfPlotData#
Purpose#
Reshape IRF, FEVD, or SV-BVAR IRF results into a plot-ready long-format dataframe.
Format#
- df = irfPlotData(result, shock, response)#
- df = irfPlotData(result)
- Parameters:
result (struct) – an instance of an
irfResult,svIrfResult, orfevdResultstructure.shock (scalar) – Optional, shock index (1 to m). If omitted, all shocks are included.
response (scalar) – Optional, response variable index (1 to m). If omitted, all responses are included.
- Returns:
df (dataframe) – Dataframe. For
irfResult: columns horizon, shock, response, value. ForsvIrfResult: columns horizon, shock, response, median, lower_68, upper_68, lower_90, upper_90. ForfevdResult: columns horizon, shock, response, share.
Examples#
Plot a Single Shock-Response Pair#
new;
library timeseries;
data = loadd(getGAUSSHome("pkgs/timeseries/examples/macro.dat"));
result = varFit(data, 4);
irf = irfCompute(result, 20, quiet=1);
// GDP response to FFR shock
df = irfPlotData(irf, 3, 1);
plotXY(df[., "horizon"], df[., "value"]);
Plot SV-BVAR IRF with Credible Bands#
new;
library timeseries;
data = loadd(getGAUSSHome("pkgs/timeseries/examples/macro.dat"));
result = bvarSvFit(data, quiet=1);
irf = irfSvCompute(result, 20, quiet=1);
// GDP response to FFR shock with bands
df = irfPlotData(irf, 3, 1);
// Plot median with 68% band
plotXY(df[., "horizon"],
df[., "median"]~df[., "lower_68"]~df[., "upper_68"]);
Extract All Pairs#
new;
library timeseries;
data = loadd(getGAUSSHome("pkgs/timeseries/examples/macro.dat"));
result = varFit(data, 4, quiet=1);
irf = irfCompute(result, 20, quiet=1);
// All m*m pairs in long format
df = irfPlotData(irf);
print df[1:10, .];
Remarks#
This is a convenience function for plotting. It reshapes the array-of-matrices
representation into a long-format dataframe that can be passed directly to
plotXY() or exported to CSV.
No Rust FFI call — this is a pure GAUSS reshape operation.
Library#
timeseries
Source#
irf.src
See also
Functions irfCompute(), irfSvCompute(), fevdCompute()