Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72797

Panel data with IV: commands and some other issues

$
0
0
Hello, Im wokring on a panel data with IV for 140 countries from 1984 to 2013 (first estimating a global model, then only doing it with coutnries from latin american region-using dummies-)

My question relies on how to correct heteroskedasticity, autocorrelation and multicolineality with statas IV panel data commands> Here-s my complete procedure:

*Paper Corrupción vs Crecimiento económico y desarrollo político
clear all
use "C:\Users\ALEJANDRO\Desktop\IE 1\data_final.dta", clear
encode Country , gen (country)
findit xtserial
net sj 3-2 st0039
net install st0039
ssc install xttest3
ssc install xttest2
ssc install ranktest ,replace
ssc install ivreg2, replace
ssc install xtivreg2
*Pruebas del modelo global
xtset country Year


xtivreg Corrupt ln_pbi inv_total taxeslaworder pop education educa_2 gini_index (desa_pol = burocra democra)
reg Corrupt ln_pbi inv_total taxeslaworder pop education educa_2 gini_index desa_pol burocra democra
estat vif

xtreg Corrupt ln_pbi inv_total taxeslaworder pop education educa_2 gini_index desa_pol burocra democra , fe
xttest3
xtivreg2 Corrupt ln_pbi inv_total taxeslaworder pop education educa_2 gini_index (desa_pol = burocra democra) , fe robust
estimates store fixed
xtivreg Corrupt ln_pbi inv_total taxeslaworder pop education educa_2 gini_index (desa_pol = burocra democra) , re
estimates store random
hausman fixed random
xtserial Corrupt ln_pbi inv_total taxeslaworder pop education educa_2 gini_index desa_pol burocra democra

*el test de hausman revela que el mejor modelo es el de efectos fijos dado a que su p-value es menor a 5%
*prima el modelo de efectos fijos (tal como se habló en la teoría del paper)
*pruebas del modelo regional
gen latam=0
replace latam=1 if country==4
replace latam=1 if country==14
replace latam=1 if country==16
replace latam=1 if country==22
replace latam=1 if country==24
replace latam=1 if country==27
replace latam=1 if country==34
replace latam=1 if country==35
replace latam=1 if country==37
replace latam=1 if country==47
replace latam=1 if country==51
replace latam=1 if country==52
replace latam=1 if country==81
replace latam=1 if country==90
replace latam=1 if country==96
replace latam=1 if country==98
replace latam=1 if country==99
replace latam=1 if country==125
replace latam=1 if country==133
replace latam=1 if country==134
replace latam=. if missing(country)

*generando nuevas variables junt con las dummies
gen latam_lnpbi = latam*ln_pbi
gen latam_desa_pol=latam*desa_pol

*modelo regional
xtset country Year

xtivreg Corrupt latam_lnpbi inv_total taxeslaworder pop education educa_2 gini_index (latam_desa_pol= burocra democra)
reg Corrupt latam_lnpbi inv_total taxeslaworder pop education educa_2 gini_index latam_desa_pol burocra democra
estat vif

xtreg Corrupt latam_lnpbi inv_total latam taxeslaworder pop education educa_2 gini_index latam_desa_pol burocra democra , fe
xttest3
xtivreg2 Corrupt latam_lnpbi inv_total taxeslaworder pop education educa_2 gini_index (latam_desa_pol= burocra democra) , fe robust
estimate store fixed_latam
xtivreg Corrupt latam_lnpbi inv_total taxeslaworder pop education educa_2 gini_index (latam_desa_pol= burocra democra) , re
estimate store random_latam
hausman fixed_latam random_latam
xtserial Corrupt latam_lnpbi inv_total taxeslaworder pop education educa_2 gini_index latam_desa_pol burocra democra
*pruebas de raiz unitaria
xtunitroot fisher Corrupt, dfuller lags(1)

xtunitroot fisher ln_pbi, dfuller lags(1)

xtunitroot fisher inv_total, dfuller lags(1)

xtunitroot fisher taxeslaworder, dfuller lags(1)

xtunitroot fisher pop, dfuller lags(1)

xtunitroot fisher education, dfuller lags(1)

