From the course: Advanced and Specialized Statistics with Stata

Panel data dynamics demo - Stata Tutorial

From the course: Advanced and Specialized Statistics with Stata

Start my 1-month free trial

Panel data dynamics demo

- [Instructor] I've already loaded the associated nlswork panel data and set it to panel data using xtset. Now let's generate some new variables that use the full available time series operators and take a closer look at them. Let's type the following code to get us started. Generate the variable never married equals to never married. Let's copy this four times, two, three, four. And now let's modify this code. Let's call the first variable L one never married which is the function of the lag one of never married. We'll call the next one F one which is the function of the forward one of never married. We'll call the next one D one which is a function of the difference one of never married. And finally we'll call the last variable S one never married which is the function of the seasonal difference one of never married. Let's run this. We've now created four new variables. A lag variable, a forward variable, a difference variable, and a seasonal difference variable. Let's go ahead and look at a small portion of this data. Specifically, let's look at the raw data of the first 12 observations which correspond to the first individual in our dataset. Let's type list idcode year age and all the never married variables in the first 12 observations. Okay, so we can see that individual one was 18 years old at the beginning of our dataset and 37 years old at the end. Individual one was not married at age 18, but then at age 19, this indicator flips from one to zero suggesting that they got married. And we can now see what the time series operators did. The lag to the previous value and carried it forward to the contemporaneous value. So here is the lag of never married. Note that some time gaps exist in our data and that the lag value is not carried forward when there is a time gap. For example, take a look over here for observation five. This takes place in 1975 and the reason that this observation is missing is because the value for 1974 is missing. The previous value was 1973 and the lag operator does not use the previous value, it uses the previous time period which was 1974 which is missing. The same applies to all the other time series operators. Here we can see the forward values, here we can see the difference values, and we can identify the change in marital status. And finally, we can see the seasonal difference which because there's a seasonal difference one is exactly the same as the difference operator one. Having created these lagged variables, we can also tabulate them against each other to explore transitions for example. So, if we wanted to look at the transition matrix we could type tabulate never married which is the contemporaneous variable against the forward of never married and let's add raw percentages. So now we can explore the transition between never married from the current time period to the future time period. In this case, if you are never married the likelihood is that you will remain never married in the next period by 81%. If you've ever married, then you cannot be never married again. So the transition from zero to zero is 100%. Next, let me show you how to incorporate multiple lags into an estimation command. For example, let's type regress log wage is a function of the lag going from minus two to two of the variables weeks, unemployed, and south. In this case, we're going to regress the log wages on the lags of minus two to two for both unemployment weeks and living in the south. These results actually have something quite interesting. The effect of living in the south today, or in the future, or in the past is statistically insignificant on effecting today's wages. However, the effect of being unemployed does have a negative effect on current wages. We can see that here. Current unemployment matters a lot. But, the lag one also appears to matter slightly. In other words, my wages today are a function of my current unemployment in weeks, but also my past unemployment. Even more interesting is the fact that my wages today are also related to tomorrow's unemployment. How can something in the future affect me today, you might ask. We call this the preprogram effect. You need to be careful here with the causal interpretation. Of course tomorrow's unemployment cannot affect your wages today. But often events don't come out the blue. People who become unemployed tomorrow may already be experiencing declining wages today, for example, as their company struggles for survival. This is what's highlighted here in these statistics and this is a great example of how useful panel data can be in exploring time dynamics.

Contents