Announcement

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

  • Autocorrelation test (i need he command) when dealing with Panel Data FE

    can someone help me finding the right way (the also woks, because most of the attempts that I performed were not working) to check for autocorrelation when dealing with panel data FE? this is my work so far: //----------------------------*4. Original Model-----------------------------
    *Preparation of the Work Environment
    clear all
    set more off
    cd "/Users/catz/Desktop/Master in Finance/FEP- MÉTODOS ECONOMÉTRICOS/Assignment"
    use "/Users/catz/Desktop/Master in Finance/FEP- MÉTODOS ECONOMÉTRICOS/Assignment/dataset.dta"
    log using assigecon.log, replace

    *Program Installation
    ssc install asdoc
    ssc install coefplot
    net install dca, from("https://raw.github.com/ddsjoberg/dca.stata/master/")replace

    *Database
    use "dataset.dta", clear

    global ylist firmgrowth
    global xlist female_director directors_number board_size ceo_duality board_independence firmsize

    describe c_id yr $ylist $xlist
    summarize c_id yr $ylist $xlist
    * Set data as panel data
    sort c_id yr
    xtset c_id yr
    xtdescribe
    xtsum c_id yr $ylist $xlist

    ///////////////////////////////*4.1.ORIGINAL MODEL//////////////////////////////////////
    *Descriptive Statistics
    describe c_id yr $ylist $xlist
    summarize c_id yr $ylist $xlist

    * Pooled OLS estimator
    reg $ylist $xlist

    * Population-averaged estimator
    xtreg $ylist $xlist, pa

    * Between estimator
    xtreg $ylist $xlist, be

    *Estimation of the Fixed Effects Model
    xtreg $ylist $xlist, fe
    estimates store fixed

    *Estimation of the Random Effects Model
    xtreg $ylist $xlist, re
    estimates store random

    * Breusch-Pagan LM test for random effects versus OLS
    quietly xtreg $ylist $xlist, re
    xttest0

    *Hausman Test to Compare FE and RE
    hausman fixed random, sigmamore

    * The Hausman test shows significant differences between the coefficients for the fixed effects and random effects model. Therefore, we need to use the fixed effects model. *

    Specification
    xtreg $ylist $xlist, fe
    predict yhat_fe, xb
    gen yhat_fe2 = yhat_fe^2
    gen yhat_fe3 = yhat_fe^3
    xtreg $ylist $xlist yhat_fe2 yhat_fe3, fe
    test yhat_fe2 yhat_fe3


    ////////////MULTICOLINEARITY/////////////////////////
    global ylist firmgrowth
    global xlist female_director board_size ceo_duality board_independence firmsize
    //////////Correlation Matrix///////
    pwcorr $xlist
    ///////////VIF////////////
    regress $ylist $xlist
    vif

    ////////////AUTOCORRELATION/////////////////////////
    xtregar firmgrowth female_director directors_number board_size ceo_duality board_independence firmsize, fe

    ///////////////////////////////////////////////////////
    * 5. HETEROSKEDASTICITY
    ///////////////////////////////////////////////////////

    * Baseline pooled OLS
    regress $ylist $xlist i.yr

    * 5.1 Breusch–Pagan / Cook–Weisberg test
    estat hettest

    * 5.2 White's general test
    estat imtest, white

    * FIXED EFFECTS MODEL
    xtreg $ylist $xlist i.yr, fe

    * MODIFIED WALD TEST FOR GROUPWISE HETEROSKEDASTICITY
    ssc install xttest3
    xttest3

    * MAIN FE MODEL – firm-clustered robust SE
    xtreg $ylist $xlist i.yr, fe vce(cluster c_id)

  • #2
    Matteo:
    welcome to this forum.
    The policy is not to consider posts related to home or class assignments (please see Help - Statalist, #4).
    That said, you may want to take a look at the community-contribuyed module -xttest2-.
    I am also not clear with your switching from -xtreg,fe- to -xtregar,fe-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you very much for your prompt response. First of all I was not aware about the policies of thegroup, I am extremely sorry. However, my main goal is to understand what I am doing and see why when it comes to conduct a test for Autocorrelation it does not work on my STATA. Regarding the xttest2, could you please be more kind as to give me more information so that I can check this area on my own? On the other hand, which one do you think is more appropriate to use between xtreg and xtregar? Thank you in advance.

      Comment


      • #4
        Matteo:
        1) new posters are kindly requested to read the FAQ before their first message. Skipping this step is not a waiver.
        2) just type -search xttest2-;
        3) your last question has no "one size fits all" answer. -xtreg- works for N>T pabel datasets.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thanks! However, I do have a question... isn't the xttest2 the breusch–pagan lm test? If so, why I will need to use it in my FE Panel Data if I am trying to check for autocorrelation? I tried to used the xtserial option but it is not working.

          Comment


          • #6
            Matteo:
            -search xtcsd-.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              what about this option:

              ////////////AUTOCORRELATION/////////////////////////

              xtreg firmgrowth female_director directors_number board_size ceo_duality board_independence firmsize, fe

              ///////////////////////////////////////////////////////
              ///////////// MANUAL WOOLDRIDGE TEST //////////////////
              ///////////////////////////////////////////////////////

              reg D.firmgrowth D.female_director D.directors_number D.board_size D.ceo_duality D.board_independence D.firmsize, noconst vce(cluster c_id)

              predict ehat, resid

              reg ehat L.ehat, noconst vce(cluster c_id)

              test L.ehat = -0.5

              Comment

              Working...
              X