Announcement

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

  • Panel Data and Fixed Effect

    Hello everybody and thank you for your help. I am a new member so I kindly ask you to excuse me if I will commit some mistakes in filling in my question.

    I am a Management Students and I'm carrying out my Master of Science Thesis and I have a Panel Database. I have registered the type of social partnerships that 124 firms have developed from 2005 to 2014. These Partnership have made classified from 1 to 4 in my Database. My indipendent variable is the number of positive articles that each company received in each year of analysis. My research question is focused on understanding what type of partnership have a higher significative impact on Media Favorability.
    Someone could help me suggesting the best model to use? I have tried both Xtreg and LSDV models, but I Think I am commiting some mistakes in writing the code.
    Below I outline the name of my variables:

    Company
    Year
    Type of Partnership
    Positive News

    Someone could suggesting me an example of regression? Thank you very much for your support!

    Alessio

  • #2
    Alessio:
    welcome to this forum.
    This kind of questions are easier to reply if you post na example/excerpt of your dataset (via -dataex-). Please see the FAQ on posting-related advice. Thanks.
    By the way, I'm not clear with your dependent variable: is it continuous? Is it a count one (if the latter were the case, -xtreg- would not be the right tool; see -xtpoisson- instead)?
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      Dear Carlo Lazzaro ,

      I have attached an example of my Panel Dataset below. My Dependent Variable is "MediaFavorability" that is the number of Positive News minus the number of Negative News that each Company have received every Year. The Dataset is based on the classification of the social partnership developed by 124 Comapnies from 2005 and 2014. These partnership have been defined with a number from 1 to 5. My aim is to understand what type of partnership have a significative influence on MediaFavorability that is used as a proxy of Social Legitimacy.
      Sorry it is one my first approach with these types of analysis.

      Thank you very much for your support,

      Alessio


      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str42 Company int(Year TotNews MediaFavorability) byte INSTRUMENTAL
      "3 M Company" 2010 122 76 4
      "3 M Company" 2013 195 171 4
      "3 M Company" 2013 195 171 4
      "3 M Company" 2014 173 169 4
      "Abbott Laboratories" 2005 133 73 4
      "Abbott Laboratories" 2005 133 73 3
      "Abbott Laboratories" 2006 146 64 5
      "Abbott Laboratories" 2006 146 64 5
      "Abbott Laboratories" 2007 136 84 3
      "Abbott Laboratories" 2008 114 78 3
      "Abbott Laboratories" 2008 114 78 5
      "Abbott Laboratories" 2009 135 109 4
      "Abbott Laboratories" 2010 190 110 4
      "Abbott Laboratories" 2011 189 135 3
      "Abbott Laboratories" 2011 189 135 5
      "Abbott Laboratories" 2012 199 93 5
      "Abbott Laboratories" 2013 169 147 5
      "Abbott Laboratories" 2014 144 114 3
      "Abbott Laboratories" 2014 144 114 5
      "Adobe Systems Inc" 2006 64 64 5
      "Adobe Systems Inc" 2009 64 64 4
      "Advanced Micro Devices Inc" 2008 90 34 3
      "Advanced Micro Devices Inc" 2008 90 34 3
      "Advanced Micro Devices Inc" 2009 261 -125 2
      "Advanced Micro Devices Inc" 2011 316 42 2
      "Advanced Micro Devices Inc" 2008 90 34 3
      "Advanced Micro Devices Inc" 2008 90 34 3
      "Advanced Micro Devices Inc" 2008 90 34 3
      "Advanced Micro Devices Inc" 2008 90 34 3
      "Advanced Micro Devices Inc" 2011 316 42 3
      "Advanced Micro Devices Inc" 2011 316 42 3
      "Advanced Micro Devices Inc" 2011 316 42 3
      "Advanced Micro Devices Inc" 2011 316 42 3
      "Advanced Micro Devices Inc" 2011 316 42 3
      "Advanced Micro Devices Inc" 2011 316 42 3
      "Advanced Micro Devices Inc" 2012 105 89 5
      "Advanced Micro Devices Inc" 2013 80 50 5
      "Advanced Micro Devices Inc" 2014 93 47 5
      "Aflac Inc" 2005 30 28 5
      "Aflac Inc" 2006 34 34 5
      "Aflac Inc" 2007 21 21 5
      "Aflac Inc" 2008 24 22 5
      "Aflac Inc" 2009 11 11 5
      "Aflac Inc" 2010 28 28 5
      "Aflac Inc" 2011 30 30 5
      "Aflac Inc" 2012 30 30 5
      "Aflac Inc" 2013 22 22 3
      "Aflac Inc" 2013 22 22 5
      "Aflac Inc" 2014 11 11 5
      "Air Products & Chemicals Inc" 2013 52 52 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2006 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2005 0 0 4
      "Alcoa Inc" 2008 0 0 5
      "Allergan Inc" 2005 45 39 1
      "Allergan Inc" 2006 68 56 1
      "Allergan Inc" 2007 39 35 1
      "Allergan Inc" 2008 37 33 1
      "Allergan Inc" 2009 38 10 1
      "Allergan Inc" 2010 55 13 1
      "Allergan Inc" 2012 41 23 1
      "Allergan Inc" 2013 31 17 1
      "Allergan Inc" 2014 210 104 1
      "ALLSTATE CORP" 2005 60 36 5
      "ALLSTATE CORP" 2005 60 36 5
      "ALLSTATE CORP" 2005 60 36 1
      "ALLSTATE CORP" 2006 85 35 1
      "ALLSTATE CORP" 2007 111 -35 1
      "ALLSTATE CORP" 2008 55 -3 1
      "ALLSTATE CORP" 2009 41 25 1
      "ALLSTATE CORP" 2010 66 32 1
      "ALLSTATE CORP" 2013 84 66 5
      "ALLSTATE CORP" 2014 67 63 5
      "American Electric Power" 2008 55 47 4
      "American Electric Power" 2009 53 39 5
      "American Electric Power" 2010 110 54 5
      "American Electric Power" 2011 102 40 2
      "American Electric Power" 2014 66 60 2
      "AMGEN INC" 2005 89 61 4
      "AMGEN INC" 2006 125 79 4
      "AMGEN INC" 2006 125 79 4
      "Alcoa Inc" 2012 1 1 5
      "AMGEN INC" 2007 110 66 4
      "AMGEN INC" 2007 110 66 4
      "AMGEN INC" 2007 110 66 4
      "AMGEN INC" 2008 134 78 4
      "AMGEN INC" 2009 79 49 4
      "AMGEN INC" 2010 56 54 4
      "AMGEN INC" 2011 76 70 4
      "APPLIED MATERIALS INC" 2005 29 27 2
      "APPLIED MATERIALS INC" 2006 57 43 4
      end

      Comment


      • #4
        Alessio:
        thanks for providing an almost doable example (for the future, pleaase use CODe delimiters to share what you tyoed and what Stata gave you back. Thanks).
        Some issues cocnerning your dataset:
        1) you cannot have a panel identifier in -string- format;
        2) you have repeated time values within panel;
        3) you do not state/tested what specification fits your data better (that is, -fe- or -re-);
        4) -hausman- test outcome cannot help you out in choosing between -fe- and -re- specification.

        The good news is that Stata can manage all these nuisances.

        Let's work them out step by step:

        1)
        Code:
        . xtset Company Year
        string variables not allowed in varlist;
        Company is a string variable
        r(109);
        
        . egen New_Company=group( Company)
        
        . tab Company
        
                                        Company |      Freq.     Percent        Cum.
        ----------------------------------------+-----------------------------------
                                    3 M Company |          4        4.00        4.00
                                  ALLSTATE CORP |         10       10.00       14.00
                                      AMGEN INC |         10       10.00       24.00
                          APPLIED MATERIALS INC |          2        2.00       26.00
                            Abbott Laboratories |         15       15.00       41.00
                              Adobe Systems Inc |          2        2.00       43.00
                     Advanced Micro Devices Inc |         17       17.00       60.00
                                      Aflac Inc |         11       11.00       71.00
                   Air Products & Chemicals Inc |          1        1.00       72.00
                                      Alcoa Inc |         14       14.00       86.00
                                   Allergan Inc |          9        9.00       95.00
                        American Electric Power |          5        5.00      100.00
        ----------------------------------------+-----------------------------------
                                          Total |        100      100.00
        
        . label define New_Company 1 "3 M Company" 2 "ALLSTATE CORP" 3 "AMGEN INC" 4 "APPLIED MATERIALS INC" 5 "Abbott Laborato
        > ries" 6 "Adobe Systems Inc" 7 "Advanced Micro Devices Inc" 8 "Aflac Inc" 9 " Air Products & Chemicals Inc" 10 "Alcoa
        > Inc" 11 "Allergan Inc" 12 "American Electric Power"
        
        . label val New_Company New_Company
        2)
        Code:
        . xtset New_Company Year
        repeated time values within panel
        r(451);
        
        . xtset New_Company
               panel variable:  New_Company (unbalanced) *you can -xtset- your data with panel identifier only provided that you do not plan to use time-sereis commands, such as lags and leads*
        3) & 4)
        Code:
        . xtreg MediaFavorability TotNews i.INSTRUMENTAL, fe
        
        Fixed-effects (within) regression               Number of obs     =        100
        Group variable: New_Company                     Number of groups  =         12
        
        R-sq:                                           Obs per group:
             within  = 0.1884                                         min =          1
             between = 0.2264                                         avg =        8.3
             overall = 0.1820                                         max =         17
        
                                                        F(5,83)           =       3.85
        corr(u_i, Xb)  = 0.0645                         Prob > F          =     0.0034
        
        ------------------------------------------------------------------------------
        MediaFavor~y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
             TotNews |   .0876154   .0502505     1.74   0.085    -.0123309    .1875617
                     |
        INSTRUMENTAL |
                  2  |  -17.37422   21.72075    -0.80   0.426    -60.57592    25.82748
                  3  |   30.93266   18.62852     1.66   0.101    -6.118711    67.98404
                  4  |   27.40014   19.23978     1.42   0.158    -10.86701    65.66729
                  5  |   35.41793   16.01183     2.21   0.030     3.571041    67.26482
                     |
               _cons |   14.27669   15.15691     0.94   0.349     -15.8698    44.42318
        -------------+----------------------------------------------------------------
             sigma_u |  34.317343
             sigma_e |  24.804973
                 rho |  .65683317   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        F test that all u_i=0: F(11, 83) = 11.86                     Prob > F = 0.0000
        
        . estimate store fe
        
        . xtreg MediaFavorability TotNews i.INSTRUMENTAL, re
        
        Random-effects GLS regression                   Number of obs     =        100
        Group variable: New_Company                     Number of groups  =         12
        
        R-sq:                                           Obs per group:
             within  = 0.1475                                         min =          1
             between = 0.4695                                         avg =        8.3
             overall = 0.2830                                         max =         17
        
                                                        Wald chi2(5)      =      28.79
        corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
        
        ------------------------------------------------------------------------------
        MediaFavor~y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
             TotNews |   .1889134    .050382     3.75   0.000     .0901665    .2876603
                     |
        INSTRUMENTAL |
                  2  |  -27.97537   18.89814    -1.48   0.139    -65.01504    9.064306
                  3  |    16.7423   15.23832     1.10   0.272    -13.12426    46.60887
                  4  |    30.6268   13.66169     2.24   0.025     3.850389    57.40322
                  5  |   27.87955   12.81515     2.18   0.030     2.762309    52.99678
                     |
               _cons |   13.61421   12.05342     1.13   0.259    -10.01006    37.23849
        -------------+----------------------------------------------------------------
             sigma_u |  11.151804
             sigma_e |  24.804973
                 rho |   .1681374   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        
        . estimate store re
        
        . hausman fe re
        
                         ---- Coefficients ----
                     |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
                     |       fe           re         Difference          S.E.
        -------------+----------------------------------------------------------------
             TotNews |    .0876154     .1889134        -.101298               .
        INSTRUMENTAL |
                  2  |   -17.37422    -27.97537        10.60114        10.70754
                  3  |    30.93266      16.7423        14.19036        10.71519
                  4  |    27.40014      30.6268       -3.226665        13.54723
                  5  |    35.41793     27.87955        7.538384        9.599512
        ------------------------------------------------------------------------------
                                   b = consistent under Ho and Ha; obtained from xtreg
                    B = inconsistent under Ha, efficient under Ho; obtained from xtreg
        
            Test:  Ho:  difference in coefficients not systematic
        
                          chi2(5) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                                  =  -790.59    chi2<0 ==> model fitted on these
                                                data fails to meet the asymptotic
                                                assumptions of the Hausman test;
                                                see suest for a generalized test
        However, you can use the user-written command -xtoverid- (type -search xtoverid- to spot and install it). Please be aware that -xtoverid- does not support -fvvarlist- notation; hence, you should prefix your code with -xi.-:

        Code:
        . xtoverid
        1b:  operator invalid
        r(198);
        
        . xi: xtreg MediaFavorability TotNews i.INSTRUMENTAL, re
        i.INSTRUMENTAL    _IINSTRUMEN_1-5     (naturally coded; _IINSTRUMEN_1 omitted)
        
        Random-effects GLS regression                   Number of obs     =        100
        Group variable: New_Company                     Number of groups  =         12
        
        R-sq:                                           Obs per group:
             within  = 0.1475                                         min =          1
             between = 0.4695                                         avg =        8.3
             overall = 0.2830                                         max =         17
        
                                                        Wald chi2(5)      =      28.79
        corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
        
        -------------------------------------------------------------------------------
        MediaFavora~y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        --------------+----------------------------------------------------------------
              TotNews |   .1889134    .050382     3.75   0.000     .0901665    .2876603
        _IINSTRUMEN_2 |  -27.97537   18.89814    -1.48   0.139    -65.01504    9.064306
        _IINSTRUMEN_3 |    16.7423   15.23832     1.10   0.272    -13.12426    46.60887
        _IINSTRUMEN_4 |    30.6268   13.66169     2.24   0.025     3.850389    57.40322
        _IINSTRUMEN_5 |   27.87955   12.81515     2.18   0.030     2.762309    52.99678
                _cons |   13.61421   12.05342     1.13   0.259    -10.01006    37.23849
        --------------+----------------------------------------------------------------
              sigma_u |  11.151804
              sigma_e |  24.804973
                  rho |   .1681374   (fraction of variance due to u_i)
        -------------------------------------------------------------------------------
        
        . xtoverid
        
        Test of overidentifying restrictions: fixed vs random effects
        Cross-section time-series model: xtreg re  
        Sargan-Hansen statistic  42.691  Chi-sq(5)    P-value = 0.0000
        All in all, -re- specification seems the way to go (as per your data excerpt, at least).
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment


        • #5
          Dear Carlo Lazzaro

          thank you very much for your support. I would ask you another adivce. In this case, for you, may it better using the "ln" of the dependent variable (MediaFavorability)? I have studied that logarith is a good way for reducing heteroscedasticity and I have noted that some articles have developed the research in this way.

          Thak you and good evening

          Alessio

          Comment


          • #6
            Alessio:
            depending on one's research field, logging the dependent variable comes in handy whenever you want to express in % terms the contribution to the variation of the regressand caused by each predictor when adjusted for the other ones.
            I would recommend you to check whether logging the dependent variable is customary in your discipline.
            As an aside, please note that logging the regressand does not replace/rule out regression model post estimation routine.
            Kind regards,
            Carlo
            (Stata 18.0 SE)

            Comment

            Working...
            X