0

I'm working with water and sewage provision data from Brazil, 5500 obs, unbalanced panel.

I want to estimate a correlated random effects (CRE) model, and since Wooldridge tells that estimates are the same under CRE and fixed effects I estimated the two models to see if I got it right, but they are quite different. Can anyone tell me if is it a code flaw?

The code I wrote (also, code suggestions are welcome):

import pandas as pd
import linearmodels
data = pd.read_csv(path + 'final_base4.csv')
data = data.set_index(['level_0', 'level_1'])
cre_estimates = {}
fe_estimates = {}

xit = ['lnPIBpc_m', 'in004_', 'const']
di = ['PIBpc_m_bar', 'in004_bar',
       '2011', '2012', '2013', '2014',
       '2015', '2016', '2017', '2018']
y = ['lnfn033__m', 'lntotinv_m',
     'lnfn033_pop', 'lntotinv_pop',
     'lnfn033_eh2o', 'lntotinv_eh2o',
     'lnfn033_toteh2o', 'lntotinv_toteh2o']

for i in range(len(y)):
    # Correlated Random Effects
    cre_estimates[f'{y[i]}'] = linearmodels.RandomEffects(data[y[i]],
                                                          data[xit + di])
    cre_estimates[f'{y[i]}_robs'] = cre_estimates[f'{y[i]}'].fit(cov_type='clustered',
                                                                 entity_cluster=True)
    cre_estimates[f'{y[i]}_hac'] = cre_estimates[f'{y[i]}'].fit(cov_type='kernel')
    cre_estimates[f'{y[i]}'] = cre_estimates[f'{y[i]}'].fit()
    # Fixed Effects
    fe_estimates[f'{y[i]}'] = linearmodels.PanelOLS(data[y[i]], data[xit + di],
                                                    entity_effects=True,
                                                    drop_absorbed=True)
    fe_estimates[f'{y[i]}_hac'] = fe_estimates[f'{y[i]}'].fit(cov_type='kernel')
    fe_estimates[f'{y[i]}_robs'] = fe_estimates[f'{y[i]}'].fit(cov_type='clustered',
                                                               entity_cluster=True)
    fe_estimates[f'{y[i]}'] = fe_estimates[f'{y[i]}'].fit()
print(linearmodels.panel.compare({'Correlated Random Effects': cre_estimates['lnfn033__m'],
                                  'Fixed Effects': fe_estimates['lnfn033__m']}))

Print of the estimates

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • `Wooldridge tells that estimates are the same under CRE and fixed effects` Can you provide a link to the paper you're referencing? I can't find it. – Nick ODell Oct 27 '21 at 17:44
  • Proposition 2.1, but also equation 14.16 of Introductory Econometrics https://www.sciencedirect.com/science/article/pii/S0304407618302392?casa_token=nnfC0QwpxMEAAAAA:gzQLmygc4ASMiwwW9mDThNm96_PlUPpC3uOOMNrDqMdPbSgDETdH3QAiBkTn8N6qSmKp-LLVKL0 – Mateus Cardoso Oct 27 '21 at 19:01

0 Answers0