Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ERF Training Workshop Panel Data 3

179 views

Published on

Raimundo Soto - Catholic University of Chile
ERF Training on Advanced Panel Data Techniques Applied to Economic Modelling

29 -31 October, 2018
Cairo, Egypt

Published in: Government & Nonprofit
  • Be the first to comment

  • Be the first to like this

ERF Training Workshop Panel Data 3

  1. 1. ERF Training Workshop Panel Data 3 Raimundo Soto Instituto de EconomΓ­a, PUC-Chile
  2. 2. RANDOM EFFECTS MODEL β€’ Consider the following true model 𝑦𝑖𝑑 = 𝛼𝑖 + 𝛽π‘₯𝑖𝑑 + πœ€π‘–π‘‘ β€’ So far, we assumed 𝛼𝑖 to be a fixed characteristic of individuals. β€’ We now allow the individual effect to be the realization of a random variable 2
  3. 3. RANDOM EFFECTS MODEL β€’ Why random? β€’ Several explanations (indeed, all are the same) – The β€œfixed effect” depends on group composition β€’ There could be sub-groups within the group – The observed β€œfixed effect” is a realization of a β€œlatent” characteristic variable and therefore the observed behavior depends on this hidden process β€’ Example: farm produce and the quality of soil 3
  4. 4. RANDOM EFFECTS MODEL Grupo 2 Grupo 1 π‘₯ 𝑦 4 Differences in heterogeneity cannot be ignored
  5. 5. RANDOM EFFECTS MODEL β€’ The model is: 𝑦𝑖𝑑 = 𝛼𝑖 + 𝛽π‘₯𝑖𝑑 + πœ€π‘–π‘‘ 𝛼𝑖 = 𝛼 + πœ‡π‘– β€’ Where πœ‡π‘– is a random shock i.i.d. β€’ Now, there are two sources of uncertainty (πœ€π‘–π‘‘ and πœ‡π‘–). A structure is therefore needed 5
  6. 6. RANDOM EFFECTS MODEL β€’ Assume: β€’ Non systematic shocks: 𝐸 πœ€π‘–π‘‘ = 𝐸 πœ‡π‘– = 0 β€’ Finite uncertainty: 𝑉 πœ€π‘–π‘‘ = πœŽπœ€ 2 𝑉 πœ‡π‘– = πœŽπœ‡ 2 β€’ No cross information: 𝐸 πœ€π‘–π‘‘, πœ‡π‘– = 0 𝐸 πœ‡π‘–, πœ‡ 𝑗 = 0 𝐸 πœ€π‘–π‘‘, πœ€π‘—π‘‘ = 0 β€’ Key assumption in red 6
  7. 7. RANDOM EFFECTS MODEL β€’ The model is: 𝑦𝑖𝑑 = 𝛼 + 𝛽π‘₯𝑖𝑑 + πœ€π‘–π‘‘ + πœ‡π‘– 𝑦𝑖𝑑 = 𝛼 + 𝛽π‘₯𝑖𝑑 + πœ”π‘–π‘‘ β€’ The error term πœ”π‘–π‘‘ is now heteroskedastic. Consider the variance of the error term in group 1 7
  8. 8. RANDOM EFFECTS MODEL β€’ Consider the variance for all groups β€’ We now need an estimator of this variance to use generalized least squares (GLS) 8
  9. 9. RANDOM EFFECTS MODEL β€’ Recall the GLS estimator trick: we want to transform (weigh) the data so that the model becomes homoskedastic β€’ Let T be the transformation: 𝑇𝑦𝑖𝑑 = 𝑇𝛼 + 𝛽𝑇π‘₯𝑖𝑑 + π‘‡πœ”π‘–π‘‘ β€’ We thus want E π‘‡πœ”π‘–π‘‘ β€² π‘‡πœ”π‘–π‘‘ = 𝜎2 𝐼 9
  10. 10. RANDOM EFFECTS MODEL β€’ We want to find T so that E π‘‡πœ”π‘–π‘‘ β€² π‘‡πœ”π‘–π‘‘ = 𝜎2 𝐼 β€’ Then 𝑇′Ω𝑇 = 𝐼 β€’ Hence, Ω½ = 𝐼 βˆ’ πœƒ 𝑇 𝑖𝑖′ where πœƒ = 1 βˆ’ 𝜎 πœ€ π‘‡πœŽ πœ‡ 2 +𝜎 πœ€ 2 β€’ What does 𝐼 βˆ’ πœƒ 𝑇 𝑖𝑖′ do? β€’ Magic! 𝐼 βˆ’ πœƒ 𝑇 𝑖𝑖′ π‘₯ = π‘₯𝑖 βˆ’ πœƒ π‘₯𝑖 10
  11. 11. RANDOM EFFECTS MODEL β€’ 𝐼 βˆ’ πœƒ 𝑇 𝑖𝑖′ π‘₯ = π‘₯𝑖 βˆ’ πœƒ π‘₯𝑖 y πœƒ = 1 βˆ’ 𝜎 πœ€ π‘‡πœŽ πœ‡ 2 +𝜎 πœ€ 2 β€’ Note that when πœŽπœ‡ 2 =0, πœƒ = 0, there is only one fixed effect and we are back to the pooled model β€’ Note that when T β†’ ∞, πœƒ = 1, there is one fixed effect per group and we are to the fixed-effects model β€’ When 0 < πœƒ < 1 we have a random-effects model 11
  12. 12. RANDOM EFFECTS MODEL β€’ The transformed models is 𝑦𝑖𝑑 βˆ’ πœƒ 𝑦𝑖 = π‘₯𝑖𝑑 βˆ’ πœƒ π‘₯𝑖 𝛽 + 𝛼 + πœ€π‘–π‘‘ β€’ But, how do we estimate this model? β€’ We need πœƒ β€’ Indeed, we need πœƒ β€’ That is, we need πœŽπœ€ 2 and πœŽπœ‡ 2 12
  13. 13. RANDOM EFFECTS MODEL β€’ But we already know how to do it!! β€’ We need the intra-group variance, use the fixed-effect estimator to obtain πœŽπœ€ 2 β€’ We need the inter-group variance which we do not have, but we have the variance from the between groups estimator 𝜎 πœ‡ 2 +𝜎 πœ€ 2 𝑇 to obtain πœŽπœ‡ 2 β€’ The needed estimator is πœƒ = 1 βˆ’ 𝜎 πœ€ 𝑇 𝜎 πœ‡ 2+ 𝜎 πœ€ 2 13
  14. 14. RANDOM EFFECTS MODEL β€’ Note that – This estimator is inconsistent when 𝐸 π‘₯𝑖𝑑, πœ‡π‘– β‰  0 – This estimator is only asymptotically efficient, since Ξ© β†’ Ξ© only when 𝑁 β†’ ∞ (even if T is fixed) – Note the notable reduction in estimated parameters: while in the fixed-effects model there are K constants to estimate, in the random–effects models there is only 1 (besides πœŽπœ‡ 2 ) 14
  15. 15. RANDOM EFFECTS MODEL 15 rho .71183054 (fraction of variance due to u_i) sigma_e .32607847 sigma_u .51249125 _cons -4.159675 .221007 -18.82 0.000 -4.592841 -3.72651 l_popt .0564086 .021553 2.62 0.009 .0141654 .0986517 l_infl2 -.0402788 .0050865 -7.92 0.000 -.0502482 -.0303094 l_realgdp .2575086 .0119961 21.47 0.000 .2339967 .2810204 l_money Coef. Std. Err. z P>|z| [95% Conf. Interval] corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 Wald chi2(3) = 1520.84 overall = 0.0028 max = 55 between = 0.0126 avg = 33.3 R-sq: within = 0.3236 Obs per group: min = 4 Group variable: idwbcode Number of groups = 163 Random-effects GLS regression Number of obs = 5436
  16. 16. RANDOM EFFECTS MODEL RESULTS 16 rho .71183054 (fraction of variance due to u_i) sigma_e .32607847 sigma_u .51249125 _cons -4.159675 .221007 -18.82 0.000 -4.592841 -3.72651 l_popt .0564086 .021553 2.62 0.009 .0141654 .0986517 l_infl2 -.0402788 .0050865 -7.92 0.000 -.0502482 -.0303094 l_realgdp .2575086 .0119961 21.47 0.000 .2339967 .2810204 l_money Coef. Std. Err. z P>|z| [95% Conf. Interval] corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 Wald chi2(3) = 1520.84 overall = 0.0028 max = 55 between = 0.0126 avg = 33.3 R-sq: within = 0.3236 Obs per group: min = 4 Group variable: idwbcode Number of groups = 163 Random-effects GLS regression Number of obs = 5436
  17. 17. COMPARED RESULTS 17 * p<0.1, ** p<0.05, *** p<0.01 t statistics in parentheses Observations 5436 5436 5436 5436 (39.10) (-31.67) (5.14) (-18.82) Constant 3.315*** -7.845*** 2.450*** -4.160*** (0.24) (2.56) (0.30) (2.62) Population 0.00144 0.0732** 0.00875 0.0564*** (-20.94) (-5.92) (-6.24) (-7.92) Inflation -0.165*** -0.0281*** -0.406*** -0.0403*** (-2.36) (25.09) (-0.37) (21.47) Real GDP -0.00867** 0.385*** -0.00630 0.258*** Pooled Within Between Random (1) (2) (3) (4)
  18. 18. WHICH MODEL TO USE? β€’ Random effects or fixed effects? β€’ Fixed effects or pooled data? β€’ Recall 18 Fixed-effects Estimator Random-effects Estimator When 𝐸 π‘₯𝑖𝑑, πœ‡π‘– = 0 Consistent Consistent Inefficient Efficient When 𝐸 π‘₯𝑖𝑑, πœ‡π‘– β‰  0 Consistent Inconsistent Inefficient -
  19. 19. WHICH MODEL TO USE? β€’ Let us estimate the parameters using both estimators 𝛽 𝑅𝐸 and 𝛽 𝑉𝐸: – if they are the same, choose 𝛽 𝑅𝐸 because it is consistent and efficient – if they are different, choose 𝛽 𝐹𝐸 because 𝛽 𝑅𝐸 is consistent β€’ Use a β€œt” type test 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 β€’ It is easier to use a Wald test: 𝛽 π‘…πΈβˆ’ 𝛽 𝐹𝐸 2 π‘£π‘Žπ‘Ÿ 𝛽 π‘…πΈβˆ’ 𝛽 𝐹𝐸 β€’ Let us study π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 19
  20. 20. WHICH MODEL TO USE? π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 = π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 + π‘£π‘Žπ‘Ÿ 𝛽 𝐹𝐸 βˆ’ 2π‘π‘œπ‘£ 𝛽 𝑅𝐸, 𝛽 𝐹𝐸 β€’ Key insight from Hausman and Wu: – An efficient estimator is orthogonal to β€œits difference vis-a-vis an inefficient estimator” – Otherwise, you could have an even more efficient estimator 0=Cov[ 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸, 𝛽 𝑅𝐸]=Cov[ 𝛽 𝑅𝐸, 𝛽 𝐹𝐸] βˆ’ Var[ 𝛽 𝑅𝐸] β€’ Hence π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 = π‘£π‘Žπ‘Ÿ 𝛽 𝐹𝐸 βˆ’ π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 20
  21. 21. WHICH MODEL TO USE? β€’ Hence, the test is 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 2 π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 = 𝛽 𝑅𝐸 βˆ’ 𝛽 𝐹𝐸 2 π‘£π‘Žπ‘Ÿ 𝛽 𝐹𝐸 βˆ’ π‘£π‘Žπ‘Ÿ 𝛽 𝑅𝐸 ~πœ’2 (𝐾) 21
  22. 22. HAUSMAN-WU TEST RESULTS 22 (V_b-V_B is not positive definite) Prob>chi2 = 0.0000 = 1298.59 chi2(3) = (b-B)'[(V_b-V_B)^(-1)](b-B) Test: Ho: difference in coefficients not systematic B = inconsistent under Ha, efficient under Ho; obtained from xtreg b = consistent under Ho and Ha; obtained from xtreg l_popt .0731808 .0564086 .0167722 .0186968 l_infl2 -.0281481 -.0402788 .0121307 . l_realgdp .3846652 .2575086 .1271567 .009549 Within Random Difference S.E. (b) (B) (b-B) sqrt(diag(V_b-V_B)) Coefficients Random effects vs. Fixed effects
  23. 23. BREUSCH-PAGAN TEST 23 Prob > chibar2 = 0.0000 chibar2(01) = 30448.43 Test: Var(u) = 0 u .2626473 .5124913 e .1063272 .3260785 l_money .4515998 .6720118 Var sd = sqrt(Var) Estimated results: l_money[idwbcode,t] = Xb + u[idwbcode] + e[idwbcode,t] Breusch and Pagan Lagrangian multiplier test for random effects Random effects vs. No effects
  24. 24. WHICH MODEL TO USE? β€’ Fixed Effects or pooled estimator? β€’ Equivalent to test: 𝐻0: 𝛼𝑖 = 𝛼 β€’ Careful with the alternative: 𝐻1: 𝛼𝑖 β‰  𝛼 π‘“π‘œπ‘Ÿ π‘Žπ‘‘ π‘™π‘’π‘Žπ‘‘ π‘œπ‘›π‘’ π‘”π‘Ÿπ‘œπ‘’π‘ "𝑖" β€’ Stata performs the test when using the Fixed – effects estimator: 24
  25. 25. POOLABILITY TEST RESULTS 25 F test that all u_i=0: F(162, 5270) = 98.59 Prob > F = 0.0000 rho .95557807 (fraction of variance due to u_i) sigma_e .32607847 sigma_u 1.5123647 _cons -7.844568 .2477214 -31.67 0.000 -8.330205 -7.358932 l_popt .0731808 .0285325 2.56 0.010 .0172453 .1291163 l_infl2 -.0281481 .004758 -5.92 0.000 -.0374757 -.0188204 l_realgdp .3846652 .0153326 25.09 0.000 .354607 .4147234 l_money Coef. Std. Err. t P>|t| [95% Conf. Interval] corr(u_i, Xb) = -0.9200 Prob > F = 0.0000 F(3,5270) = 859.53 overall = 0.0036 max = 55 between = 0.0140 avg = 33.3 R-sq: within = 0.3285 Obs per group: min = 4 Group variable: idwbcode Number of groups = 163 Fixed-effects (within) regression Number of obs = 5436 Fixed effects vs. No effects

Γ—