Announcement

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

  • Forming panel data fixed effects using sub-sampled data

    Hello,

    I am very new to Stata and i do not know how to form the right regression. I am testing the effect of corruption on economic growth represented in the time period 1996 to 2016. I will be testing the results by splitting the data into developed and developing countries using a dummy variable, developing=0, developed=1. I will also be representing the corruption variable as a lag.

    Before forming my regression, i want to group my data using five year periods.
    Through doing this

    egen country_id = group(country)

    gen period1 = 1 if year >= 1996 & year < 2001
    replace period1 = 2 if year >= 2001 & year < 2006
    replace period1 = 3 if year >= 2006 & year < 2011
    replace period1 = 4 if year >= 2011 & year < 2017

    collapse(mean) GDPpercapitagrowth RealGDPpercapita FDI Populationrate Corruptioncontrolindex TradeOpenness PoliticalStability, by (period1 country)

    If i am to generate the lag, will i have to do this before grouping the data or after ?

  • #2
    Aiyana:
    welcome to this forum.
    If you have annual data, why grouping them in 5-year waves?
    Last edited by Carlo Lazzaro; 25 Apr 2022, 10:39.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Aiyana:
      welcome to this forum.
      If you have annual data, why groupong them in 5-year waves?
      Sometimes you use low frequency data to test the robustness of the results from annual data.


      Before forming my regression, i want to group my data using five year periods.
      Through doing this

      egen country_id = group(country)

      gen period1 = 1 if year >= 1996 & year < 2001
      replace period1 = 2 if year >= 2001 & year < 2006
      replace period1 = 3 if year >= 2006 & year < 2011
      replace period1 = 4 if year >= 2011 & year < 2017
      An easier way to do this is to use the -ceiling()- or -floor()- functions.

      Code:
      gen period= ceil((year-1995)/5)

      If i am to generate the lag, will i have to do this before grouping the data or after ?
      Use the lag operators in the regression. You have 4 observations per country after collapsing the data, so taking lags is really stretching your data. But the following will work.

      Code:
      collapse GDPpercapitagrowth RealGDPpercapita FDI Populationrate Corruptioncontrolindex TradeOpenness PoliticalStability, by (period country)
      xtset country period
      xtreg yvar xvars L.Corruption, fe
      Last edited by Andrew Musau; 25 Apr 2022, 10:52.

      Comment


      • #4
        Andrew:
        thanks for pointing this out.
        I've never came across something similar in health economics.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          It is common in macroeconomics, see e.g., Table 2 in Acemoglu et al. (2008).

          Reference

          Acemoglu, Daron, Simon Johnson, James A. Robinson, and Pierre Yared. 2008. "Income and Democracy." American Economic Review, 98 (3): 808-42.
          Last edited by Andrew Musau; 25 Apr 2022, 11:39.

          Comment


          • #6
            Thanks again, Andrew.
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment


            • #7
              Hello, thank you for this.

              When generating my lags, i seem to notice there is an error saying "no observations". I am not quite sure what to do?

              Comment


              • #8
                You lose a cross-section with lagging, assuming a balanced panel. If the panel is unbalanced, you can lose even more cross-sections. Secondly, fixed effects requires a minimum of two cross-sections. Doing the math, you start with 4 cross-sections after collapsing the data. You can afford to lose only the first or the last cross-section as a result of missing values. If missing values are not the issue, make sure that you have the correct xtsettings after collapsing the data. From #3

                Code:
                xtset country period
                The previous time variable (year) is no longer valid with the collapsed data.
                Last edited by Andrew Musau; 30 Apr 2022, 16:50.

                Comment


                • #9
                  Yes, i do have some gaps in my data. Would that mean i would have to remove some countries or would there be a different command i could use?

                  Comment


                  • #10
                    If there were some observations for some countries, then you would not get a "no observations" error. Therefore, dropping some countries will not help. If you can share your dataset after the collapse, we may be able to verify whether the issue is missing observations. If that turns out to be the case, there is not much that you can do beyond finding alternative data sources.

                    Comment


                    • #11
                      Can you copy and paste the result of this instead?

                      Code:
                      dataex if regexm(country, "^A")

                      Comment


                      • #12
                        Sensitive data removal.
                        Last edited by sladmin; 03 May 2022, 08:39. Reason: Removed sensitive data per user request.

                        Comment


                        • #13
                          Thank you. Your data are fine, it is just that you did not create a consecutive period variable, so the lagging will not be implemented correctly. You need

                          Code:
                          xtset country_id period, delta(5)
                          or

                          Code:
                          egen newperiod= group(period)
                          xtset country_id newperiod

                          Notice that my suggestion in #3 will create the consecutive period variable.
                          Last edited by Andrew Musau; 01 May 2022, 07:45.

                          Comment


                          • #14
                            It works now, thank you

                            Comment

                            Working...
                            X