Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Panel data with IV: commands and some other issues

    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

  • #2
    Click image for larger version

Name:	iv robust.png
Views:	1
Size:	19.7 KB
ID:	1341819


    Here´s an example of one of my estimations using the XTIVREG2 with robust command

    Comment


    • #3
      You really cannot expect anyone to volunteer to figure out your posting - it is much much too long. Unless is it absolutely necessary for your question, don't just dump your entire do file on us. Read the FAQ on posting questions.

      Before you get all tied up in all the tests, look at the results you posted. That you're getting all the parameters not estimating suggests you have a real problem with your data. It is not a normal colinearity issue - that would almost never result in all of your parameters being zero. You've got a systematic error somewhere almost certainly in your data set up, but where is not clear. Look at variances and correlations, try a very simple model then add variables, etc. to try to figure out the problem.

      Comment


      • #4
        Im sorry if that bothered you or the community, but as the FAQ says (statement 9 and the first lines of the statement 10) I did provide the code, and was as accurate as I could be with my question.

        Thanks anyway because I thougth that my data was OK, but it didnt as you said it might happen.

        PD: I dont expect anything from nobody, I flipped the coin after I spend all my resource (luck)...But you did volunteer.

        Have a good day sir

        Alejandro Albrecht
        Attached Files

        Comment


        • #5
          Alejandro:
          you did post what ypu typed, but your post has some formatting problems, because you did use CODE delimiters (please, see FAQ #12).
          That said, Phil is right: there's something quite weird about your results: maybe a trivial mistake is the culprit.
          Eventually, you did not bother anybody with your query, which (set aside the CODE delimiters issue) has the only drawback of being too long (and, sometimes, difficult to follow).
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Thanks Carlo it's just that I am new in the forum , by the way, I managed to solve my data problems using Phil's advices,

            Thanks to both of you

            Alejandro

            Comment


            • #7
              Alejandro:
              happy with reading the news.
              I do hope you' ll enjoy contributing to this forum.

              PS: sorry for my previous miswriting; I meant "...you did not use CODE delimiters..." (my writing is plagued by some kind of sad interaction between being non-English mother-tongue and trying to do more than one thing at the same time)
              Last edited by Carlo Lazzaro; 21 May 2016, 10:43.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment

              Working...
              X