Skip to content

Latest commit

 

History

70 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository will be retired and moved to the official SOA repository: https://github.com/society-of-actuaries/Macroeconomics-based-ESG

macroesg

Macroeconomics based ESG

It includes calibration of a DSGE model, multifactor regression, and economic scenario generation.

DSGE Model

The DSGE model is built using dynare and tested using Octave, an open source software that replicates Matlab.

The model is documented according to a research paper (to be updated later)

Dynare version 4.5.7 (https://www.dynare.org/download/)

Octave version 4.4.1 (https://ftp.gnu.org/gnu/octave/windows/octave-4.4.1-w64-installer.exe)

Data: us_data.m

Model: us.mod

To run the model:

  1. addpath c:\dynare\4.5.7\matlab
  2. cd C:\dynare\us
  3. dynare us

Folder "us" needs to include data file and model file

Results are saved in us_results.mat in the dynare project folder. oo_ contains most of the useful information. To extract the results, you may load the mat in Octave and the output them to a csv file, with an example shown below. Or you can do copy and paste if the data volume is small.

load('C:\dynare\us\us_results.mat');

csvwrite('C:\dynare\us\oo_vd.csv', oo_.variance_decomposition);

Multifactor Regression

Regression models are used to build the relationships between macroeconomic factors and asset returns. R programs are used to test eight model types: linear regression, Lasso, Ridge, Elastic Net, CART, KNN, ANN, and GBM. It also includes prediction of economic recession, repairing correlation matrix for non-positive definite ones, and Vector Autoregressive Model for macroeconomic factors

Data: inputmap.csv for multifactor regression; varinput.csv for VAR macroecnomic model

Program: /R_Notebook/fundmapping.Rmd It needs to be run in RStudio which provides a more interative interface than R itself. It also generates a html file to show the codes and outputs.

ESG

ESG using DSGE and multifactor regression. It also includes yield curve interpolation and extropolation, and bond return calculation based on bond yield curve and investment strategy.

Data

mapping.csv: linear regression model parameters

normalchol.csv: Cholesky decomposition for expansion periods

recessionchol.csv: Cholesky decomposition for recession periods

glm_all_Recession.csv: Logistic model parameters for predicting recession periods. It is an output of the fundmapping program

dsge_foa.csv: DSGE first order approximation used for economic factor simulation

dsge_shocks.csv: distribution of soruces of risk

Program: /R_Notebook/esg.Rmd It needs to be run in RStudio which provides a more interative interface than R itself. It also generates a html file to show the codes and outputs.

R Scripts

fundmapping.R and esg.R in folder R_Script are the script version of the R notebooks. In case you do not want to use RStudio, they can be run in R.

You may need to change working directory in setwd("C:/dsge/r6/") with your own directory

Tips

Sometimes after you finish a dynare program run, you need to wait a few minutes to kick off new runs as the program may crash.

If you want to use the same folder for a new run, it is advised to clean all the files generated by dynare before the new run. You only need to keep the data file and mod file.

For Bayesian estimation, if you run multiple chains, a multi-core machine can speed up the estimation process.

Matlab is expected to be faster than Octave running the dynare program but it is not tested for this project.

Parallel Computing

If you have multiple cores or multiple machines, you may want to set up parallel runs using Matlab. This is especially helpful for MCMC with multiple chains. You will need a configuration file to specifiy the machines and how many CPU cores to use. A sample config file is provided as /input/parallel_matlab.cfg. To run the model in the parallel mode, you can use the following commands, assuming you saved the config file under 'C:\dynare':

  • addpath c:\dynare\4.5.7\matlab
  • cd C:\dynare\us
  • dynare us parallel conffile='C:\dynare\parallel.cfg'

More detailed instructions can be found at https://www.dynare.org/manual/Windows-Step_002dby_002dStep-Guide.html#Windows-Step_002dby_002dStep-Guide

Variables

In input/inputmap.csv, the following variables are included as inputs for fund mapping.

  • R_: policy interest rate
  • pi_c_: inflation rate based on CPI
  • dy_: change in real GDP per capita
  • dc_: change in consumption per capita
  • di_: change in investment per capita
  • dE_: change in employment per capita
  • dS_: change in exchange rate
  • dex_: change in export per capita
  • dimp_: change in import per capita
  • dw_: change in wage index
  • pi_i_: inflation based on fixed investment
  • pi_d_: inflation rate based on PPI
  • dy_star_: change in foreign real GDP per capita
  • pi_star_: change foreign inflation rate
  • R_star_: foreign policy interest rate
  • tb3m: 3-month Treasury bond yield
  • tb*y: *-year Treasury bond yield
  • aaaboa: AAA-rated corporate bond credit spread
  • aaboa: AA-rated corporate bond credit spread
  • aboa: A-rated corporate bond credit spread
  • bbbboa: BBB-rated coporate bond credit spread
  • aadefault: AAA-rated corporate bond default rate
  • adefault: AA-rated corporate bond default rate
  • bbbdefault: BBB-rated corporate bond default rate
  • sp500: S&P 500 quarterly index value change (%)
  • sp500d: S&P 500 annualized dividend yield (%)
  • oil: Crude oil quarterly price change (%)
  • gold: Gold quarterly price change (%)
  • reitret: REITs quarterly capital return
  • reitinc: REITs quarterly cap rate

About

Macroeconomics based ESG

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages