Transcript:
One in this video we’re going to have an example of conducting the vector autoregression using art in particular, we’re going to be using Philippine data and we’re gonna try and explore associations between unemployment and GDP, and these associations typically form the concept of something called Okun’s law. So we’re gonna run through Var. And then we’re going to build the model That includes doing the lag’s election and then checking for persistence and we’re also going to do the robustness tests And eventually what we’re gonna do is we’re gonna see some Granger causality. Some impulse responses, which is indeed an application of water as well as trying to forecast future values of our variables. So first thing to do. Is we need to load we need to? We need to load required packages for running water. Okay, so first step. We have a couple of packages that we need in order for us to run a vector autoregression in our, so we start with the work of package next. There’s a specialized package called Vars, So we need that as well so library. M Filter another package, library, t-series, library forecasts and library diapers. Okay, so if in case, there’s an error in any of these commands, it just means that it’s not installed in your R. So you may just want to install the package and call the library command afterward. So what we do is now we load the data set, so let’s load the dataset. Okay, and so let’s name the data set. Okay, since we want to prove that long, okay, or disprove it, whatever the case, so it’s in a CSV file, so let’s go that CSV file so father, choose that CSV file is saved in my desktop, So that’s it sample Var, And if you notice here in our environment tab, there should be a data set and it should contain here. Uh, what’s included in the CSV file? That’s the date. Real GDP growth and unemployment is here, and then we have two other variables which we will not use for now. Okay, and then so we’ve loaded the data set into our already, so let’s let’s try and find some things about about our data set for now, so so a simple graph, so let’s see if we can graph it, so we’ll use ggplot and then we’re gonna get the data from Oakland. So remember, we stored the data in an object called Oakland. Then you want to create a scatterplot okay between GDP and unemployment and then let’s try and analyze it a bit. Yes, X equals on them. Y equals real others or GDP underscore groups. Okay, and that’s see so here. We have a scatterplot of unemployment and your GDP growth and what you can see is that so it’s relatively scattered. Okay, but notice there’s some sort of trend here. If we unemployment rate is low, say, for example. Here, look here, say it’s below six K. GD P tends to be high, but again there are exception, so for example, here, the unemployment rate was quite high, but then GD P growth or was quite high. And we have other things here, but generally we see okay. But when the unemployment rate is low, okay, our real GDP growth is high and when unemployment is high. Okay, like in this case, real GDP growth is that tends to be lower. But I’m gonna prove to you that. In the Philippine case, it doesn’t hold as much as it does in developed country. So you make me you might be asking what exact is open. Slow opens law states that there is a negative relationship between unemployment and GDP, so when unemployment is high, GDP growth is likely to be low. Okay, because, ah, there is a productivity loss or a productivity. There is a productivity that is underutilized that we cannot use so that can bolster down GDP growth, so that inverse relationship has been found to be true in a lot of countries and it’s well documented. But I’m gonna show to you now. At least in a timeframe that we have okay that that may not hold true for the Philippine case so first that is, we need to declare our time series variables. Okay, and the way we do that is, we’re gonna create an object, so we’re gonna get two objects since we have two variables. Okay, That’s using the PS Command So that will turn the variable we have into a series. Okay, and what we’re gonna do is from? Oakland, okay, we’re gonna get okay For GDP real GDP growth, okay, and that starts at that that data point start at 1999 third month. Okay, and the data frequency that we have that quarterly, so the frequency is equal to four if it were monthly, it would be 12 and so on, so we’re gonna create a time series object of GDP. Okay, and then we’re going to declare it as a type use variable, and there we go so we can see its value there and we’ll do the same for unemployment, And then I M so just just call it an M. That’s the S Oakland dollar side. An M. Okay start equals the same one, nine three whoops frequency for okay. Then we have GDP and unemployment there. Okay, something nice to do. Is we want to plot the series? Okay, so plot the series and we have, so let’s use the auto plot command auto plot. Since they’re both rates we can use approximately the same scale of the Y-axis. I am okay, so we want to plot. Just whoopsie bind. Okay, So we want to plot the series. Then we get this notice. We have unemployment. It’s in blue then. GDP growth that’s in. This is real GDP growth. So that’s in red, okay, so those are the data poisons. We’re gonna be using now. Can we use Var because we want to see associations between two or more series, assuming that both of the verbs in the series are both dependent variables, so we’re letting the data be agnostic and speak for itself, so we’re not imposing any sort of structure in the data. We just let the data speak for itself, and we run it as a vector autoregression. Okay, so something that in it’s curious that we that. I just want to put for now. Is that that if we try and run an OLS? Okay, so let’s say OLS one. Okay, so let’s try to run an oilless and what you’ll notice. Is that okay, we can see, OK? So summary or well, that’s what so the! LM command will run an OLS between GDP and unemployment GDP being dependent unemployment being independent. And then that’s summarized. So if you notice Unemployment’s coefficient is negative, so it does have a negative effect on GDP and it’s statistically significant. Okay, but if we just run OLS. What we’re imposing is that unemployment okay, affects GDP, But in this scenario, K GDP cannot affect unemployment because it’s the dependent variable and unemployment is independent, so the the train of causality or of correlation is from unemployment to GDP. But the philosophy of the VAR is that we were were not supposed to be imposing structures. It’s not right for us to impose a definite structure and how variables would be related so better let the data speak for itself in this case, so we have that. Okay, so lets are, so we plotted the data and then we saw that there is indeed some negative relationship. Okay, one thing we can do first is determine determine the persistence of the model. And how do we determine that? Well, we use the autocorrelation function or the ACF and the partial autocorrelation function or the PACA from sort of like the AR and the MA stuff that we’ve discussed before so we can do ACF and I will generate an autocorrelation function graph for GDP. Okay, and let’s just call it A A CF ACF for real GDP growth. Okay, and we should see it here, so we can see that the first few lags of GDP are indeed statistically significant, but it Peters out quickly, then if we do the AR component, which is P. ACF, okay, so let’s meet the ACF. Then this one should be be easier and we get the partial autopilot. Whoops, sorry, we get the partial autocorrelation function off real GDP growth and we notice that it’s not necessarily that significant, At least in this case. Then what we can do is we can do the same for unemployment. Okay, so let’s copy of a man, so ACF on em. Okay, ACF, for unemployment, and then you know, amen, and then so we have that so notice. There is a lot of persistence when it comes to unemployment because all of the lags are found to be relatively significant. And if we turn to be ACF, okay, so this whoops. Then do this mean and the whoops. This should be P. Asa. Sorry, and we should get that. So similarly, the there is some sort of persistence in the model that we can see. Okay, now we can run the augmented dickey-fuller test and that’s fine, but let’s skip it for now and let’s go directly to finding, okay, The optimal lags. Optima lags. So what we want to know now is Rea. Var uses by the new vector autoregression. It gives us auto regressive lags. There are variants of the Var called such as the Varma, which also uses moving average trucks, but for the most part, the basic bar only includes the number of auto regressive Lag. That we’re gonna do and one thing that we need to know is how many auto regressive locks will be put in this case. So our as is command for us to select. Okay, the number of the number of lags that we’re gonna do so what we’re gonna do Now First is we’re gonna bind the two variables in question, so let’s create a binding. Oh, cannot be V and then we’re gonna just bind or essentially group together, GDP, GDP and unemployment. Okay, we’re gonna group them together, and then what we’re gonna do is we’re gonna just gonna change their names a bit off. Oh, V V. So we’re just gonna change. The variable names see, bind GDP and unemployment. And we get that then what we’re gonna do is Lang. Select, okay, so we can select the optimal number flags to you. So what we’re gonna do is we’re gonna tell our game. Please select the optimal excuse from the two variables that we have, okay, and then let’s test, say approximately a matter of ten lags and just a constant type for now. Okay, so let’s assume there is no trend for now. Whoops type equals constant, sorry, not constant constant, and that should give us that then what we’re just gonna do is from like select, okay, that will create a variable inside that object called selection and that will display to us our selection criteria, so according to the Heike, the Hannah and Quinn and this indicator, we should use for lugs for our bar. According to – Wash, we should use one so since most indicator is safe for let’s use four. Okay, and what we’re gonna do now is we’re gonna build the model, so we build the model. So that’s a model one. Oh, models or a model open one, so we can be consistent then. Okay, so this is building in water, Okay, so the command to do a. Var is Bart. Okay, and we’re gonna use our parent. Oh, cannot be V. Which is the variables inside the world, then? P, which is your autoregressive border is equal to 4 because according to the information criteria, we’re gonna use for let this be a typical var so just constant, then see son equals null. Let’s assume no seasonal effects for now, and we have no extraneous variables. No, and we can run the wall. Okay, and we can do summary okay of our bar. And this is the result of our VAR model for now. Okay, so we have the VAR estimation results note. I can already anticipate that the results won’t be that significant, because if we notice there’s no really significant lags here. Okay, but what’s important is that notice all of the routes? K are inside the unit circle. Okay, so we have no strenuous routes. So the roots are all inside of this unit circle, so our system is generally stable, so this video is on building the bar in the next video. What we’re gonna do is we’re gonna diagnose and we’re gonna try to forecast and to causality analysis using the same var model.