Announcement

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

  • OLS regression with panel data

    Before I do an OLS regression for panel data, do I need to xtset first? How can I tell that the results are overtime? Would I need to include the year variable as an independent variable in the regression?

  • #2
    You'd need to use - regress - for that matter, but that is not a panel data structure anymore. You may use the time variable as a factor, but you need to check the assumptions for the pooled regression analysis in this scenario. Yes.
    Best regards,

    Marcos

    Comment


    • #3
      Sarah:
      as an aside to Marcos' helpful advice, please note:
      - -regress- rarely outperforms -xtreg- when it comes to panel data analysis;
      - in those rare instances, pooled OLS needs clustered standard errors: -vce(cluster panelid); otherwise, Stata will consider your observations as independent (which is not true for panel dataset);
      -pooled OLS does not need data to be -xtset- beforehand.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Even when I cluster, do I need to include the year variable as an independent variable in the regression?
        When I cluster standard errors, the results show "." for the F value and "Pr > F"
        Code:
        Linear regression                               Number of obs     =     10,418
                                                        F(44, 8981)       =          .
                                                        Prob > F          =          .
                                                        R-squared         =     0.2224
                                                        Root MSE          =     1.1673
        
                                                                                    (Std. Err. adjusted for 8,982 clusters in id)
        -------------------------------------------------------------------------------------------------------------------------
                                                                |               Robust
                                                       ideology |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        --------------------------------------------------------+----------------------------------------------------------------
                                                   partisanship |
                                               Strong Democrat  |          0  (base)
                                                 Weak Democrat  |   .0046774   .6089275     0.01   0.994    -1.188959    1.198314
                                        Independent - Democrat  |  -.0927612    .650655    -0.14   0.887    -1.368194    1.182671
                                     Independent - Independent  |  -.7757902    .696951    -1.11   0.266    -2.141973    .5903927
                                      Independent - Republican  |  -.5126019   .6688168    -0.77   0.443    -1.823635    .7984316
                                               Weak Republican  |   .3779365    .619436     0.61   0.542    -.8362994    1.592172
                                             Strong Republican  |    .070907   .6603656     0.11   0.914     -1.22356    1.365374
                                                                |
                                                           gini |  -.2376736   1.435403    -0.17   0.868     -3.05139    2.576043
                                                                |
                                            partisanship#c.gini |
                                                 Weak Democrat  |    1.16259    1.73815     0.67   0.504     -2.24458    4.569759
                                        Independent - Democrat  |    .941021   1.861296     0.51   0.613    -2.707544    4.589586
                                     Independent - Independent  |    4.15489   2.003504     2.07   0.038     .2275651    8.082214
                                      Independent - Republican  |   4.502688   1.918488     2.35   0.019     .7420146    8.263362
                                               Weak Republican  |   1.960276    1.77351     1.11   0.269    -1.516209    5.436761
                                             Strong Republican  |   4.504105   1.889499     2.38   0.017     .8002568    8.207954
                                                                |
                                                       agegroup |
                                                       17 - 24  |          0  (base)
                                                       25 - 34  |   .1828415   .0447554     4.09   0.000     .0951107    .2705722
                                                       35 - 44  |   .2798604   .0479967     5.83   0.000     .1857759    .3739449
                                                       45 - 54  |   .4003191    .050759     7.89   0.000     .3008199    .4998182
                                                       55 - 64  |   .3678654   .0539155     6.82   0.000     .2621787    .4735521
                                                        65- 74  |   .4472742   .0688137     6.50   0.000     .3123836    .5821649
                                              75 - 99 and over  |   .4038219   .0873067     4.63   0.000     .2326807     .574963
                                                                |
                                                            sex |
                                                          Male  |          0  (base)
                                                        Female  |  -.1096559   .0271185    -4.04   0.000    -.1628143   -.0564975
                                                                |
                                                          Black |
                                                            No  |          0  (base)
                                                           Yes  |  -.3910219   .0600558    -6.51   0.000     -.508745   -.2732988
                                                                |
                                                          Asian |
                                                            No  |          0  (base)
                                                           Yes  |   .3738355   .1861965     2.01   0.045     .0088479    .7388232
                                                                |
                                                       Hispanic |
                                                            No  |          0  (base)
                                                           Yes  |  -.0447577   .0720504    -0.62   0.534     -.185993    .0964776
                                                                |
                                                 AmericanIndian |
                                                            No  |          0  (base)
                                                           Yes  |  -.0820483   .1681501    -0.49   0.626    -.4116609    .2475643
                                                                |
                                                         region |
                                                     Northeast  |          0  (base)
                                                       Midwest  |   .0548613   .0329436     1.67   0.096    -.0097157    .1194383
                                                         South  |   .2082701   .0415744     5.01   0.000     .1267748    .2897654
                                                          West  |   .0175894   .0449426     0.39   0.696    -.0705083    .1056871
                                                                |
                                                      education |  -.0502062   .0149638    -3.36   0.001    -.0795387   -.0208737
                                                                |
                                                     employment |
                                                1. Working now  |          0  (base)
                                       2. Temporarily laid off  |   .0420828   .1183183     0.36   0.722    -.1898481    .2740136
                                                 4. Unemployed  |  -.0790482   .0741498    -1.07   0.286    -.2243988    .0663023
                                                    5. Retired  |  -.0116983   .0559228    -0.21   0.834    -.1213197    .0979232
                                       6. Permanently disabled  |  -.0636708   .1107712    -0.57   0.565    -.2808077    .1534661
                                                  7. Homemaker  |   .1428696   .0381717     3.74   0.000     .0680443    .2176948
                                                    8. Student  |  -.1566266   .0772453    -2.03   0.043     -.308045   -.0052082
                                                     9. NA; DK  |   3.003869   .0549856    54.63   0.000     2.896084    3.111653
                                                                |
                                                          union |
                  0. DK; NA; no Pre IW; short-form 'new' Cross  |          0  (base)
        1. Yes, someone (1948: head) in household belongs to a  |  -.0277703   .0300503    -0.92   0.355    -.0866757    .0311352
                                                                |
                                                         income |   .0257678    .013738     1.88   0.061    -.0011617    .0526974
                                                                |
                                                      religion2 |
                                                    Protestant  |          0  (base)
                                     Non-traditional Christian  |  -.0474245   .0825667    -0.57   0.566    -.2092741     .114425
                                                      Catholic  |  -.0809195   .0289501    -2.80   0.005    -.1376683   -.0241706
                                                        Jewish  |  -.6276536   .0707225    -8.87   0.000    -.7662857   -.4890214
                                              Eastern Orthodox  |  -.2105337   .1753325    -1.20   0.230    -.5542254     .133158
                                                        Muslim  |  -.0192561   .3785831    -0.05   0.959    -.7613653    .7228531
                                                      Buddhist  |  -1.367934   .2207422    -6.20   0.000    -1.800639   -.9352286
                                                         Hindu  |  -2.504343   .5161774    -4.85   0.000    -3.516168   -1.492517
                                                       Atheist  |  -.9662209   .1593526    -6.06   0.000    -1.278588   -.6538534
                                                                |
                                                          _cons |   2.540547   .5030692     5.05   0.000     1.554417    3.526678
        -------------------------------------------------------------------------------------------------------------------------

        Comment


        • #5
          Sarah:
          1) yes, you should add -i.year- even if you cluster your standard errors;
          2) see -help j_robustsingular- about missing F-test
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment

          Working...
          X