The following is code used in the project, ‘Risk Shocks’, by Lawrence Christiano, Massimo Rostagno and Roberto Motto. You may use this code, but please include a citation to this manuscript in any work that uses all or parts of this code.