DATA SCIENCE USING PYTHON

ONLINE TRAINING COURSE

Vector Autoregression (VAR) Model

Vector autoregression(VAR) is a statistical model used to catch the connection between different amounts as they change over the long haul. VAR is a sort of stochastic interaction model. VAR models sum up the single-variable (univariate) autoregressive model by taking into consideration multivariate time series. VAR models are frequently utilized in financial aspects and the inherent sciences.


To explain this model, let me introduce one of interesting case study of Money Supply (M1) and 90 Days Corporate Interest rates (R) in economics.

Money Supply:

The total stock of money circulating in an economy is the money supply. The circulating money involves the currency, printed notes, money in the deposit accounts and in the form of other liquid assets.

90 Days Corporate Interest rates:

90-day prime corporate interest rates in %

These two are the key factors of the Monetary Policy which impacts other economic parameters like inflation, business expansions, net exports, employments – all of which directly or indirectly affects the demand.

OK!!! Return to the term VAR Model.


To explain the concept of VAR, we will consider the often asked question in macroeconomics: Is it Money Supply that “causes” the interest rates that is,


Money Supply (M1) ----> Interest rates (R) that is M1 affects R or


Interest rates that “causes” the Money Supply that is,


Interest rates (R) ----> Money Supply (M1) that is R affects M1

These two questions create a seed of VAR model as follow.

M1t = α + β (Mt – j) + γ (Rt – j) + u1
Rt = α + β (Mt – j) + γ (Rt – j) + u2


M1t = Money Supply at time t
Mt – j = Lagged money supply at time t – j
Rt = Interest Rates at time t
Rt – j = Lagged Interest rates

The above model parameters are estimated by the usual OLS method. Lagged variables can be fixed by using trial and error and by using AIC, BIC information criteria. The term autoregressive in VAR is used as it contains the lagged value of endogenous (dependent) variable and the term vector is used as we are dealing with vector of two (or more) variables.

In VAR Model, there is a true simultaneity among set of variables and must be treated on an equal footing. In fact, there is no distinction between endogenous (dependent) and exogenous (independent) variables.





Let’s model the Money Supply – Interest rates data using VAR models in Python.

Implementation of VAR Models using Python

Vector Auoregressive (VAR) Models

In[2]:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from statsmodels.tsa.api import VAR

# Load the input files

money_int_rates = pd.read_excel ("./Data/Money_Interest_Rate.xlsx") [[ "Year","M1" ),"R"]]
money_int_rates.head()

Out[2]:

Year M1 R
0 1979-1 22175.0 11.13333
1 1979-2 22841.0 11.16667
2 1979-3 23461.0 11.800000
3 1979-4 23427.0 14.18333
4 1980-1 23811.0 14.38333

In[23]:

money_int_rates_train = money_int_rates[0:36]
money_int_rates_test = money_int_rates[36:]

Fit the VAR Model by treating Money Supply and Interest Rates dependent on each other.

I used AIC information criteria method to set for the appropriate lag variables

In[24]:

money_int_rates_model = VAR(np.asarray(money_int_rates_train[["M1", "R"]])
result = money_int_rates_model.fit(ic = 'aic')
result.summary()

Out[24]:

Summary of Regression Results

Model: VAR
Method: OLS
Date: Tue, 24, Nov, 2020
Time: 14:33:57