Skip to content

Commit

Permalink
+ Kaenzig data files - some superfluous files, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkelpm committed Jul 10, 2021
1 parent adcb758 commit 895ac82
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 231 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
*.png
*.eps
*.DS_Store
!applications/kaenzig/dataQuantM.mat
!applications/kaenzig/OilSurprisesMLog.mat
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
Matlab code for inference on variance decompositions and the degree of invertibility/recoverability in a general Structural Vector Moving Average (SVMA) model identified by external instruments (IVs, also known as proxies)

**Reference:**
Plagborg-Møller, Mikkel and Christian K. Wolf (2020), "Instrumental Variable Identification of Dynamic Variance Decompositions", https://scholar.princeton.edu/mikkelpm/decomp_iv (paper + online appendix)
Plagborg-Møller, Mikkel and Christian K. Wolf (2021), "Instrumental Variable Identification of Dynamic Variance Decompositions", https://scholar.princeton.edu/mikkelpm/decomp_iv (paper + online appendix)

**Acknowledgements:**
We are grateful to Diego Känzig for allowing us to reproduce some of the data files used in his 2021 AER paper.

Tested in: Matlab R2020a on Windows 10 PC (64-bit)

Expand All @@ -13,8 +16,9 @@ Tested in: Matlab R2020a on Windows 10 PC (64-bit)
- [SVMAIV_estim.m](functions/SVMAIV_estim.m): main function for SVMA-IV inference
- [SVARIV_estim.m](functions/SVARIV_estim.m): SVAR-IV inference (assumes invertibility)

**[application](application):** empirical example
- [run_gk.m](application/run_gk.m): example based on Gertler & Karadi (2015)
**[applications](applications):** empirical applications
- [gk/run_gk.m](applications/gk/run_gk.m): application based on Gertler & Karadi (2015)
- [kaenzig/run_kaenzig.m](applications/kaenzig/run_kaenzig.m): application based on Känzig (2021)

**[illustration](illustration):** numerical illustration
- [run_sw.m](illustration/run_sw.m): SVMA-IV and SVAR-IV analysis of Smets & Wouters (2007) model
Expand Down Expand Up @@ -55,4 +59,12 @@ Parameter names:
- `FVR`: forecast variance ratio
- `FVD`: forecast variance decomposition

See the [empirical application](application/run_gk.m) for a concrete example. Additional optional arguments to [`SMVAIV_estim.m`](functions/SVMAIV_estim.m) are listed at the top of the function.
See our [empirical applications](applications) for concrete examples of how to use the code. Additional optional arguments to [`SMVAIV_estim.m`](functions/SVMAIV_estim.m) are listed at the top of the function.

## Replication instructions

The figures and tables in our paper and supplement are produced as follows:
- Figures 1 and B.7 and Table 1: [applications/gk/run_gk.m](applications/gk/run_gk.m)
- Table 2: First run [simulations/run_sim.m](simulations/run_sim.m) nine separate times, with the variable `model.dgp` at the top set to each of the options `0` through `8`. Then run [simulations/print_results.m](simulations/print_results.m)
- Figures B.1-B.6 and Table B.1: [illustration/run_sw.m](illustration/run_sw.m)
- Figures B.8-B.11: [applications/kaenzig/run_kaenzig.m](applications/kaenzig/run_kaenzig.m)
2 changes: 1 addition & 1 deletion applications/gk/run_gk.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

% Estimation settings (see other optional settings in "functions/SVMAIV_estim.m")
settings = {'ic', 'aic'; % Information criterion
'n_boot', 500; % Number of bootstrap samples
'n_boot', 1e3; % Number of bootstrap samples
'signif', 0.1; % Significance level
'horiz', 1:24}'; % Horizons of FVR to report

Expand Down
Binary file added applications/kaenzig/OilSurprisesMLog.mat
Binary file not shown.
Binary file added applications/kaenzig/dataQuantM.mat
Binary file not shown.
64 changes: 23 additions & 41 deletions applications/kaenzig/run_kaenzig.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,57 @@

% Empirical application: Kaenzig (AER, 2021)

%% Load data

% settings

data.endo_vars = {'oil_price','oil_production','oil_inventories','world_ip','neer','ip','cpi','ffr','vxo','tot'};
data.iv = 'oil_surprise';

% data.smpl_start = '1974M01';
% data.smpl_start = '1983M04';
data.smpl_start = '1983M03';
data.smpl_end = '2017M12';

