{ "cells": [ { "cell_type": "markdown", "id": "electric-contract", "metadata": {}, "source": [ "# The Random Effects Model\n", "\n", "In the previous chapter, we saw two approaches to dealing with\n", "recovering marginal effects in panel data. First, we showed how simple\n", "differencing in a two period example can effectively rid the model of\n", "the unobserved individual effects, albeit with some strong assumptions.\n", "We also examined the assumptions necessary to completely ignore these\n", "effects and estimate a pooled OLS regression model. These approaches are\n", "commonly used, but more can be done [^1]. The literature has implemented\n", "these type of models in a number of ways, but the most prevalent are\n", "termed (1) random effects and (2) fixed effects. These terms refer to\n", "assumptions about the individual-specific constant terms $c_i$.\n", "\n", "The labels fixed and random effects are misleading. What matters here is\n", "the nature of the unobserved, time invariant, and individual-specific\n", "quantities. If there is a dependence between these unobserved factors\n", "and the observed independent variables we employ the fixed effects\n", "approach. If on the other hand, these effects are independent of the\n", "observed independent variables, then we use the random effects\n", "estimator. In this chapter, we focus on the random effects model.\n", "Keeping the same notation as before, let our estimating equation be\n", "\n", "$$y_{it}=\\mathbf{x}_{it}\\beta+c_i+\\epsilon_{it}$$\n", "\n", "Since the impact of these unobservable factors ($c_i$) are put in the\n", "error structure for each individual, we assume\n", "\n", "**Assumption 1: Restrictions on the error structure**\n", "\n", "```{math}\n", "\\begin{equation}\n", "\\Sigma=E[v_i v'_i]=\\sigma^2_\\epsilon I + \\sigma^2_c \\psi \\psi' = \n", " \\begin{bmatrix}\n", " \\sigma^2_\\epsilon+\\sigma^2_c & \\sigma^2_c & \\ldots & \\sigma^2_c \\\\\n", " \\sigma^2_c & \\sigma^2_\\epsilon+\\sigma^2_c & \\ldots & \\sigma^2_c \\\\\n", " \\vdots & & \\ddots & \\vdots \\\\\n", " \\sigma^2_c &\\ldots & &\\sigma^2_\\epsilon+\\sigma^2_c \\\\\n", " \\end{bmatrix} \\nonumber\n", "\\end{equation}\n", "```\n", "where the elements of $v$, $v_{it}$, are defined as $c_i+\\epsilon_{it}$.\n", "Note that $\\Sigma$ is the same for all individuals in the sample. The\n", "dimensions of I and $\\psi$ (a vector whose elements are all equal to 1)\n", "are $T \\times T$ and $T \\times 1$, respectively. This defines the piece\n", "of the variance covariance matrix relevant for each individual i.\n", "\n", "**Assumption 2: The rank condition**\n", "\n", "$$rank\\left ( E(x '\\Omega x)\\right ) = K$$\n", "\n", "To consider what this chapter is trying to accomplish, the following\n", "figure shows the classic case that is consistent with the assumptions\n", "outlined above. Note that the \\\"true\\\" model shows how each set of\n", "observations (each color are four observations collected over each\n", "individual) deviates from the population regression line (in black) by\n", "the amount $c_i$. Then, each of those points deviate around the colored\n", "lines by a random time variant unobservable component\n", "($\\epsilon_{it} \\sim N(0,\\sigma^2_{\\epsilon} I)$).\n", "\n", "```{figure} /_static/lectures/panel_re/random_effects.png\n", ":scale: 35%\n", ":name: \n", " \n", "Data Consistent with the Random Effects Model\n", "```\n", "\n", "## Estimating Parameters\n", "\n", "To use the information embodied in this error structure for estimating\n", "$b_{RE}$ and $Var(b_{RE})$, we can use a weighted least squares\n", "approach, where we first estimate $\\Omega$, denoted as $\\hat{\\Omega}$\n", "and then we estimate $b_{RE}$ as\n", "\n", "```{math}\n", ":label: eq:re_estimator\n", "\\begin{equation}\n", " \\mathbf{b_{RE}}=\\mathbf{(x' \\hat{\\Omega}^{-1} x)}^{-1}\\mathbf{x' \\hat{\\Omega}^{-1} y}\n", "\\end{equation}\n", "```\n", "Clearly to calculate {eq}`eq:re_estimator` we need\n", "$\\hat{\\Omega}$. By assumption,\n", "\n", "```{math}\n", "\\begin{equation}\n", "\\hat{\\Sigma}= \n", " \\begin{bmatrix}\n", " \\hat{\\sigma}^2_\\epsilon+\\hat{\\sigma}^2_c & \\hat{\\sigma}^2_c & \\ldots & \\hat{\\sigma}^2_c \\\\\n", " \\hat{\\sigma}^2_c & \\hat{\\sigma}^2_\\epsilon+\\hat{\\sigma}^2_c & \\ldots & \\hat{\\sigma^2_c} \\\\\n", " \\vdots & & \\ddots & \\vdots \\\\\n", " \\hat{\\sigma}^2_c &\\ldots & & \\hat{\\sigma}^2_\\epsilon+\\hat{\\sigma}^2_c \\\\\n", " \\end{bmatrix}_{T \\times T}\n", "\\end{equation}\n", "```\n", "a $T \\times T$ dimensional matrix for each individual i. $\\sigma$\n", "follows from our assumptions above, since (noting that assuming mean\n", "zero errors for $v_{it}$), that\n", "\n", "```{math}\n", "\\begin{aligned}\n", " Var(v_{it})=&E[(v_i-0)^2]=E(v^2_i) \\\\\n", " =&E[(\\epsilon_{it}+c_i)^2] \\\\\n", " =&E[\\epsilon^2_{it}+2\\epsilon_{it}c_i+c_i^2]\\\\\n", " =&E[\\epsilon^2_{it}+c_i^2] \\\\\n", " =&\\sigma_{\\epsilon}^2+\\sigma_{c}^2\n", "\\end{aligned}\n", "```\n", "Noting that $E[2\\epsilon_{it}c_i]=0$ from Assumption 1. The covariance\n", "with $v_{it+1}$\n", "\n", "```{math}\n", "\\begin{aligned}\n", " Cov(v_{it},v_{it+1})=&E[(v_{it}-0)(v_{it+1}-0)] \\\\\n", " =&E[(v_{it}v_{it+1})] \\\\\n", " =&E[(\\epsilon_{it}+c_i)(\\epsilon_{it+1}+c_i)]\\\\\n", " =&E[\\epsilon_{it}\\epsilon_{it+1}+\\epsilon_{it}c_i+\\epsilon_{it+1}c_i+c^2_i]\\\\\n", "=&\\sigma_c^2 \n", "\\end{aligned}\n", "```\n", "where the first term is zero (we assume no autocorrelation in\n", "$\\epsilon$), and the middle two terms are zero due to Assumption 1. This\n", "leaves us with the individual specific variance assumed to be constant\n", "across all groups. These derivations explicitly show what we are\n", "imposing in this model.\n", "\n", "It is important to note that $E[v_{it}v_{jt}]$ and $E[v_{it+1}v_{jt}]$\n", "are also assumed to be zero which is implicit in the full sample\n", "variance covariance matrix for the error structure defined by\n", "\n", "```{math}\n", ":label: eq:full_varcov_matrix\n", "\\begin{equation}\n", "\\Omega=\\begin{bmatrix}\n", " \\Sigma & \\mathbf{0}&\\mathbf{0}&\\ldots&\\mathbf{0} \\\\\n", " \\mathbf{0}&\\Sigma & \\mathbf{0}&\\ldots&\\mathbf{0} \\\\\n", " & & & \\vdots & \\\\\n", " \\mathbf{0}& \\mathbf{0}&\\ldots&\\mathbf{0} &\\Sigma \n", " \\end{bmatrix}_{NT \\times NT}\n", "\\end{equation}\n", "```\n", "Since $\\Omega$ is a block diagonal matrix (having off diagonal elements\n", "not zero only when individual i and j are the same person), all\n", "information about $\\sigma^2_{c}$, which is assumed to be constant across\n", "all individuals comes from within cross section units.\n", "\n", "To estimate these, first estimate the model using pooled OLS as in the\n", "previous chapter to recover $\\mathbf{b}_{ols}$, then find the estimated\n", "model errors as\n", "\n", "```{math}\n", ":label: eq:pooled_resids\n", "\\begin{equation}\n", " \\hat{\\mathbf{v}}=\\mathbf{y}-\\mathbf{x} b_{ols}\n", "\\end{equation}\n", "```\n", "Using these we can find the overall variance of the model:\n", "$\\hat{\\sigma}^2_v=\\hat{\\sigma}^2_\\epsilon+\\hat{\\sigma}^2_c$ for the\n", "diagonal elements of the matrix. This is done by using the formula:\n", "\n", "```{math}\n", "\\begin{equation}\n", "\\hat{\\sigma}^2_v=\\frac{1}{N \\times T -K} \\hat{\\mathbf{v}}'\\hat{\\mathbf{v}} \\nonumber\n", "\\end{equation}\n", "```\n", "We can also use the information contained in $\\hat{\\mathbf{v}}$ to\n", "estimate the covariance in the error imparted by the individual specific\n", "unobservable factor\n", "\n", "```{math}\n", ":label: eq:var_c\n", "\\begin{equation}\n", " \\hat{\\sigma}^2_c=\\frac{1}{[N \\times T (T-1)/2 -K]} \\sum^N_{i=1} \\sum^{T-1}_{t=1} \\sum^{T}_{s=t+1} \\hat{v}_{it}\\hat{v}_{st}\n", "\\end{equation}\n", "```\n", "The intuition behind {eq}`eq:var_c` is that the complicated\n", "summation pattern takes the off diagonal elements contained in $v$ and\n", "averages these to estimate the variance of $c_i$. For off diagonal\n", "elements where $i \\ne j$, these elements are ignored and the equation\n", "omits these. Consider this simple example of $N=2$ and $T=3$ for how the\n", "estimated errors in the model ($\\hat{v}$) are actually used for\n", "calculating $\\sigma^2_c$:\n", "\n", "```{math}\n", ":label: eq:re_example\n", "\\begin{equation}\n", " \\begin{matrix}\n", " Individual & t & s & Row,Column \\\\\n", " \\hline\n", " 1 & 1 & 2 & 1,2 \\\\\n", " 1 & 1 & 3 & 1,3 \\\\\n", " 1 & 2 & 3 & 2,3 \\\\\n", " 2 & 1 & 2 & 1,2 \\\\\n", " 2 & 1 & 3 & 1,3 \\\\\n", " 2 & 2 & 3 & 2,3 \n", " \\end{matrix}\n", "\\end{equation}\n", "```\n", "```{math}\n", "\\begin{equation}\n", " \\hat{\\mathbf{v}}\\hat{\\mathbf{v}}'=\n", " \\begin{bmatrix}\n", " \\hat{v}_{11}\\hat{v}_{11} & \\color{blue}{\\hat{v}_{11}\\hat{v}_{12}} & \\color{blue}{\\hat{v}_{11}\\hat{v}_{13}} & \\hat{v}_{11}\\hat{v}_{21} & \\hat{v}_{11}\\hat{v}_{22} & \\hat{v}_{11}\\hat{v}_{23} \\\\\n", " \\hat{v}_{12}\\hat{v}_{11} & \\hat{v}_{12}\\hat{v}_{12} & \\color{blue}{\\hat{v}_{12}\\hat{v}_{13}} & \\hat{v}_{12}\\hat{v}_{21} & \\hat{v}_{12}\\hat{v}_{22} & \\hat{v}_{12}\\hat{v}_{23} \\\\\n", " \\hat{v}_{13}\\hat{v}_{11} & \\hat{v}_{13}\\hat{v}_{12} & \\hat{v}_{13}\\hat{v}_{13} & \\hat{v}_{13}\\hat{v}_{21} & \\hat{v}_{13}\\hat{v}_{22} & \\hat{v}_{13}\\hat{v}_{23} \\\\\n", " \\hat{v}_{21}\\hat{v}_{11} & \\hat{v}_{21}\\hat{v}_{12} & \\hat{v}_{21}\\hat{v}_{13} & \\hat{v}_{21}\\hat{v}_{21} & \\color{red}{\\hat{v}_{21}\\hat{v}_{22}} & \\color{red}{\\hat{v}_{21}\\hat{v}_{23}} \\\\\n", " \\hat{v}_{22}\\hat{v}_{11} & \\hat{v}_{22}\\hat{v}_{12} & \\hat{v}_{22}\\hat{v}_{13} & \\hat{v}_{22}\\hat{v}_{21} & \\hat{v}_{22}\\hat{v}_{22} & \\color{red}{\\hat{v}_{22}\\hat{v}_{23}} \\\\\n", " \\hat{v}_{23}\\hat{v}_{11} & \\hat{v}_{23}\\hat{v}_{12} & \\hat{v}_{23}\\hat{v}_{13} & \\hat{v}_{23}\\hat{v}_{21} & \\hat{v}_{23}\\hat{v}_{22} & \\hat{v}_{23}\\hat{v}_{23} \n", " \\end{bmatrix} \\nonumber\n", "\\end{equation}\n", "```\n", "The blue elements are included for individual 1, while the red elements\n", "are included for individual 2. Only the upper diagonal elements are used\n", "in the average because of symmetry. Also note that in our example, the\n", "denominator in {eq}`eq:var_c` is equal to $6-K$, or the number of\n", "elements included in the summation minus the number of parameters\n", "estimated from the independent variables in the model. All other upper\n", "diagonal elements are ignored in this formula due to the constraints\n", "imposed by using {eq}`eq:full_varcov_matrix`, even if they\n", "are not zero!! [^2]\n", "\n", "From there, it is easy to calculate\n", "$\\hat{\\sigma}^2_\\epsilon=\\hat{\\sigma}^2_v-\\hat{\\sigma}^2_c$, and\n", "calculate $\\hat{\\Omega}$ for use in {eq}`eq:re_estimator`.\n", "\n", "### Weighted Least Squares and the Role of $\\hat{\\Omega}$\n", "\n", "To investigate how $\\sigma^2_c$ influences our estimates of\n", "$\\mathbf{b}_{RE}$. Consider a simple case where $N=2$ and $T=2$. We can\n", "write our estimate of $\\Omega$ as\n", "\n", "```{math}\n", "\\begin{equation}\n", "\\hat{\\Omega} = \\begin{bmatrix} \\hat{\\sigma}^2_{c} +\\hat{\\sigma}^2_{\\epsilon} & \\hat{\\sigma}^2_{c} & 0 & 0\\\\ \\hat{\\sigma}^2_{c} & \\hat{\\sigma}^2_{c} + \\hat{\\sigma}^2_{\\epsilon} & 0 & 0\\\\ 0 & 0 & \\hat{\\sigma}^2_{c} + \\hat{\\sigma}^2_{\\epsilon} & \\hat{\\sigma}^2_{c}\\\\ 0 & 0 & \\hat{\\sigma}^2_{c} & \\hat{\\sigma}^2_{c} + \\hat{\\sigma}^2_{\\epsilon} \n", "\\end{bmatrix}\n", "\\end{equation}\n", "```\n", "and noting that $\\hat{\\Omega}^{-1}$ can be written\n", "\n", "```{math}\n", ":label: eq:omega_inverse\n", "\\begin{equation}\n", "\\left(\\begin{array}{cccc} \\frac{\\hat{\\sigma}^2_{c} + \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}} & -\\frac{\\hat{\\sigma}^2_{c}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}} & 0 & 0\\\\ -\\frac{\\hat{\\sigma}^2_{c}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}} & \\frac{\\hat{\\sigma}^2_{c} + \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}} & 0 & 0\\\\ 0 & 0 & \\frac{\\hat{\\sigma}^2_{c} + \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}} & -\\frac{\\hat{\\sigma}^2_{c}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}}\\\\ 0 & 0 & -\\frac{\\hat{\\sigma}^2_{c}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}} & \\frac{\\hat{\\sigma}^2_{c} + \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 + 2\\, \\hat{\\sigma}^2_{c}\\, \\hat{\\sigma}^2_{\\epsilon}} \\end{array}\\right)\n", "\\end{equation}\n", "```\n", "To understand how the weighted least squares estimator works, it is\n", "worthwhile considering two cases. First, where $\\sigma^2_c = 0$ and\n", "secondly where both $\\sigma^2_{c}$ is large relative to\n", "$\\sigma^2_{\\epsilon}$.\n", "\n", "1. Case 1: No individual heterogeneity ($\\sigma^2_c = 0$)\n", "\n", " This case is depicted in the following Figure.\n", "\n", " ```{figure} /_static/lectures/panel_re/re_sigma2e_zero.png\n", " :scale: 35%\n", " :name: \n", " \n", " Case where there is no individual heterogeneity\n", " ```\n", "\t\n", " Since, $E(c_i) = 0$, if the variance of $c$ is zero, there is no\n", " individual specific heterogeneity since every $c_i=0$. In this case,\n", " notice that $\\hat{\\Omega}^{-1}$ collapses to\n", "\n", " $$\n", " \\left(\\begin{array}{cccc} \\frac{ \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 } & 0 & 0 & 0\\\\ 0 & \\frac{ \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 } & 0 & 0\\\\ 0 & 0 & \\frac{ \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 } & 0\\\\ 0 & 0 & 0 & \\frac{ \\hat{\\sigma}^2_{\\epsilon}}{{(\\hat{\\sigma}^2_{\\epsilon}})^2 } \\end{array}\\right)\n", " = \\frac{1}{\\hat{\\sigma}^2_{\\epsilon}} \\times I_{NT \\times NT}\n", " $$\n", "\n", " Consequently, the random effects estimator becomes\n", "\n", " ```{math}\n", " \\begin{align}\n", " \\mathbf{b}_{RE} &= \\mathbf{(x' \\hat{\\Omega}^{-1} x)}^{-1}\\mathbf{x' \\hat{\\Omega}^{-1} y} \\nonumber \\\\\n", " &= \\mathbf{\\left(x' \\frac{1}{\\hat{\\sigma}^2_{\\epsilon}} I x \\right)}^{-1}\\mathbf{x'} \\frac{1}{\\hat{\\sigma}^2_{\\epsilon}} \\mathbf{Iy} \\nonumber \\\\\n", " &= \\hat{\\sigma}^2_{\\epsilon}\\mathbf{\\left(x'x \\right)}^{-1}\\mathbf{x'} \\frac{1}{\\hat{\\sigma}^2_{\\epsilon}} \\mathbf{y} \\nonumber \\\\\n", " &= \\mathbf{\\left(x'x \\right)}^{-1}\\mathbf{x'} \\mathbf{y} \\nonumber \\\\\n", " &=\\mathbf{b}_{OLS}\n", " \\end{align}\n", " ```\n", " Thus, the pooled OLS estimator is the appropriate version of the\n", " random effects model, since there are no random effects. In this\n", " case, the weighted least squares estimator puts equal weight within\n", " individual observations and between individual observations.\n", "\n", "2. Case 2: Individual heterogeneity dominates($\\sigma^2_{c}$ is large\n", " relative to $\\sigma^2_{\\epsilon}$)\n", "\n", " As $\\sigma^2_c$ becomes larger, the weighted regression begins\n", " placing relatively more weight on the variation within individual\n", " observations in calculating $\\mathbf{b}_{RE}$. In the extreme case,\n", " we might consider the case where $\\sigma^2_{\\epsilon}=0$. This would\n", " lead to the following graphical representation of the data. Note\n", " that the slope coefficient can be estimated completely within each\n", " set of individual observations. As more weight is placed on\n", " \n", "\t```{figure} /_static/lectures/panel_re/re_sigma2e_zero.png\n", " :scale: 35%\n", " :name: \n", " \n", " Case where individual heterogeneity dominates\n", " ```\n", " In practice, however, there are fairly minor differences between the\n", " RE and OLS estimator. Consequently the test of OLS versus RE does\n", " not examine differences in parameter estimates since both are\n", " consistent.\n", "\n", " Since the OLS model is nested within the RE model (by restricting\n", " $\\sigma^2_c = 0$), we can use a maximum likelihood based test.\n", "\n", "## Inference\n", "\n", "With that, we can calculate the parameter estimate given in\n", "{eq}`eq:re_estimator`, having variance-covariance matrix\n", "\n", "```{math}\n", ":label: eq:re_varcov\n", "\\begin{equation}\n", " Var(\\mathbf{b}_{RE})=\\left ( \\mathbf{x}'\\hat{\\mathbf{\\Omega}} \\mathbf{x} \\right )^{-1}\n", "\\end{equation}\n", "```\n", "One might also want to use robust standard errors if the model\n", "specification (including the structure assumed in $\\Omega$) is\n", "incorrect. In this case, we can follow the methods and definition of\n", "$\\hat{\\mathbf{V}}$ outlined in Section (\\[sec:ols~h~et\\]) to write the\n", "robust random effects variance covariance estimator as\n", "\n", "```{math}\n", ":label: eq:re_robust_varcov\n", "\\begin{equation}\n", " E[Var(\\mathbf{b}_{RE})^{robust}]=\\left ( \\mathbf{x}' \\hat{\\mathbf{\\Omega}} \\mathbf{x} \\right )^{-1}\\left ( \\mathbf{x}'\\hat{\\mathbf{\\Omega}}^{-1} \\hat{\\mathbf{V}} \\hat{\\mathbf{\\Omega}} \\mathbf{x} \\right )^{-1}\\left ( \\mathbf{x}' \\hat{\\mathbf{\\Omega}} \\mathbf{x} \\right )^{-1}\n", "\\end{equation}\n", "```\n", "\n", "## Another Estimation Method\n", "\n", "The classic random effects model presented above places quite stringent\n", "restrictions on the error structure by way of the random effects\n", "definition of $\\Omega$. Further each and every realization of $c_{i}$ is\n", "assumed to impart the identical covariance structure in the errors. It\n", "may well be the case that there is serial correlation among the\n", "individual specific errors that the random effects specification above\n", "ignores. Feasible Generalized Least Squares does not rely on $\\Omega$,\n", "but rather gets full information about how the random effects influence\n", "the error structure by way of the estimated errors from the pooled OLS\n", "regression shown in {eq}`eq:pooled_resids`, and the\n", "calculation of $\\hat{v}$. Specifically, define\n", "\n", "```{math}\n", ":label: eq:omega_fgls\n", "\\begin{aligned}\n", " \\mathbf{\\hat{\\Omega}}_F=&\\frac{1}{N}\\sum^N_{i=1}\\hat{\\mathbf{v}_i}\\hat{\\mathbf{v}_i}' \\\\\n", " =&\\frac{1}{N} \\left [ \n", " \\begin{bmatrix} \\hat{v}_{11}\\hat{v}_{11} & \\hat{v}_{11}\\hat{v}_{12} & \\ldots & \\hat{v}_{11}\\hat{v}_{1T} \\\\\n", " \\hat{v}_{12}\\hat{v}_{11} & \\hat{v}_{12}\\hat{v}_{12} & \\ldots & \\hat{v}_{12}\\hat{v}_{1T} \\\\\n", " \\vdots & \\vdots & \\ddots & \\vdots \\\\\n", " \\hat{v}_{1T}\\hat{v}_{11} & \\hat{v}_{1T}\\hat{v}_{12} & \\ldots & \\hat{v}_{1T}\\hat{v}_{1T}\n", " \\end{bmatrix} + \\ldots +\n", " \\begin{bmatrix} \\hat{v}_{N1}\\hat{v}_{N1} & \\hat{v}_{N1}\\hat{v}_{N2} & \\ldots & \\hat{v}_{N1}\\hat{v}_{NT} \\\\\n", " \\hat{v}_{N2}\\hat{v}_{N1} & \\hat{v}_{N2}\\hat{v}_{N2} & \\ldots & \\hat{v}_{N2}\\hat{v}_{NT} \\\\\n", " \\vdots & \\vdots & \\ddots & \\vdots \\\\\n", " \\hat{v}_{NT}\\hat{v}_{N1} & \\hat{v}_{NT}\\hat{v}_{N2} & \\ldots & \\hat{v}_{NT}\\hat{v}_{NT}\n", " \\end{bmatrix} \n", " \\right]\n", "\\end{aligned}\n", "```\n", "where the subscript on $\\hat{v}_{it}$ denotes individual $i$ and time\n", "period $t$. Finally, calculate the parameter estimates using\n", "\n", "```{math}\n", "\\begin{equation}\n", ":label: eq:fgls_estimator\n", " \\mathbf{b_{FGLS}}=\\mathbf{(x' \\hat{\\Omega}_F^{-1} x)}^{-1}\\mathbf{x' \\hat{\\Omega}_F^{-1} y}\n", "\\end{equation}\n", "```\n", "The variance-covariance matrix of the parameters is\n", "\n", "$$Var(\\mathbf{b}_{FGLS})=\\mathbf{(x'x)^{-1}(x'\\hat{\\Omega}_Fx)(x'x)^{-1}}$$\n", "\n", "So why not always use the FGLS estimator? It is more efficient since it\n", "extracts more information about the underlying process from the data?\n", "However, if $N$ is not more than several times larger than T, than an\n", "unrestricted FGLS (where we allow for a richer variance covariance\n", "matrix for the error structure) can have poor finite sample properties\n", "since because we need to estimate $T(T+1)/2$ elements. Conversely,\n", "random effects only requires the estimation of 2 elements describing the\n", "variance/covariance structure of the error.\n", "\n", "## Random Effects Advantages\n", "\n", "So long as the exogeneity assumptions are met (perhaps a big if), the\n", "biggest advantage of the random versus fixed effects approach is that\n", "one can include *time invariant* independent variables in $\\mathbf{x}$\n", "[^3]. For example, suppose that gun control laws differed across states\n", "but were constant for a 10 year period for which you have data. The\n", "Random Effects Model allows for consistent and efficient estimate of\n", "$\\beta$ and allows you to identify the effect of the gun control laws by\n", "exploiting the variation of these laws across states. The fixed effects\n", "model which we turn to next can not identify the effects of time\n", "invariant independent variables.\n", "\n", "## Implementation in R and Stata\n", "\n", "The companion to this chapter shows how to implement many of these\n", "ideas in R and Stata.\n", "\n", "------------------------------------------------------------------------\n", "\n", "[^1]: Although the differencing approach for T=2 is identical to the\n", " more sophisticated methods we will explore in the next chapter\n", "\n", "[^2]: Another point to note is that any $\\hat{v}_{it}\\hat{v}_{it+1}$ is\n", " not assured to be zero. In extreme cases, the average obtained in\n", " {eq}`eq:var_c` might be negative which is not suitable\n", " for a variance estimate (which must be positive) and is a sign that\n", " the Random Effects estimator is not suitable or that there is\n", " autocorrelation in $\\epsilon$. Wooldridge suggests including time\n", " dummies and perhaps searching for other models if this happens.\n", " Note: Stata will report $\\sqrt(\\sigma^2_c)$ (which Stata calls\n", " \\`\\`sigma\\\\~u~\\'\\') of zero if the average using the above equation\n", " is less than or equal to zero.\n", "\n", "[^3]: Pooled OLS also has this advantage." ] } ], "metadata": { "jupytext": { "text_representation": { "extension": ".md", "format_name": "myst", "format_version": 0.13, "jupytext_version": "1.10.3" } }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.8" }, "source_map": [ 12 ] }, "nbformat": 4, "nbformat_minor": 5 }