Unlocking the Potential of VAR Model in R & R-Studio by Dr. Dhaval Maheta

VAR Model in R: Think of it like the mood swings of three kids, Alice, Bob, and Carol. Their happiness, energy, and playfulness are all interconnected. Just like how a sunny day can make Alice happy, a lag in energy level can affect Bob. In the same way, the VAR model tracks the influence of past variables on current ones, giving us a peek into the dynamics of their joint behavior over time. So, it’s like predicting how playful Carol might be based on her recent playfulness, Alice’s happiness, and Bob’s energy. Ultimately, it’s about understanding how changes in one child’s mood can affect the others. And don’t forget, only significant results get the stars! 😎

In this article, we will understand how to run a Vector Autoregressive (VAR) model in R. The concept of a Vector Autoregressive model was given by Christopher Albert Sims and is quite common in economics to have models where some variables are not only explanatory variables for a given dependent variable but they are also explained by the variables that they are used to determine the decision regarding such a differentiation among variables was heavily criticized by Sims in 1980. According to Sims, there should not be any distinction between the endogenous and exogenous variable, therefore, once this distinction is abandoned, all variables are treated as endogenous.

Example of VAR Model

Let’s take an example scenario involving three children – Alice, Bob, and Carol. Here, the endogenous variables are Alice’s happiness level, Bob’s energy level, and Carol’s playfulness. Each child’s happiness, energy, or playfulness is expressed as a combination of their own past states and the past states of the other children.

What can be the auto-regressive relationships among them? Alis happiness today might be influenced by her own happiness yesterday, Bob’s energy from yesterday, and Carol’s playfulness from the day before. Bob’s energy today might be influenced by his own energy yesterday, Alice’s happiness from the day before, and Carol’s playfulness from two days ago. Carol’s playfulness today might be influenced by her own playfulness yesterday, Alice’s happiness from two days ago, and Bob’s energy from yesterday.

In simple terms, the term "Vector" means we are looking at the multiple variables A, B, and C related to the different aspects of the children’s experience. So, the Vector represents a collection of the related variables that are analyzed together to understand their joint behavior and dynamics over time.

How to Use VAR Model

We can use the VAR model to predict how playful Carol might be based on her recent playfulness, Alice’s happiness, and Bob’s energy. The exogenous variable can be the weather, as weather can influence this relationship.

In the VAR model, the assumption is that there are no exogenous variables. YT affects XT, XT affects YT, Y is influenced by its own lag, X is influenced by its own lag. Moreover, Y is also influenced by the lag of X (that is XT minus one). X is also influenced by the lag of Y (that is YT minus one). All the variables in a VAR system are endogenous.

Requirements of VAR Model

The basic requirements of the VAR model are:

  • There should be the presence of lagged values of the dependent variable on the right-hand side of the equation
  • The system contains a vector of two or more variables
  • The VAR model is constructed only if the variables are integrated of the order one, that is stationary at first difference
  • If the variables are cointegrated, construct both srun and long run models. If the models are not cointegrated, construct only short-run models.

How to Run VAR Model in R

To run the VAR model in R, we need to import the dataset into R. We can then use the package "Wars" to create the model. We require the package Wars, which we can install by running the command "install.packages("Wars")". After the installation, we can activate its library by running the command "library(Wars)".

We can create the model using the "model.frame" function in R. We can specify the variables, the type of constant, the maximum legs we are considering, and the model selection to be done on the basis of the Aki information criterion. We can then run and get the summary of the model.

We can calculate the information criterion for all the models by applying the formula minus 2 log likelihood plus the number of parameters. The model will be selected

About the Author

Dhaval Maheta (DM)
18.3K subscribers

About the Channel:

Dr. Dhaval Maheta is an accomplished professor specializing in Business and Industrial Management. He is a Doctorate in Management. He has authored insightful books on various software tools like “Minitab,” “Statistical Analysis using R Software,” “Machine Learning Using R-Rattle,” and “Data Analysis using R.” Dr. Maheta offers comprehensive training sessions on numerous software platforms, including SPSS, STATCRAFT, STATA, R and R-Studio, Minitab, Jamovi, Excel, Power BI Desktop, Google Data Studio, Tableau, SPSS-AMOS, ADANCO, Smart-PLS, SEM using R, Qualitative Data Analysis using Nvivo and Atlas.it, Design of Experiment using Minitab and Design Expert, Eviews, Gretl and Econometric Analysis using R. This YouTube channel is a gateway to a treasure trove of insights in data analysis and management. Subscribers gain access to tutorials, insights, and tips curated by Dr. Dhaval Maheta himself.
Share the Post: