Announcement

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

  • 3 dimentional panel dataset and fixed effect control

    Hello, everyone,
    I have a very simple request:

    I am working the effect of specific crises on the sectoral GVA, and in the left sid, I have three dimention (s,i,t), while my shock is at the country level. I use the local projection of jorda (2005).
    and I want to see the effect of the crises on the sectoral GVA.

    I am not sure about the control fixed effect.
    since I have a three dimentional dataset, I have to control for country-sector and sector-time fe.



    1) is it correct that I doing?

    Code:
    xtscc gva_sector_0 l(0/1).recession L(1/2).institutions  L(1/2).bankcrisis L(1/2).debtcrisis L(1/2).inflation l(1/1).gva_sector_0 i.country_ind  i.time_ind, fe

    Or, becasue the country-sector fixed effect already drop by "xtset country_ind year ", I should not add it in the model?


    2) when I used the reghdfe insted of the xtscc, my point estimate is not the same, however I underestood that the only difference between these to is SE.

    Code:
    reghdfe gva_sector_0 l(0/1).recession L(1/2).institutions  L(1/2).bankcrisis L(1/2).debtcrisis L(1/2).inflation l(1/1).gva_sector_0 , absorb(i.country_ind    i.time_ind) vce(cluster ifscode)

    I am not sude how to add this control in the model.

    thanks in advance for any help.




    Code:
    egen country_ind=group(ifscode sector_id)
    egen country_time=group(ifscode year)
    egen time_ind=group(year sector_id)
    xtset country_ind year



    . dataex ifscode year sector_id GVA_sector institutions bankcrisis debtcrisis inflation r
    > ecession

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int ifscode double year float(sector_id gva_sector institutions bankcrisis debtcrisis inflation recession)
    111 1973 2      .875   1.56345 0 0  .06034303 0
    111 1973 3         1   1.56345 0 0  .06034303 0
    111 1973 1  .5555556   1.56345 0 0  .06034303 0
    111 1973 4  .3809524   1.56345 0 0  .06034303 0
    111 1974 1  .5555556   1.71753 0 0  .10467768 0
    111 1974 3         1   1.71753 0 0  .10467768 0
    111 1974 2         1   1.71753 0 0  .10467768 0
    111 1974 4  .3809524   1.71753 0 0  .10467768 0
    111 1975 3         1  1.778193 0 0  .08738732 0
    111 1975 1  .5555556  1.778193 0 0  .08738732 0
    111 1975 4  .3809524  1.778193 0 0  .08738732 0
    111 1975 2         1  1.778193 0 0  .08738732 0
    111 1976 4  .3809524 1.7866578 0 0  .05578494 0
    111 1976 3         1 1.7866578 0 0  .05578494 0
    111 1976 2         1 1.7866578 0 0  .05578494 0
    111 1976 1  .5555556 1.7866578 0 0  .05578494 0
    111 1977 4  .3809524   1.82757 0 0  .06284785 0
    111 1977 3         1   1.82757 0 0  .06284785 0
    111 1977 2         1   1.82757 0 0  .06284785 0
    111 1977 1  .5555556   1.82757 0 0  .06284785 0
    111 1978 2         1   1.82757 0 0  .07369137 0
    111 1978 3         1   1.82757 0 0  .07369137 0
    111 1978 5   .930355   1.82757 0 0  .07369137 0
    111 1978 4  .3809524   1.82757 0 0  .07369137 0
    111 1978 1  .5555556   1.82757 0 0  .07369137 0
    111 1979 1  .5555556 1.8261594 0 0  .09059691 0
    111 1979 4  .3809524 1.8261594 0 0  .09059691 0
    111 1979 2         1 1.8261594 0 0  .09059691 0
    111 1979 5   .930355 1.8261594 0 0  .09059691 0
    111 1979 3         1 1.8261594 0 0  .09059691 0
    111 1980 1  .7222222  1.826495 0 0   .1053605 0
    111 1980 5  .9355956  1.826495 0 0   .1053605 0
    111 1980 3         1  1.826495 0 0   .1053605 0
    111 1980 4  .3809524  1.826495 0 0   .1053605 0
    111 1980 2         1  1.826495 0 0   .1053605 0
    111 1981 1  .7222222 1.8737898 0 0  .09172463 0
    111 1981 3         1 1.8737898 0 0  .09172463 0
    111 1981 5  .9426824 1.8737898 0 0  .09172463 0
    111 1981 4  .3809524 1.8737898 0 0  .09172463 0
    111 1981 2         1 1.8737898 0 0  .09172463 0
    111 1982 3         1 1.8737898 0 0  .05859399 0
    111 1982 2         1 1.8737898 0 0  .05859399 0
    111 1982 4  .3809524 1.8737898 0 0  .05859399 0
    111 1982 1  .8333333 1.8737898 0 0  .05859399 0
    111 1982 5  .9430157 1.8737898 0 0  .05859399 0
    111 1983 5  .9478928 1.8709682 0 0  .04114723 0
    111 1983 4  .3809524 1.8709682 0 0  .04114723 0
    111 1983 2         1 1.8709682 0 0  .04114723 0
    111 1983 1  .8333333 1.8709682 0 0  .04114723 0
    111 1983 3         1 1.8709682 0 0  .04114723 0
    111 1984 1  .8333333  1.872379 1 0    .041394 0
    111 1984 5  .9499953  1.872379 1 0    .041394 0
    111 1984 3         1  1.872379 1 0    .041394 0
    111 1984 2         1  1.872379 1 0    .041394 0
    111 1984 4 .52380955  1.872379 1 0    .041394 0
    111 1985 4 .52380955  1.878022 0 0 .033131838 0
    111 1985 2         1  1.878022 0 0 .033131838 0
    111 1985 3         1  1.878022 0 0 .033131838 0
    111 1985 1  .8333333  1.878022 0 0 .033131838 0
    111 1985 5  .9546942  1.878022 0 0 .033131838 0
    111 1986 1  .8333333 1.8766114 0 0 .018535614 0
    111 1986 4 .52380955 1.8766114 0 0 .018535614 0
    111 1986 5  .9547356 1.8766114 0 0 .018535614 0
    111 1986 3         1 1.8766114 0 0 .018535614 0
    111 1986 2         1 1.8766114 0 0 .018535614 0
    111 1987 5  .9547356 1.8695575 0 0  .03263712 0
    111 1987 1  .8333333 1.8695575 0 0  .03263712 0
    111 1987 3         1 1.8695575 0 0  .03263712 0
    111 1987 4 .52380955 1.8695575 0 0  .03263712 0
    111 1987 2         1 1.8695575 0 0  .03263712 0
    111 1988 5  .9547356 1.8709682 0 0  .03603983 0
    111 1988 3         1 1.8709682 0 0  .03603983 0
    111 1988 4 .52380955 1.8709682 0 0  .03603983 0
    111 1988 2         1 1.8709682 0 0  .03603983 0
    111 1988 1  .8333333 1.8709682 0 0  .03603983 0
    111 1989 5  .9550222 1.8737898 0 0  .04223704 0
    111 1989 4 .52380955 1.8737898 0 0  .04223704 0
    111 1989 1  .8333333 1.8737898 0 0  .04223704 0
    111 1989 3  .9702252 1.8737898 0 0  .04223704 0
    111 1989 2         1 1.8737898 0 0  .04223704 0
    111 1990 3  .9702252 1.8752005 0 0  .04813337 0
    111 1990 5  .9555556 1.8752005 0 0  .04813337 0
    111 1990 2         1 1.8752005 0 0  .04813337 0
    111 1990 4 .52380955 1.8752005 0 0  .04813337 0
    111 1990 1  .8333333 1.8752005 0 0  .04813337 0
    111 1991 1  .8888889 1.8794328 0 0 .035735846 0
    111 1991 5  .9546667 1.8794328 0 0 .035735846 0
    111 1991 2         1 1.8794328 0 0 .035735846 0
    111 1991 4 .52380955 1.8794328 0 0 .035735846 0
    111 1991 3  .9702252 1.8794328 0 0 .035735846 0
    111 1992 1  .8888889 1.8808436 0 0  .02456188 0
    111 1992 2         1 1.8808436 0 0  .02456188 0
    111 1992 4 .52380955 1.8808436 0 0  .02456188 0
    111 1992 5  .9554667 1.8808436 0 0  .02456188 0
    111 1992 3  .9702252 1.8808436 0 0  .02456188 0
    111 1993 5     .9568 1.8688853 0 0  .02490139 0
    111 1993 2         1 1.8688853 0 0  .02490139 0
    111 1993 4 .52380955 1.8688853 0 0  .02490139 0
    111 1993 3  .9702252 1.8688853 0 0  .02490139 0
    111 1993 1  .8888889 1.8688853 0 0  .02490139 0
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 16968 observations
    Use the count() option to list more


  • #2
    looks like your missing a fixed effect in the reghdfe. what is "fe" getting in xtscc?

    Comment


    • #3
      @George Ford thanks for your respond.

      I’m dealing with a specific (and potentially confusing for me) issue.
      In my panel dataset in Stata, the dependent variable is available for 1973–2014, while the shock and other control variables span 1870–2022 (they have missing value in some years).

      As a rule, I would expect the regression to end up using 1973–2014. My confusion is: before running the regression, should I manually restrict the data with
      keep if year >= 1973 & year <= 2014,
      or does Stata handle this automatically within the regression?

      The reason I’m asking is that, if I don’t restrict the data, my results aren’t great; but if I limit the sample to the years where the dependent variable is available, I get statistically significant and more promising results.
      because I was thinking it is a huge gap. But also, the stata I read will ends up to dependent variable availability.




      withourrestricting.gphwithrestricting.gph

      Thanks in advance,
      Attached Files
      Last edited by Khati Zolfaghari; 04 Sep 2025, 04:00.

      Comment


      • #4
        STATA will exclude anything with missings. If you're getting different results, then I don't know why but there's a reason (may be related to xtscc). But there's no reason to include data with missing DV.

        G

        Comment

        Working...
        X