Part 4: Fixed Effects [ 1/96] Econometric Analysis of Panel Data William Greene Department of Economics Stern School of Business Part 4: Fixed Effects [ 2/96] Estimation with Fixed Effects The fixed effects model y it = x it β + c i + ε it , o bse rva tio n fo r pe rso n i a t tim e t y i = X iβ + c ii+ ε i , T i o bse rva tio n s in gro u p i = X iβ + c i + ε i , n o te c i (c i , c i ,...,c i ) N y = X β + c + ε , i= 1 T i o bse rva tio n s in th e sa m ple N c= ( c 1 , c 2 , ...c N ) , i= 1 Ti by 1 ve cto r ci is arbitrarily correlated with xit but E[εit|Xi,ci]=0 Dummy variable representation N y it = x it β + j= 1 j d ijt + ε it , d ijt = 1 (i= j) Part 4: Fixed Effects [ 3/96] The Fixed Effects Model yi = Xi + diαi + εi, for each individual y1 y 2 yN X1 X 2 X N d1 0 0 0 d2 0 0 0 0 0 0 β ε α d N β = [X , D ] ε α = Zδ ε E[ci | Xi ] = g(Xi); Effects are correlated with included variables. Cov[xit,ci] ≠0 Part 4: Fixed Effects [ 4/96] Useful Analysis of Variance Notation D ecom position of T otal variation : N Ti 2 N Ti 2 Σ i= 1 Σ t= 1 (z it z ) Σ i= 1 Σ t= 1 (z it z i . ) N Σ i= 1 T i z i . z 2 Total variation = Within groups variation + Between groups variation Part 4: Fixed Effects [ 5/96] Baltagi and Griffin’s Gasoline Data World Gasoline Demand Data, 18 OECD Countries, 19 years Variables in the file are COUNTRY = name of country YEAR = year, 1960-1978 LGASPCAR = log of consumption per car LINCOMEP = log of per capita income LRPMG = log of real price of gasoline LCARPCAP = log of per capita number of cars See Baltagi (2001, p. 24) for analysis of these data. The article on which the analysis is based is Baltagi, B. and Griffin, J., "Gasoline Demand in the OECD: An Application of Pooling and Testing Procedures," European Economic Review, 22, 1983, pp. 117-137. The data were downloaded from the website for Baltagi's text. Part 4: Fixed Effects [ 6/96] Analysis of Variance Per Capita Gasoline Use for 18 OECD Countries 6 .5 0 6 .0 0 L GA S P C A R 5 .5 0 5 .0 0 4 .5 0 4 .0 0 3 .5 0 3 .0 0 0 2 4 6 8 10 COUNT RY 12 14 16 18 Part 4: Fixed Effects [ 7/96] Analysis of Variance SETPANEL ; Group = country ; Pds = T $ REGRESS ; Lhs=lgaspcar ; Rhs=one ; Panel $ Part 4: Fixed Effects [ 8/96] X X1 X2 D X3 X N X i1 d1 0 0 0 d2 0 0 0 d3 0 0 0 i2 iN 0 d N (T1 row s) (T 2 row s) (T3 row s) (T N row s) i= 1 Ti row s N Part 4: Fixed Effects [ 9/96] Estimating the Fixed Effects Model The FEM is a plain vanilla regression model but with many independent variables Least squares is unbiased, consistent, efficient, but inconvenient if N is large. b X X a D X X D D D 1 X y D y U sin g th e Frisc h -W a u g h th e o re m b = [ X M D X ] 1 X M D y Part 4: Fixed Effects [ 10/96] Fixed Effects Estimator (cont.) MD M 1D 0 0 0 0 (T h e d u m m y v a ria b le s a re o rth o g o n a l) N M D 0 2 MD 0 1 i M D I T d i ( d i d i ) d i = I T (1 /T i ) d i d i i i N i X M D X = i=1 X iM D X i , N i X M D y = i=1 X iM D y i , i X iM D X i i X iM D y i T k ,l t=i 1 ( x it,k -x i.,k )( x it,l -x i.,l ) T t=i 1 ( x it,k -x i.,k )( y it -y i. ) k 0 If a ll g ro u p s h a v e th e sa m e T i , M D M I w h e re M 0 X M D X = X [M I ] X a n d b = 0 X [M I ] X 1 0 0 I T (1 /T ) d d X [M I ] y . Part 4: Fixed Effects [ 11/96] The Within Transformation Removes the Effects y it x it β c i + ε it y i x iβ c i + ε i y it y i ( x it - x i ) β ( ε it ε i ) y it x it β ε it Wooldridge notation for data in deviations from group means Part 4: Fixed Effects [ 12/96] Least Squares Dummy Variable Estimator b is obtained by ‘within’ groups least squares (group mean deviations) Normal equations for a are D’Xb+D’Da=D’y a = (D’D)-1D’(y – Xb) Ti a i = (1 /T i )Σ t= 1 (y it - x it b )= e i Notes: This is simple algebra – the estimator is just OLS Least squares is an estimator, not a model. (Repeat twice.) Note what ai is when Ti = 1. Follow this with yit-ai-xit’b=0 if Ti=1. Part 4: Fixed Effects [ 13/96] Inference About OLS Assume strict exogeneity: Cov[εit,(xjs,cj)]=0. Every disturbance in every period for each person is uncorrelated with variables and effects for every person and across periods. Now, it’s just least squares in a classical linear regression model. Asy.Var[b] = ( 2 / Ni= 1 Ti )plim[( 2 / Ni= 1 Ti ) Ni= 1 X iM Di X i ] 1 w h ich is th e u su a l e stim a to r fo r O LS T N 2 ˆ i= 1 t=i 1 ( y it -a i -x it b ) N i= 1 Ti - N - K 2 (N o te th e degrees o f freedo m co rrectio n ) Part 4: Fixed Effects [ 14/96] Application Cornwell and Rupert Part 4: Fixed Effects [ 15/96] LSDV Results Note huge changes in the coefficients. SMSA and MS change signs. Significance changes completely! Pooled OLS Part 4: Fixed Effects [ 16/96] The Effect of the Effects Part 4: Fixed Effects [ 17/96] On Computation “Sometimes it is useful to obtain the cˆi even when the (dummy variable) regression is infeasible.” (W: p. 273) It is never infeasible. The degrees of freedom correction must include the constants (N of them). Part 4: Fixed Effects [ 18/96] The Estimated Fixed Effects Fre que nc y Fixed E ffects fr om C or nw ell and R uper t W age M odel .8 5 6 1 .6 8 8 2 .5 2 0 3 .3 5 1 4 .1 8 3 AI 5 .0 1 5 5 .8 4 7 6 .6 7 8 Part 4: Fixed Effects [ 19/96] A Kernel Density Estimator * x x i m ˆf ( x * ) K m i1 n h h 1 n 1 * , fo r a se t o r p o in ts x m h " b a n d w id th " ch o se n b y th e a n a lyst. A c o m m o n ch o ice is S ilv e rm a n 's ru le o f th u m b = 1 .0 6 ˆ x /n 1/ 5 K th e k e rn e l fu n ctio n , su ch a s th e n o rm a l o r lo g istic d e n sity (o r o n e o f se v e ra l o th e rs) x* th e p o in t a t w h ich th e d e n sity is a p p ro xim a te d . Part 4: Fixed Effects [ 20/96] Examining the Effects with a KDE Fixed Effects from Cornwell and Rupert Wage Model .3 4 5 .2 7 6 D e n s i ty .2 0 7 .1 3 8 .0 6 9 .0 0 0 0 1 2 3 4 5 6 AI Ke rn e l d e n s i ty e s ti m a te fo r AI Mean = 4.819, standard deviation = 1.054. 7 Part 4: Fixed Effects [ 21/96] Histogram vs. KDE Fixed E ffects fr om C or nw ell and R uper t W age M odel Fixed Effects from Cornwell and Rupert Wage Model .3 4 5 .2 7 6 D e n s i ty Fre que nc y .2 0 7 .1 3 8 .0 6 9 .0 0 0 0 1 2 3 4 5 6 7 AI .8 5 6 1 .6 8 8 2 .5 2 0 3 .3 5 1 4 .1 8 3 5 .0 1 5 5 .8 4 7 6 .6 7 8 Ke rn e l d e n s i ty e s ti m a te fo r AI AI CREATE ; ID=TRN(7,0)$ SETPANEL ; GROUP=ID ; PDS=TI $ REGRESS ;lhs=lwage;rhs=occ,smsa,ms,exp ; panel ; fixed $ ? Creates 595 by 1 matrix named ALPHAFE HISTOGRAM; rhs=alphafe ;title=Fixed Effects from Cornwell and Rupert Wage Model$ KERNEL;rhs=alphafe ; title=Fixed Effects from Cornwell and Rupert Wage Model$ Part 4: Fixed Effects [ 22/96] A Caution About Stata and R2 R squared = 1 - R esidual S um of S quares T otal S um of S quares For the FE model above, O r is it? W hat is the total sum of squa res? C onventional: T otal S um of S quares = "W ithin S um of S quares" = N i 1 N i 1 W hich should appear in the denom inator o f R Ti Ti t 1 t 1 y it y y it yi 2 R2 = 0.90542 areg 2 R2 = 0.65142 xtreg fe 2 The coefficient estimates and standard errors are the same. The calculation of the R 2 is different. In the areg procedure, you are estimating coefficients for each of your covariates plus each dummy variable for your groups. In the xtreg, fe procedure the R reported is obtained by only fitting a 2 mean deviated model where the effects of the groups (all of the dummy variables) are assumed to be fixed quantities. So, all of the effects for the groups are simply subtracted out of the model and no attempt is made to quantify their overall effect on the fit of the model. Since the SSE is the same, the R2=1−SSE/SST is very different. The difference is real in that we are making different assumptions with the two approaches. In the xtreg, fe approach, the effects of the groups are fixed and unestimated quantities are subtracted out of the model before the fit is performed. In the areg approach, the group effects are estimated and affect the total sum of squares of the model under consideration. Part 4: Fixed Effects [ 23/96] Robustness of the LSDV Estimator Under the full Gauss-Markov assumptions, b is unbiased and consistent (and even efficient). If Var[εi] = Ωi ≠ε2ITi then b is consistent but inefficient. (We’ll return to robust estimation below.) Under all assumptions, Var[ai] is O(1/Ti). ai is unbiased but inconsistent. Inconsistent not because it estimates the wrong parameter, but because it converges to a random variable, not a constant. Ti is not increasing. Part 4: Fixed Effects [ 24/96] Robust Counterpart to White Estimator? Assumes Var[εi] = Ωi ≠2ITi ei = yi – aiiTi - Xib = MDyi – MDXib (Ti x 1 vector of group residuals) N i E st.A sy.V ar[ b ]= i= 1 X iM D X i H 1 1 Ni= 1 ( X iM Di e i )( e iM Di X i ) Ni= 1 X iM Di X i N Ti i= 1 t= 1 ( x it x i )e it 1 T t=i 1 ( x it x i )e it H T N H i= 1 t=i 1 ( x it x i )( x it x i ) Resembles (and is based on) White, but treats a full vector of disturbances at a time. Robust to heteroscedasticity and autocorrelation (within the groups). 1 Part 4: Fixed Effects [ 25/96] Robust Covariance Matrix for LSDV Cluster Estimator for Within Estimator Part 4: Fixed Effects [ 26/96] Asymptotics for ai 1 a i ( d i d i ) d i ( y i X ib ) fro m th e L S n o rm a l e q u a tio n s = y i x ib = (y i x iβ ) - x i ( b - β ) = i + i - x i ( b - β ) E [a i | X ] i 0 0 = i ( b is u n b ia se d ) 2 V a r[a i | X ] 0 / T i x i V a r[( b - β ) | X ] x i lim N E [a i | X ] i 2 lim N V a r[a i | X ] / T i + 0 ( b is co n siste n t so V a r[ ( b - β ) | X ] 0 ) 2 (S e e slid e 1 3 , lim N N i 1 Ti = 0) Part 4: Fixed Effects [ 27/96] LSDV is an IV Estimator y it x it β c i + ε it x it β ( c i + ε it ) x it β w it C ov [ x it , w it ] C ov [ x it , ( c i + ε it )] g ( x it ) 0 x it is corre la te d w ith th e F E s e m b e d d e d in w it Part 4: Fixed Effects [ 28/96] y it x it β c i + ε it (1 ob se rv a tion ) y i X iβ c i d i + ε i (T i ob se rv a tion s) y i X iβ w i y ( i T i ob se rv a tion s) Xβ w p lim ( b )= p lim X X 1 X y X X = β p lim N i= 1 T i X X = β p lim N i= 1 T i X X = β p lim N T i= 1 i X X = β p lim N T i= 1 i N ote Ti N i= 1 T i = 1 N 1 1 1 1 p lim N i= 1 T i N i= 1 x it c i t= 1 Ti N 1 Ti p lim c i N i= 1 T Ti i= 1 i t 1 x it Ti N Ti p lim c x i i. N i= 1 T i= 1 i 1 N p lim fi c i x i. i= 1 if b a la n ce d p a n e l N 0 < fi < 1 , i= 1 fi 1 Part 4: Fixed Effects [ 29/96] MD M 1D 0 0 0 0 (T h e d u m m y variab les are orth og on al) N MD 0 2 MD 0 1 i M D I T d i ( d id i ) d i = I T (1 /T i ) d i d i i i N i X M D X = i=1 X iM D X i , N i X M D y = i=1 X iM D y i , i X iM D X i X M i i yi D k,l k T t=i 1 ( x it,k -x i.,k )( x it,l -x i.,l ) T t=i 1 ( x it,k -x i.,k )( y it -y i. ) Part 4: Fixed Effects [ 30/96] b LS D V X M D X 1 X M D y D e fin e Z = M D X . b LS D V Z X 1 Z y (L o o k s lik e a n IV e stim a to r.) Z X (1 ) P lim 0? Σ i Ti i P lim X iM D X i T i ( x -x )( x -x ) t= 1 it,k i.,k it,l i.,l k,l N o n sin g u la r P D m a trix if th e r e is n o m u ltico llin e a rity a n d if e v e ry co lu m n o f X h a s w ith in g ro u p v a ria t io n . Z w (2 ) P lim = 0? Σ i Ti Σ i X iM Di ( c ii i ) Z w P lim P lim Σ T Σ T i i i i i c iM D i = 0 b e ca u se i h a s n o w ith in g ro u p v a ria tio n 1 Σ i Ti P lim Σ X M i i i D i 0 b y th e a ssu m p tio n o f th e m o d e l. Part 4: Fixed Effects [ 31/96] LSDV is a Control Function Estimator y it x it β c i + ε it x it β (c i + ε it ) x it β w it C ov [ x it , w it ] C ov [ x it , (c i + ε it )] g ( x it ) 0 x it is corre la te d w ith th e F E s e m b e d d e d in w it . L S re g re ssion of y on X is in con siste n t b e ca u se X is corre la te d w ith w . W e se e k a con trol fu n ction h (.) su ch th a t X | h (.) is u n corre la te d w ith w . (In th e p re se n ce of h (.), X is n ot corre la te d w ith w .) U sin g th e F risch -W a u g h th e ore m b = [ X M D X ] 1 X M D y C on sid e r re g re ssion of y on [ X , X ]. I.e ., a d d g rou p m e a n s to th e re g re ssion . Part 4: Fixed Effects [ 32/96] LSDV is a Control Function Estimator C on sid er reg ression of y on [ X , X ]. I.e., ad d g rou p m ean s to th e reg ression . x 11 x 21 [ X ,X ] x N1 x 12 x 1K x 1 1 .i1 x 1 2 .i1 x 22 x 2K x 2 1 .i 2 x 2 2 .i 2 x N2 x NK x N1 .iN x N 2 .iN = [X , (I-M D ) X ] = [ X , PD X ] = [ X ,F ] x 1 1 i1 x 1 1i2 x N K .iN Part 4: Fixed Effects [ 33/96] LSDV is a Control Function Estimator U sin g th e F risch -W a u g h th e ore m b C on trolF u n ction = [ X M F X ] 1 X M F y 1 X M F X X [ I F ( F F ) F ] X X [ I PD X ( X PD PD X ) 1 X PD ] X PD is sym m e tric a n d id e m p ote n t. A n d PD = I - M D X [ I ( I - M D ) X ( X ( I - M D ) X ) 1 X ( I - M D ) ] X M u ltip ly th is ou t in fu ll a n d colle ct so m e te rm s = X IX - X ( I - M D ) X X ( I - M D ) X 1 X ( I - M D ) X T h e tw o la rg e m a trice s ca n ce l. O n e m ore ste p = X X - X ( I - M D ) X = X X - X X + X M D X = X M D X . Like w ise , X M F y X M D y . T h e re fore , b C on trolF u n ction = b LS D V Part 4: Fixed Effects [ 34/96] Note the usual problem with control function estimators. The standard errors need to be corrected. Part 4: Fixed Effects [ 35/96] The problem here is the estimator of the disturbance variance. The matrix is OK. Note, for example, .01374007/.01950085 (top panel) = .16510 /.23432 (bottom panel). Part 4: Fixed Effects [ 36/96] Part 4: Fixed Effects [ 37/96] Generalized Least Squares? If Var[εi] = Ωi ≠ε2ITi then b is consistent but inefficient. ˆ = [ X Ω -1 X ] 1 [ X Ω -1 y ] G LS : β N -1 -1 N -1 = [ i= 1 X i Ω i X i ] [ i= 1 X i Ω i y i ] E stim a te Ω ? N (1 ) B a la n ce d pa n e l ca se : (1 /N ) i= 1 e i e i fro m fix e d e ffe cts (2 ) U n ba la n ce d ca se ? P u t ze ro s in e i in a ppro pria te pla ce s? E le m e n ts o f Ωˆ a re n o w ba se d o n diffe re n t T . i ˆ is T x T w ith ra n k a t m o st N . If T > N , Ω ˆ is N o te Ω sin gu la r a n d G LS ca n n o t be co m pu te d. N w ill be > > T . Part 4: Fixed Effects [ 38/96] Maximum Likelihood Estimation W ith n orm a lly d istrib u te d d istu rb a n ce s, th e F E m od e l is th e ord in a ry cla ssica l n orm a l lin e a r re g re ss ion m od e l. O L S is th e m a x im u m lik e lih ood e stim a tor of β . T h e m a x im u m lik e lih ood 2 e stim a tor of is T N 2 ˆ 2 i 1 t i 1 e it Ti t 1 Ti , th e u su a l m e a n sq u a re d re sid u a l, w ith n o corre ction for d e g re e s of fre e d om . F rom sta n d a rd re su lts for th e lin e a r m od e l (e .g ., G re e n e , p . 5 1 ), th e e x a ct e x p e cta tion is 2 2 E[ ˆ ] ( Ni 1 T i ) N K 1 K 1 N K 2 2 1 1 N N T T T T N i1 i i1 Part 4: Fixed Effects [ 39/96] ML Estimation (cont.) 2 2 E[ ˆ ] ( Ni 1 T i ) N K 1 K 1 N K 2 2 1 1 N N N T T T T i1 i i1 2 T h is is a 're g u la r' p rob le m , so ˆ con v e rg e s to a p rob a b ility lim it - it is con siste n t for som e th in g . N ote , a s 2 2 N in cre a se s, ˆ con v e rg e s to [1 - 1 /T ]. T (or T i ) is 2 fix e d in th is m od e l. S o, ˆ is n o t a con sist e n t e stim a tor 2 of u n le ss T in cre a se s. S u p p ose T i 2 . T h e n 2 2 p lim ˆ 2 . T h e in con siste n cy d oe s n o t g o a w a y a s N in cre a se s. T h is is T H E e x a m p le of th e I n c id e n ta l P a ra m e te rs P ro b le m . (N e y m a n a n d S cott (1 9 4 8 ). It occu rs b e ca u se th e n u m b e r of p a ra m e te rs b e in g e stim a te d is g row in g a s N g row s. Part 4: Fixed Effects [ 40/96] Between Groups Estimator Inconsistency of the group means estimator y i x iβ c i + ε i = x iβ w i C o v [w i , x i ] C o v [c i + ε i , x ] 0 Part 4: Fixed Effects [ 41/96] Time Invariant Regressors Time invariant xit is defined as invariant for all i. E.g., SEX dummy variable. ED (education in the Cornwell/Rupert data). If xit,k is invariant for all i, then xit,k = ihidi for the set of dummy variables and some set of his. If xit,k is invariant for all i, then the group mean deviations are all 0. Part 4: Fixed Effects [ 42/96] FE With Time Invariant Variables +----------------------------------------------------+ | There are 2 vars. with no within group variation. | | FEM ED | +----------------------------------------------------+ +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |b/St.Er.|P[|Z|>z]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ EXP | .09671227 .00119137 81.177 .0000 19.8537815 WKS | .00118483 .00060357 1.963 .0496 46.8115246 OCC | -.02145609 .01375327 -1.560 .1187 .51116447 SMSA | -.04454343 .01946544 -2.288 .0221 .65378151 FEM | .000000 ......(Fixed Parameter)....... ED | .000000 ......(Fixed Parameter)....... +--------------------------------------------------------------------+ | Test Statistics for the Classical Model | +--------------------------------------------------------------------+ | Model Log-Likelihood Sum of Squares R-squared | |(1) Constant term only -2688.80597 886.90494 .00000 | |(2) Group effects only 27.58464 240.65119 .72866 | |(3) X - variables only -1688.12010 548.51596 .38154 | |(4) X and group effects 2223.20087 83.85013 .90546 | +--------------------------------------------------------------------+ Part 4: Fixed Effects [ 43/96] Drop The Time Invariant Variables Same Results +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |b/St.Er.|P[|Z|>z]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ EXP | .09671227 .00119087 81.211 .0000 19.8537815 WKS | .00118483 .00060332 1.964 .0495 46.8115246 OCC | -.02145609 .01374749 -1.561 .1186 .51116447 SMSA | -.04454343 .01945725 -2.289 .0221 .65378151 +--------------------------------------------------------------------+ | Test Statistics for the Classical Model | +--------------------------------------------------------------------+ | Model Log-Likelihood Sum of Squares R-squared | |(1) Constant term only -2688.80597 886.90494 .00000 | |(2) Group effects only 27.58464 240.65119 .72866 | |(3) X - variables only -1688.12010 548.51596 .38154 | |(4) X and group effects 2223.20087 83.85013 .90546 | +--------------------------------------------------------------------+ No change in the sum of squared residuals Efficient Estimation of Time Invariant and Rarely Changing Variables in Finite Sample Panel Analyses with Unit Fixed Effects Thomas Plümper and Vera Troeger Political Analysis, 2007 Part 4: Fixed Effects [ 45/96] Introduction: The Pledge [T]he FE model … does not allow the estimation of time invariant variables. A second drawback of the FE model … results from its inefficiency in estimating the effect of variables that have very little within variance. This article discusses a remedy to the related problems of estimating time invariant and rarely changing variables in FE models with unit effects Part 4: Fixed Effects [ 46/96] The Model y it = α i + K k =1 β k x kit + M m =1 m z m i + ε it w h e re α i d e n o te th e N u n it e ffe cts. Part 4: Fixed Effects [ 47/96] Fixed Effects Vector Decomposition Step 1: Compute the fixed effects regression to get the “estimated unit effects.” “We run this FE model with the sole intention to obtain estimates of the unit effects, αi.” FE αˆ i = y i - k =1 b k x k i K Part 4: Fixed Effects [ 48/96] Step 2 Regress ai on zi and compute residuals ai = M m =1 m z im + h i h i is o rth o g o n a l to z i (sin ce it is a re sid u a l) V e cto r h i is e xp a n d e d so e a ch e le m e n t h i is re p lica te d Ti tim e s - h is th e le n g th o f th e fu ll sa m p le . Part 4: Fixed Effects [ 49/96] Step 3 Regress yit on a constant, X, Z and h using ordinary least squares to estimate α, β, γ, δ. y it = α + K k =1 β k x kit + M m =1 m z m i + δ h i + ε it N otice that i in the original m odel has becom e + h i in the revised m odel. Part 4: Fixed Effects [ 50/96] The Turn: Based on Cornwell and Rupert namelist ; x = exp,wks,occ,ind,south,smsa,union ; z = fem,ed $ (1) Step 1. regress ; lhs=lwage;rhs=x,z;panel;fixed;pds=7 $ create ; uhi = alphafe(_stratum) $ (2) Step 2 regress ; lhs = uhi ; rhs = one,z ; res = hi $ (3) Step 3. regress ; lhs = lwage ; rhs = one,x,z,hi $ Part 4: Fixed Effects [ 51/96] Step 1 (Based on full sample) These 2 variables have no within group variation. FEM ED F.E. estimates are based on a generalized inverse. --------+--------------------------------------------------------| Standard Prob. Mean LWAGE| Coefficient Error z z>|Z| of X --------+--------------------------------------------------------EXP| .09663*** .00119 81.13 .0000 19.8538 WKS| .00114* .00060 1.88 .0600 46.8115 OCC| -.02496* .01390 -1.80 .0724 .51116 IND| .02042 .01558 1.31 .1899 .39544 SOUTH| -.00091 .03457 -.03 .9791 .29028 SMSA| -.04581** .01955 -2.34 .0191 .65378 UNION| .03411** .01505 2.27 .0234 .36399 FEM| .000 .....(Fixed Parameter)..... .11261 ED| .000 .....(Fixed Parameter)..... 12.8454 --------+--------------------------------------------------------- Part 4: Fixed Effects [ 52/96] Step 2 (Based on 595 observations) --------+--------------------------------------------------------| Standard Prob. Mean UHI| Coefficient Error z z>|Z| of X --------+--------------------------------------------------------Constant| 2.88090*** .07172 40.17 .0000 FEM| -.09963** .04842 -2.06 .0396 .11261 ED| .14616*** .00541 27.02 .0000 12.8454 --------+--------------------------------------------------------- Part 4: Fixed Effects [ 53/96] Step 3! --------+--------------------------------------------------------| Standard Prob. Mean LWAGE| Coefficient Error z z>|Z| of X --------+--------------------------------------------------------Constant| 2.88090*** .03282 87.78 .0000 EXP| .09663*** .00061 157.53 .0000 19.8538 WKS| .00114*** .00044 2.58 .0098 46.8115 OCC| -.02496*** .00601 -4.16 .0000 .51116 IND| .02042*** .00479 4.26 .0000 .39544 SOUTH| -.00091 .00510 -.18 .8590 .29028 SMSA| -.04581*** .00506 -9.06 .0000 .65378 UNION| .03411*** .00521 6.55 .0000 .36399 FEM| -.09963*** .00767 -13.00 .0000 .11261 ED| .14616*** .00122 120.19 .0000 12.8454 HI| 1.00000*** .00670 149.26 .0000 -.103D-13 --------+--------------------------------------------------------- Part 4: Fixed Effects [ 54/96] Part 4: Fixed Effects [ 55/96] Part 4: Fixed Effects [ 56/96] http://davegiles.blogspot.com/2012/06/fixed-effects-vector-decomposition.html Part 4: Fixed Effects [ 57/96] Paul Allison, 2005 Part 4: Fixed Effects [ 58/96] What happened here? y it = α i + K k =1 β k x k it + M m =1 m z m i + ε it w h e re α i d e n o te th e N u n it e ffe c ts . A n a s s u m p tio n is a d d e d a lo n g th e w a y C o v (α i , Z i ) = 0 . T h is is e x a c tly th e n u m b e r o f o rth o g o n a lity a s s u m p tio n s n e e d e d to id e n tify . It is n o t p a rt o f th e o rig in a l m o d e l. Part 4: Fixed Effects [ 59/96] Two Way Fixed Effects A two way FE model. Individual dummy variables and time dummy variables. yit = αi + t + xit’β + εit Normalization needed as the individual and time dummies both sum to one. Reformulate model: yit = μ + αi* + t* + xit’β + εit with i αi* =0, t t* = 0 y it y it y i . y. t y Full estimation: Practical estimation. Add T-1 dummies Complication: Unbalanced panels are complicated Complication in recent applications: Vary large N and very large T Part 4: Fixed Effects [ 60/96] Fixed Effects Estimators Slope estimators, as usual with transformed data ˆ = y- x b μ ˆ α i * ( y i . y ) ( x i . x ) b ˆ t * ( y.t y ) ( x . t x ) b Part 4: Fixed Effects [ 61/96] Two Way Fixed Effects Application Spanish Dairy Farms; N=247, T=6 +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |b/St.Er.|P[|Z|>z]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ No Effects Constant| 11.5774868 .00364586 3175.515 .0000 X1 | .59517558 .01958331 30.392 .0000 0 X2 | .02305014 .01122274 2.054 .0400 0 X3 | .02319244 .01303099 1.780 .0751 0 X4 | .45175783 .01078465 41.889 .0000 0 Firm Dummies X1 | .66200103 .02467845 26.825 .0000 0 X2 | .03735244 .01613309 2.315 .0206 0 X3 | .03039947 .02320776 1.310 .1902 0 X4 | .38251038 .01201690 31.831 .0000 0 Firm and Time Dummies X1 | .63796531 .02379854 26.807 .0000 0 X2 | .04127557 .01544463 2.672 .0075 0 X3 | .02819226 .02217322 1.271 .2036 0 X4 | .30816028 .01322571 23.300 .0000 0 REGRESS ; Lhs = yit ; Rhs = one,x1,x2,x3,x4 ; pds=6 ; period=t $ Marginal changes in the estimates. Why? Part 4: Fixed Effects [ 62/96] Analysis of Variance (FIT) +--------------------------------------------------------------------+ | Test Statistics for the Classical Model | +--------------------------------------------------------------------+ | Model Log-Likelihood Sum of Squares R-squared | |(1) Constant term only -1448.90832 .6131518321D+03 .0000000 | |(2) Group effects only 412.25944 .4974526192D+02 .9188696 | |(3) X - variables only 809.67611 .2909570093D+02 .9525473 | |(4) X and group effects 1751.64437 .8161093811D+01 .9866899 | |(5) X ind.&time effects 1826.23878 .7379537558D+01 .9879646 | +--------------------------------------------------------------------+ | Hypothesis Tests | | Likelihood Ratio Test F Tests | | Chi-squared d.f. Prob. F num. denom. P value | |(2) vs (1) 3722.336 246 .00000 56.859 246 1235 .00000 | |(3) vs (1) 4517.169 4 .00000 7412.185 4 1477 .00000 | |(4) vs (1) 6401.105 250 .00000 365.021 250 1231 .00000 | |(4) vs (2) 2678.770 4 .00000 1568.114 4 1231 .00000 | |(4) vs (3) 1883.937 246 .00000 12.836 246 1231 .00000 | |(5) vs (4) 149.189 5 .00000 25.969 5 1226 .00000 | |(5) vs (3) 2033.125 252 .00000 14.317 252 1226 .00000 | +--------------------------------------------------------------------+ Part 4: Fixed Effects [ 63/96] Unbalanced Panel Data (First 10 households in healthcare data) Ti zi . t 1 z it Nt z.t i 1 z it Part 4: Fixed Effects [ 64/96] Two Way FE with Unbalanced Data T h is co m p u ta tio n is n o t a p p ro p ria te in t w o w a y F E m o d e ls w ith u n b a la n ce d p a n e ls: N b= i1 N i1 ˆ μ Ti t 1 Ti t 1 ( x it - x i . - x .t x )( x it - x i . - x .t x ) 1 ( x it - x i . - x .t x )( y it - y i . - y. t y ) = y - x b ˆ α i * ( y i . y ) ( x i . x ) b ˆ t * ( y.t y ) ( x . t x ) b T h e m o d e l m u st b e fit a s a o n e w a y F E M w ith tim e d u m m y v a ria b le s Part 4: Fixed Effects [ 65/96] y it y it y i . y.t y an d likew ise for x it . D oes n ot w ork correctly for u n balan ced p an els. Fit tw o w ay m odels as on e w ay w ith tim e du m m ies. Part 4: Fixed Effects [ 66/96] Textbook formula application. This is incorrect. Two way fixed effects as one way with time dummies Part 4: Fixed Effects [ 67/96] Different Normalizations Separate constants: using D Overall constant and N-1 constrasts Overall constant, N constants, i i = 0 y = X β + D α+ ε = X β+ C α * + ε 1 = y , s o C α * = D α = (D P )(P α ) Part 4: Fixed Effects [ 68/96] Renormalizing Fixed Effects N Dummy Variables vs. a Constant and N-1 Dummy Variables U se 4 g ro u p s fo r e x a m p le i 0 D 0 0 i i C i i 0 0 i 0 0 i 0 0 0 0 i 0 0 i 0 0 0 0 0 i 0 1 0 1 D 1 0 i 1 P 0 0 1 0 0 1 0 0 0 0 DP 0 1 1 1 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 -1 P a = α 1 , α 2 α 1 , α 3 α 1 , ..., α N α 1 Implication: No change in other coefficients, no change in sum of squares or R2 Part 4: Fixed Effects [ 69/96] A “Hierarchical” Model L o w e r le v e l stru ctu ra l m o d e l y it x it β c i + ε it U p p e r le v e l m o d e l fo r e ffe cts c i z i δ + w i H o w d o e s th is a ffe ct th e fix e d e ffe cts m o d e l? y it x it β α i + ε it N o ch a n g e in th e m o d e l, b u t it in v ite s a se co n d ste p . Part 4: Fixed Effects [ 70/96] Estimating a Hierarchical Model Classical assumptions at both levels 2 y it x it β c i + ε it , E [ε it | X i , c i ] 0 , V a r[ε it | X i , c i ]= , e tc. 2 c i z i δ + w i , E [w i| z i ] 0 , V a r[w i| z i ]= w Two step estimation Fixed effects, dummy variables at top level Regress ai on zi to estimate δ at the 2nd level. The regression is heteroscedastic. Use OLS/White or Weighted LS with ˆ i c i ) c i v i z i δ (w i v i ) a i c i (c 2 i i A sy.V a r[a i | X i , z i ] [ / T i ] x it ( I - M D ) A sy.V a r[ b ]( I M D ) x it 2 = [ / T i ] x i A sy.V a r[ b ] x i Part 4: Fixed Effects [ 71/96] A Two Step Regression Sample ; all$ Create ; person=trn(7,0) ; year=trn(-7,0)$ Namelist; varyingX=occ,smsa,ms,exp$ Namelist; fixedX=one,fem,ed$ ? FE regression to compute dummy variable coefficients Regress ; lhs=lwage ; rhs=varyingX ; panel ; fixed ; pds=7$ Create ; ai=alphafe(person)$ Create ; occb= GroupMean(occ,pds=7)$ Create ; msb = GroupMean(ms,pds=7)$ Create ; smsab=GroupMean(smsa,pds=7)$ Create ; expb= GroupMean(exp,pds=7)$ ? Standard errors for dummy variable coefficient estimates Namelist; means=occb,smsab,msb,expb$ Create ; varai=ssqrd/_Groupti + qfr(means,varb) ; wt=1/varai$ ? Weighted least squares regression of dummy variable coefficients ? on time invariant variables. Regress ; if[year = 7] ; lhs=ai;rhs=FixedX;wts=wt$ Regress ; if[year = 7] ; lhs=ai;rhs=FixedX;Het $ Part 4: Fixed Effects [ 72/96] First Stage Fixed Effects Model Part 4: Fixed Effects [ 73/96] Second Stage Regressions Weighted Least Squares OLS with White Estimator Part 4: Fixed Effects [ 74/96] Hierarchical Linear Model as REM +--------------------------------------------------+ | Random Effects Model: v(i,t) = e(i,t) + u(i) | | Estimates: Var[e] = .235368D-01 | | Var[u] = .110254D+00 | | Corr[v(i,t),v(i,s)] = .824078 | | Sigma(u) = 0.3303 | +--------------------------------------------------+ +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |b/St.Er.|P[|Z|>z]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ OCC | -.03908144 .01298962 -3.009 .0026 .51116447 SMSA | -.03881553 .01645862 -2.358 .0184 .65378151 MS | -.06557030 .01815465 -3.612 .0003 .81440576 EXP | .05737298 .00088467 64.852 .0000 19.8537815 FEM | -.34715010 .04681514 -7.415 .0000 .11260504 ED | .11120152 .00525209 21.173 .0000 12.8453782 Constant| 4.24669585 .07763394 54.702 .0000 Part 4: Fixed Effects [ 75/96] Hierarchical Linear Model y it x it β c i + ε it , ( x d o e s n o t co n ta in a co n sta n t) 2 E [ε it | X i , c i ] 0 , V a r[ε it | X i , c i ]= c i + z i δ + w i , 2 E [w i| z i ] 0 , V a r[w i| z i ] w y it x it β [ z i δ w i ] ε it Part 4: Fixed Effects [ 76/96] HLM (Simulation Estimator) vs. REM ---------+ Nonrandom parameters OCC | -.02461285 .00566374 -4.346 .0000 .51116447 SMSA | -.06076787 .00490494 -12.389 .0000 .65378151 MS | -.04446541 .00850068 -5.231 .0000 .81440576 EXP | .08508257 .00046901 181.409 .0000 19.8537815 ---------+ Means for random parameters Constant| 2.89358963 .02426391 119.255 .0000 ---------+ Scale parameters for dists. of random parameters Constant| .86092728 .00448368 192.014 .0000 ---------+ Heterogeneity in the means of random parameters cONE_FEM| -.54972521 .01030773 -53.331 .0000 cONE_ED | .16915125 .00122320 138.286 .0000 ======================================================================== ---------+Variance parameter given is sigma Std.Dev.| .15681703 .00074231 211.256 .0000 (REM Estimated by two step FGLS) Sigma(u) = 0.3303 OCC | -.03908144 .01298962 -3.009 .0026 .51116447 SMSA | -.03881553 .01645862 -2.358 .0184 .65378151 MS | -.06557030 .01815465 -3.612 .0003 .81440576 EXP | .05737298 .00088467 64.852 .0000 19.8537815 FEM | -.34715010 .04681514 -7.415 .0000 .11260504 ED | .11120152 .00525209 21.173 .0000 12.8453782 Constant| 4.24669585 .07763394 54.702 .0000 Part 4: Fixed Effects [ 77/96] Mundlak’s Approach y it x it β + z i δ c i + ε it , ( x do e s n o t co n ta in a co n sta n t) 2 E [ε it | X i , c i ] 0 , V a r[ε it | X i , c i ]= c i + x i + w i , 2 E [w i| X i , z i ] 0 , V a r[w i| X i , z i ] w y it x it β z i δ x i w i ε it = ra n do m e ff e cts m o de l in clu din g gro u p m e a n s. Part 4: Fixed Effects [ 78/96] Mundlak Form of FE Model +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |b/St.Er.|P[|Z|>z]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ x(i,t) OCC | -.02021384 .01375165 -1.470 .1416 .51116447 SMSA | -.04250645 .01951727 -2.178 .0294 .65378151 MS | -.02946444 .01915264 -1.538 .1240 .81440576 EXP | .09665711 .00119262 81.046 .0000 19.8537815 z(i) FEM | -.34322129 .05725632 -5.994 .0000 .11260504 ED | .05099781 .00575551 8.861 .0000 12.8453782 Means of x(I,t) and constant Constant| 5.72655261 .10300460 55.595 .0000 OCCB | -.10850252 .03635921 -2.984 .0028 .51116447 SMSAB | .22934020 .03282197 6.987 .0000 .65378151 MSB | .20453332 .05329948 3.837 .0001 .81440576 EXPB | -.08988632 .00165025 -54.468 .0000 19.8537815 Estimates: Var[e] = .0235632 Var[u] = .0773825 Part 4: Fixed Effects [ 79/96] Application Passmore,W. et al., “The Effect of Housing Government Sponsored Enterprises on Mortgage Rates,” Federal Reserve Board, Division of Research & Statistics and Monetary Affairs, 2004, rev. 1/2005 Part 4: Fixed Effects [ 80/96] First Stage – Rate Difference M o rtga ge R a te i,t 0 + " lo a n to va lu e ra tio te rm s " + "n e w h o m e " (du m m y va ria ble ) + "sm a ll lo a n " (du m m y va ria ble ) + "u p fro n t fe e s pa id" (du m m y va ria ble ) + "m o rtga ge ba n k" vs. de po sito ry in st. (du m m y va ria ble ) + α 1 ,i J u m b o L o a n i,t( d u m m y v a ria b le fo r lo a n > $ 31 7 , 0 0 0 ) + i,t " i " = sta te ,ye a r gro u pin g "t"= in dividu a l lo a n in spe cifie d sta te ,ye a r N e a rly a ll "co n fo rm in g" lo a n s (u n de r $ 3 1 7 ,0 0 0 ) a re h e ld by Fa n n ie M a e . E x pe ct 1 ,i to be > 0 a s Fa n n ie M a e is a ble to fin a n ce a t lo w e r co st th a n o th e r in stitu tio n s, a n d Fa n n ie M a e do e s n o t fin a n ce Ju m bo lo a n s. In te re st is in "pa ss th ro u gh " o f th e co st a dva n ta ge . Part 4: Fixed Effects [ 81/96] An Algebraic Aspect Ji is not quite a group dummy variable. For the group, Ji is one for some members of the group – those with a “jumbo” mortgage. i M J I J i ( J i J i ) J i i M J y i y i J i * m e a n o f th o se w ith ju m bo lo a n s y it y it y i, ju m bo if ju m bo lo a n if n o t a ju m bo lo a n y it O th e rw ise , th is co u ld be tre a te d like a fixe d e ffe cts m o de l. Part 4: Fixed Effects [ 82/96] Second Stage – Pass Through a 1 ,i = 0 + 1 "E stim a te d C a pita l C o st A dva n ta ge " + "m a rke t ch a ra cte ristics" + "sta te " a n d "qu a rte r" du m m y va ria ble s + wi P rim a ry in te re st is in 1 w h ich is th e a m o u n t o f th e ca pita l co st a dva n ta ge th a t is pa sse d th ro u gh to m o rtga ge e s. R e su lt: Le ss th a n h a lf o f co st a dva n ta g e w a s pa sse d th ro u gh to bo rro w e rs. Part 4: Fixed Effects [ 83/96] Time Varying Fixed Effects 911 Rescue Part 4: Fixed Effects [ 84/96] Need for Clarification Part 4: Fixed Effects [ 85/96] Time Varying Fixed Effects Part 4: Fixed Effects [ 86/96] Munnell State Production Model Part 4: Fixed Effects [ 87/96] No Effects Part 4: Fixed Effects [ 88/96] Quadratic Fixed Effects Correct DF: 816-6-3(48)=666 Multiply standard errors by sqr(810/666) = 1.103 Part 4: Fixed Effects [ 89/96] Appendix II. Fixed Effects Algebra Part 4: Fixed Effects [ 90/96] Panel Data Algebra MD M 1D 0 0 0 0 (T h e du m m y va ria ble s a re o rth o go n a l) N M D 0 2 MD 0 i 1 M D I T d i ( d i d i ) d = I T (1 /T i ) d i d i i N i X M D X = i=1 X iM D X i , N i X M D y = i=1 X iM D y i , b LS D V 1 X M D X i X iM D X i i X iM D y i X M D y T k,l t=i 1 ( x it,k -x i.,k )( x it,l -x i.,l ) T k t=i 1 ( x it,k -x i.,k )( y it -y i. ) Part 4: Fixed Effects [ 91/96] Balanced Panel Data Algebra MD M D , T 0 0 0 0 (E a c h m a trix is T T ) M D , T 0 M D,T 0 1 M D , T I T d ( d d ) d = I T (1 /T ) d d MD 1 M D,T 0 M D,T 0 M D,T N o te : d d 0 M D,T 1 M D,T 0 M D,T 0 M D,T 0 M D,T IN M D,T 1 M D , T = a m a trix o f o n e s is B a lta g i's J T ; (1 /T ) d d = a m a trix o f 1 /T is h is J T Part 4: Fixed Effects [ 92/96] Balanced Panel 1 M D , T I T d ( d d ) d = I T (1 /T ) d d = I T J T 1 J T 0 JT P is 0 J T 1 J T 0 JT PX = 0 J T 0 JT 1 JT 0 JT 0 JT 1 JT 0 JT 0 JT 0 JT ; P X cre a te s g ro u p m e a n s 1 J T 0 JT 0 JT 1 J T X1 X1 X2 X2 X N X N T h is is T ro w s e a ch w ith m e a n s re p e a te d . Part 4: Fixed Effects [ 93/96] Balanced Panel I T 0 INT = 0 INT 0 IT 0 0 1 I T 0 0 IT = IT 0 I T 1 I T - 1 JT 0 I T 0 JT -P = 0 I T 0 J T 0 IT 1 IT 0 IT 0 I T 0 JT 1 I T - 1 JT 0 I T 0 JT IN I T IN JT IN I T - JT Q 0 IT 0 IT =I I N T 1 IT 0 I T 0 JT 0 I T 0 JT 1 I T - 1 J T Part 4: Fixed Effects [ 94/96] Balanced Panel 1 J T 0 JT PX = 0 J T 0 JT 1 JT 0 JT 0 JT 0 JT 1 J T X1 X1 X2 X 2 X N X N T h is is T ro w s e a ch w ith m e a n s re pe a te d. P X = I J X X1 X1 X2 X2 Q X = X - I J X = X N X N T h is is T ro w s e a ch w ith m e a n de via tio n s. Part 4: Fixed Effects [ 95/96] Balanced Panel Q X = X - IN JT X = INT X - IN JT X = I N I T X - I N J T X X1 X1 X2 X 2 = X N X N 1 b L S D V X Q X T h is is T ro w s e a ch w ith m e a n d e v ia tio n s X Q y QX Part 4: Fixed Effects [ 96/96] Balanced Panel JT 0 P is 0 0 0 ; P X cre a te s g rou p m e a n s JT 0 JT 0 I - JT 0 Q is 0 0 I - JT 0 0 1 IN I d d T I - JT 0 H om e w ork: (1) V e rify th a t b oth P a n d Q a re id e m p ote n t (2 ) S h ow th a t P Q = 0 (3 ) W h a t is th e tra ce o f Q ?