xtunitroot fisher educa_2, dfuller lags(1)

xtunitroot fisher desa_pol, dfuller lags(1)

xtunitroot fisher burocra, dfuller lags(1)

xtunitroot fisher democra, dfuller lags(1)
xtunitroot fisher latam_lnpbi, dfuller lags(1)


xtunitroot fisher latam_desa_pol, dfuller lags(1)


*el test de hausman para latam demeustra que sigue primando el modelo de efectos fijos pues el p value es menor a 5 %
* sin embargo se muestra un hecho interesante, el desarrollo politico en latam se ha dado principalmente por un mayor nivel de corrupciòn, mientras que el economico si se vio opacado, es interesante ver como los paises con mayor corrupciòn son los que tienen un estado màs dictatorial o màs presente en latinomarica (no incluye paises europeos pues el caso es distinto)
* esto no queire decir que ante una mayor presencia del estado necesariamente haya corrupciòn, sino que en latinomaerica tiende a ser màs probable, debido a fenomenos como el populismo, fasicmo y cualquier especie de dictadura
*corrigiendo raiz unitaria
gen d_ln_pbi=D.ln_pbi
xtunitroot fisher d_ln_pbi, dfuller lags(1)
gen d_inv_total=D.inv_total
xtunitroot fisher d_inv_total, dfuller lags(1)
gen d_education=D.education
xtunitroot fisher d_education, dfuller lags (1)
gen d_educa_2=D.educa_2
xtunitroot fisher d_educa_2 ,dfuller lags(1)
gen d_latam_lnpbi= D.latam_lnpbi
xtunitroot fisher d_latam_lnpbi ,dfuller lags(1)
*ahroa que los paneles son estacionarios y no tienen raiz unitaria (se ve el p value del test normal Z)
*se pasa a correr los modeloscon las variables estacionarias
*modelo globar
xtivreg Corrupt d_ln_pbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index (desa_pol = burocra democra)
reg Corrupt d_ln_pbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index desa_pol burocra democra
estat vif

xtreg Corrupt d_ln_pbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index desa_pol burocra democra , fe
xttest3
xtivreg2 Corrupt d_ln_pbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index (desa_pol = burocra democra) , fe robust
estimates store fixed
xtivreg Corrupt d_ln_pbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index (desa_pol = burocra democra) , re
estimates store random
hausman fixed random
xtserial Corrupt d_ln_pbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index desa_pol burocra democra
*modelo regional
xtivreg Corrupt d_latam_lnpbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index (latam_desa_pol= burocra democra)
reg Corrupt d_latam_lnpbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index latam_desa_pol burocra democra
estat vif
xtivreg2 Corrupt d_latam_lnpbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index (latam_desa_pol= burocra democra) , fe robust
xtreg Corrupt d_latam_lnpbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index latam_desa_pol burocra democra , fe
xttest3

estimate store fixed_latam
xtivreg Corrupt d_latam_lnpbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index (latam_desa_pol= burocra democra) , re
estimate store random_latam
hausman fixed_latam random_latam
xtserial Corrupt d_latam_lnpbi d_inv_total taxeslaworder pop d_education d_educa_2 gini_index latam_desa_pol burocra democra



Im aware of a few things, to correct heteroskedasticyty i use de xtivreg2 command with the robust option (for fixed effects models) but when it runs stata ommits almast all of my variables (same with the Cluster option), perhaps is a problem of multicolineality among the variables, so I use de VIF command, which gave me values less than 5 (meaning ther's no multicolineality) so I dont know what to do in these case, perhaps Im doing some syntaxis wrong,and a wish I could use some help from you.

another thing is that the XTSERIAL command gave me that there is autocorellation (I didnt find a command exclusively for IV panel data), and I wish to know how can I correct that in my IV panel model.

finally I did correct the presence of unit root so that's not a problem for me at all, and Iknow that the hausman test doesnt work with the robust or cluster option but when I compute the XTOVERID command I think is missleading because Im using IV and the command is for exogenous models

Thank you very much

Alejandro Albrecht

Viewing all articles
Browse latest Browse all 72797

Trending Articles