 Econometrikset, tekstit on panel data analysis and multilever modeling, typically focus on two different approaches, the random effects approach and the fixed effects approach. Both of these approaches belong to the family of generalized least squares or GLS estimators because they involve applying normal recursion analysis on a transform data set. So what is the problem that these techniques try to address? In a normal recursion model we have the predictors and the observed variables from the fixed part and then we have the random part that only contains the error term. In a recursion model for cluster data we also have unobserved heterogeneity. We have the unobserved term which here is called AJ. The key question that these when we start modeling this data is what do we do with the AJ? Should it go into the fixed part or into the random part? And the answer to this question determines whether we go for fixed effects modeling or random effects modeling. In the fixed effects model we estimate a specific value for each cluster. So AJ, the unobserved heterogeneity is in the fixed part and only the error term belongs to the random part. This is sometimes called the dummy variable model because the easiest way to implement this approach is not the most efficient way but easiest to understand is by adding a dummy variable for each cluster in the data. So if we have 20 observations consisting of five companies each observed five times, four companies each observed five times then we would add three dummies to the model and we would estimate a specific intercept for each company. So the first company is used as a reference and the intercept in the model is for that company and the intercept for the other companies would be obtained by using summing the intercept and the dummy for that company. So estimate the specific value for the intercept for each company that's the fixed effects strategy. The random effects model on the other hand puts the unobserved term into the random part and here we refer to the unobserved term as UJ because it's a random effect. We no longer estimate the specific value for each company instead we just estimate how much the companies vary from one another without estimating any specific values for any particular company. The random effects assumption importantly, approach importantly makes the random effects assumption that both UJ and Uij are uncorrelated with all X's. In the fixed effects approach we just assume that this normal error term Uij is uncorrelated with the X's but the Aij can be correlated with the X's here. So let's take a look at how these techniques differ and how the techniques are actually calculated and when you should be using one over the other. There are beyond these two techniques there are also other techniques that you could apply but these are two basic techniques that are fairly easy to understand. So the idea of random effects model is that we estimate one regression line. The fixed part gives the overall mean of the data and then we allow the observations to be clustered around the line. So for example this cluster of green observations is always above the regression line this cluster of blue observations is always below the regression line. In the fixed effects approach we estimate the unique regression line for each cluster. So here we have three different regression lines they have the same slope but they have a different intercept because we again estimate a specific intercept for each case and we can see that the lines are parallel because they are constrained to be so but they are varying in where they are drawn. In this case the random effects assumption holds and the regression coefficient from this model and that model the slope is about the same. When the random effects assumption doesn't hold then there are random effects approach produces inconsistent and biased estimates for the within effect. But the fixed effects approach which gives a unique regression line will estimate the within effect consistently. So how does fixed effects estimation approach actually work? It's fairly easy to understand. The idea of a fixed effects approach is that we mean center we group mean center all variables. So we subtract the group mean of each x from that x we subtract the cluster mean or group mean of y from y and then we run a normal OLS regression model to the transform data. Let's take a look at an example of how this is done. So our data consists of a few companies each observed for four years and we have two variables we have male CEO indicating whether the CEO is a man or not and then we have ROA which is return on assets our dependent variable and we want to know whether the CO gender predicts the ROA or explains ROA. So that's our original data and to implement the GLS fixed effects approach we first calculate the cluster mean for the color of cluster means for all these variables. So for the first case all CEOs are women so this is a zero male CEO. ROA 12% is the mean of these variables these values so this is the cluster mean for the ROA for the first case this is the cluster mean of ROA of these four observations that belong in the next case and so on. Then we run we cluster mean or group mean center the data by subtracting these group or cluster means from the original data and we get this kind of data. So now the ROA here has a mean of zero for each case male CEO has a mean of zero for each cluster as well. This demonstration also shows one important feature of GLS fixed effects approach. The GLS fixed effects approach assumes that all of these variables that we have male CEO and ROA vary within cluster and now we don't have any variation in the CEO gender within company and when we cluster mean center the data then all values for male CEO will be zeros and this is a violation of the third assumption of Richardson analysis and Richardson model cannot be estimated. So importantly the GLS fixed effects approach can't include variables that don't vary within groups. To include such variables we can go for the GLS random effects approach. So let's take a look at what GLS random effects estimation does. Again we have the fixed part and the random part and now we assume that the error term that the unobstructed heterogeneity term UJ is in the random part and it is uncorrelated with the predictors. This approach is similar to the fixed effects approach except that instead of cluster mean centering all variables we quasi mean center all variables and that means that we don't fully cluster mean centered variables but we do so only partly and then we apply normal OLS regression to the data. So let's take a look at what this quasi mean centering means and I'm going to use a text by Woolridge as an example. So here is the equation for the GLS random effects estimator and instead of subtracting the Y bar which is the cluster mean from Y we multiply the Y bar with lambda before we subtract from the data and the lambda varies between 0 and 1 which means that sometimes we fully cluster mean centered the data sometimes we don't cluster mean centered the data at all if lambda goes to 0. This equation also if we play around it a bit shows us that the GLS random effects estimator is the weighted average of the between regression and the within regression. The within regression is estimating regression using cluster mean centered data which is what the GLS fixed effects approach does and the between regression is the regression of cluster means on each other. When the random effects assumption holds the within and between effects are the same so that's one way to understand the random effects assumption and this is the key idea behind GLS random effects estimate. So the idea is that when the between effect and the within effect are the same then we can estimate the within effect more precisely by borrowing information from the between effects regression. In the fixed effects approach we eliminate all these between effects from the data by using the cluster mean centering in GLS random effects modeling we assume that the between effect is informative for estimating within effect and we use that information to get more precise estimates. So the idea is that the weighted average of the within regression and the between regression is more efficient than the within regression only and this more efficiency or precision is one of the advantages of GLS RE over GLS FE. Let's take a look at the lambda term a bit more and the different variance components. So in the lambda term we have the variance of the error term sigma u, then we have the variance of unobsord effect or unobsord heterogeneity sigma a and then we have t which is the number of time points and this is the within variation divided by within variation plus t times between variation and then we take a square root. So this kind of looks like an intro class correlation except that there is the extra t. So when we look at these different components that go into the equation we can make a couple of observations. So first if there is no clustering at all GLS RE equals OLS. So when the lambda is estimated to be 0 sorry when there is no within cluster variation then GLS RE will equal normal OLS regression. When there is no between cluster variation sigma a is 0 then lambda goes to 1 and GLS RE equals GLS FE. So the GLS random effects model is always somewhere between normal OLS regression model, ignores clustering and the GLS within effect model, GLS fixed effects model. Importantly when the number of observations or number of time points increases then lambda also approaches 1 which means that GLS random effects approach approaches GLS FE. So when there is a large number of observations then the efficiency difference between GLS RE and GLS FE starts to diminish because GLS RE approaches GLS FE and that's fairly intuitive because if you think that the GLS FE also uses only the within information but GLS RE uses between information. There are a number of between cluster differences that we have doesn't depend on the number of time points. But the number of time points determines how much information we have on how the cases vary over time. So we get more information from the varying time points that means that GLS FE becomes better and GLS RE then approaches GLS FE. So which one of these techniques should you apply? Before I go into this I must say that there are also other techniques that I explained in other videos that address the same problem that you could also consider. But normally in econometric books this is explained as a decision of between GLS FE and GLS RE. There are advantages of GLS FE is basically that it doesn't make the random effects assumption. But when the random effects assumption holds it is less efficient than the random effects assumption and also another major disadvantage is that the GLS fixed effects approach can be used with any variables that don't vary with inquisters. The GLS random effects assumption has two advantages. First it can include variables that are constant within groups so we can for example use individual's gender as a predictor when we study something that varies over time. GLS FE RE is also efficient when random effects assumption holds so the estimates are more precise. The major disadvantage of GLS random effects assumption approach is that it makes the random effects assumption and it is inconsistent and biased if the random effects assumption doesn't hold. Fortunately there are a couple of empirical tests that can be used for testing the random effects assumption and in practice people choose between these two approaches by performing one of these tests and then going with GLS RE if the random effects assumption holds and going with the GLS FE if it doesn't. But there are also other alternatives that you could consider that I'll talk in other videos.