% data

load data_kaenzig

% endogenous variables
%% Load data

data.sampleDates = sampleDates;
% Settings
data.endo_vars = {'oil_price','oil_production','oil_inventories','world_ip','neer','ip','cpi','ffr','vxo','tot'}; % Abbreviations of endogenous variables
data.diff = [0,1,1,1,1,1,1,0,0,0]; % =1: take first differences of endogenous variable
data.iv = 'oil_surprise';
data.smpl_start = '1983M03'; % Sample start point
data.smpl_end = '2017M12'; % Sample end point

% Endogenous variables
dat_endo = load('dataQuantM'); % Endogenous variables
data.sampleDates = dat_endo.sampleDates;
data.smplStartInd = find(strcmp(data.sampleDates,data.smpl_start));
data.smplEndInd = find(strcmp(data.sampleDates,data.smpl_end));
data.Y = dat_endo.data(data.smplStartInd:data.smplEndInd,:);

data.Y = dataEndo(data.smplStartInd:data.smplEndInd,:);

data.diff = [0,1,1,1,1,1,1,0,0,0];

% First differences
for i = 1:size(data.Y,2)
if data.diff(i) == 1
data.Y(:,i) = [NaN;12 * (data.Y(2:end,i) - data.Y(1:end-1,i))];
end
end

% IV

proxyRaw = [oilProxiesWTIM(:,14)];

dat_iv=load('OilSurprisesMLog'); % IV
proxyRaw = dat_iv.oilProxiesWTIM(:,14);
data.Z = proxyRaw(data.smplStartInd:data.smplEndInd,:);

% adjust sample

% Adjust sample
if max(data.diff) == 1
data.Y = data.Y(2:end,:);
data.Z = data.Z(2:end,:);
end

clear sampleDates dataEndo oilProxiesWTIM proxyRaw
clear sampleDates dataEndo oilProxiesWTIM proxyRaw;


%% SVMA-IV inference

disp('*** SVMA-IV analysis ***');

% Preliminaries
addpath('../../functions'); % Add folder with SVMA-IV analysis functions
addpath('subroutines'); % Add folder with some application-specific auxiliary functions
rng(2018); % Seed random number generator (for bootstrap)

% Estimation settings (see other optional settings in "functions/SVMAIV_estim.m")
settings = {'p', 12; % Information criterion
'n_boot', 100; % Number of bootstrap samples
settings = {'p', 12; % Lag length
'n_boot', 1e3; % Number of bootstrap samples
'signif', 0.1; % Significance level
'horiz', 1:50}'; % Horizons of FVR to report
'horiz', 1:48}'; % Horizons of FVR to report

% Run inference routines
[bounds, id_recov, inv_test, settings_struct] = SVMAIV_estim(data.Y, data.Z, settings{:});
Expand Down Expand Up @@ -105,7 +94,7 @@

% figure

plots.xticks = 0:10:50; % X axis ticks for FVR plot
plots.xticks = 0:12:48; % X axis ticks for FVR plot
plots.titles = {'FVR of Oil Price', 'FVR of Oil Production Growth', 'FVR of Oil Inventories Growth', 'FVR of World IP Growth', 'FVR of U.S. NEER Growth', ...
'FVR of U.S. IP Growth', 'FVR of U.S. CPI Growth', 'FVR of FFR', 'FVR of VXO', 'FVR of U.S. TOT'};
plots.xlabel = 'Horizon (Months)'; % X axis label for FVR plot
Expand All @@ -131,11 +120,8 @@

end

clear i

% table
clear i;

svmaiv_table

%% SVAR-IV analysis for comparison (assumes invertibility)

Expand Down Expand Up @@ -165,8 +151,4 @@

end

clear i

% FVD table

svariv_table
clear i;
64 changes: 0 additions & 64 deletions applications/kaenzig/subroutines/svariv_table.m

This file was deleted.

73 changes: 0 additions & 73 deletions applications/kaenzig/subroutines/svmaiv_table.m

This file was deleted.

2 changes: 0 additions & 2 deletions applications/kaenzig/subroutines/vec.m

This file was deleted.

23 changes: 0 additions & 23 deletions applications/kaenzig/tables/svariv_kaenzig.tex

This file was deleted.

23 changes: 0 additions & 23 deletions applications/kaenzig/tables/svmaiv_kaenzig.tex

This file was deleted.

0 comments on commit 895ac82

Please sign in to comment.