Announcement

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

  • Scatter plot for the country fixed effects and the gdp growth after running a fixed effect regression.

    Hi

    I try to replicate an equation from the Paper of Nazrul Islam (1995). It's about the Solow Model.

    I ran the following fixed-effects regression:
    Code:
    encode countrycode, generate(countrycode_numeric)
    xtset countrycode_numeric year
    
    xtreg gdp_growth x ln_gdp_pc_t_1 if OECD == 1, fe vce(robust)
    Click image for larger version

Name:	Bild 08.03.23 um 19.43.jpeg
Views:	1
Size:	186.0 KB
ID:	1704934


    Now I'm trying to plot the fixed effects on the y-axis and the gdp_growth on the x-axis. At the moment, I got just the following scatter plot:
    Code:
    xtreg gdp_growth x ln_gdp_pc_t_1 if OECD == 1, fe vce(robust)
    scatter countrycode_numeric gdp_growth
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	437.5 KB
ID:	1704936



    Has anyone an idea, how I can create the scatter plot with the fixed effects on the y-axis, the gdp growth on the x-axis and each country should only be once included.

    Thanks in advance for your help.

    I used STATA 17.0
    Attached Files

  • #2
    compute a mean of gdp growth and scatter on that.

    Comment


    • #3
      Thanks George for your answer. I computed the mean. But now I'm struggeling with plotting the fixed effects. The goal is to plot the gdp_growth together with the country fixed-effects. If I interpret the output correctly, then is the constant the fixed-effect for the reference country. For the others countries fixed-effects, I have to add the specific fixed-effect of the country, right? Have you any idea how to solve that?
      Last edited by Severin Voll; 09 Mar 2023, 04:59.

      Comment


      • #4
        For the better understanding of my problem, here is my plot, which is not correct:
        Click image for larger version

Name:	Scatterplot_gdp_FE.png
Views:	1
Size:	233.6 KB
ID:	1705060

        Comment


        • #5
          This is perhaps a kluge, but it might work.

          I got data for 10 countries from OECD on GDP and GDFC (the X).

          Code:
          g lgdp = ln(gdp)
          g lgcfc = ln(gcfc)
          
          bys cid: egen gdp_m = mean(gdp)
          g lgdp_m = ln(gdp_m)
          
          reg lgdp lgcfc i.cid i.time 
          matrix B = r(table)
          matrix F = J(10,2,.)
          forv i = 1/10 {
              local j = `i'+1
              matrix F[`i',1] = _b[_cons]+B[1,`j']
              summ lgdp_m if cid==`i'
              matrix F[`i',2] = r(mean)
          }
          svmat F
          ren F1 FE
          ren F2 lnGDP
          scatter F lnGDP
          Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	13.0 KB
ID:	1705154



          Attached Files

          Comment


          • #6
            Thanks a lot for your code. I tried to implement it, but I just got one point in my scatter plot. Here is the code I used:
            Code:
            xtreg gdp_growth x ln_gdp_pc_t_1 if OECD == 1, fe vce(robust)
            matrix B = r(table)
            matrix F = J(24,2,.)
            forv i = 1/24 {
                local j = `i'+1
                matrix F[`i',1] = _b[_cons]+B[1,`j']
                summ mean_gdp_growth if countrycode_numeric==`i'
                matrix F[`i',2] = r(mean)
            }
            svmat F
            ren F1 FE
            ren F2 gdp_growth_rates
            scatter F gdp_growth
            The OECD variable is a dummy variable for the 24 OECD-countries. Did I made a mistake in the code? Is this part of the code
            Code:
            matrix F[`i',1] = _b[_cons]+B[1,`j']
            for the country fixed-effects?

            In my output above, there I got the constant of 0.63. This is the country fixed effects for the reference country, if I understand it correctly. Is there a command, where I can list the specific country fixed-effects?

            Comment


            • #7
              I didn't use xtreg so I could see the coefficients.

              This is better and can be used with xtreg.

              Code:
              xtreg lgdp lgcfc , fe 
              predict fit1, xb
              predict fit2, xbu
              g fe = fit2-fit1
              scatter fe lgdp_m, mlabel(location)

              Comment


              • #8
                you could also pick a year of choice by adding "if year == x" to the scatter and replacing lgdp_m with lgdp. may make sense to restrict to a year even with lgdp_m since everything is the same across years.

                Comment


                • #9
                  btw, xb is the fit without the FE and xbu is fit with the FE. so the difference is the FE.

                  Comment


                  • #10
                    Actually, you can just predict u, since that's the fixed effect.

                    Comment


                    • #11
                      Thank you very much for your help. This here is now my Code and it seems to be right.
                      Code:
                      // Just OECD
                      xtreg gdp_growth x ln_gdp_pc_t_1 if OECD==1, fe vce(robust)
                      predict F1_o, xb
                      predict F2_o, xbu
                      gen OECD_country_FE = F2_o-F1_o
                      scatter OECD_country_FE mean_gdp_growth, mlabel(countrycode)
                      
                      
                      // all countries
                      xtreg gdp_growth x ln_gdp_pc_t_1, fe vce(robust)
                      predict F1, xb
                      predict F2, xbu
                      gen country_FE = F2-F1
                      graph twoway (lfit country_FE mean_gdp_growth) scatter country_FE mean_gdp_growth, saving(Country_effects_all.png, replace) title("Country Fixed-Effects 1960-1985") note("Source: Penn World Table version 10.01", size(5pt) pos(7)) ytitle("Country Fixed-Effects") xtitle("Mean of the gdp growth rates") legend(label(1 "linear prediction") label(2 "Country Fixed-Effects"))
                      Country_effects_all.pngOECD_Scatter_10.03.2023.png



                      Now I cha another question. The constant of my -xtreg-, fe regression is 0.63. This should also be a part of the country fixed effects, or not? In the left plot, is there a reference country for the country fixed effects included i.e. the first country in the dataset?

                      When I'm running the almost the same command, however instead of -xtreg- I use reg with i.country, then are the coefficients for the countries the FE?

                      Following, you see my output for the FE-Regression.

                      Attached Files

                      Comment


                      • #12
                        See if this gets you there. A bit tighter.

                        Code:
                         
                         xtreg gdp_growth x ln_gdp_pc_t_1 if OECD==1, fe vce(robust) predict OECD_country_FE, u scatter OECD_country_FE mean_gdp_growth, mlabel(countrycode)
                        To the scatter, I might add ylabel(0(.025),0.075), just toi spread it out a bit


                        Comment


                        • #13
                          Thank you for your help.
                          Below, you see my command for the country fixed-regression and the scatter plot with the output from the regression. I made a little change in the syntax. Now, I'm taking all years and countries into account.
                          Code:
                          xtreg gdp_growth x ln_gdp_pc_t_1 if year_60_19==1, fe vce(robust) 
                          predict OECD_country_FE, u 
                          scatter OECD_country_FE mean_gdp_growth, mlabel(countrycode)
                          Click image for larger version

Name:	statalist.png
Views:	2
Size:	414.7 KB
ID:	1705347


                          And here the output:
                          Click image for larger version

Name:	Bildschirm*foto 2023-03-11 um 15.38.48.png
Views:	1
Size:	175.1 KB
ID:	1705348


                          Do you think, the scatter plot is fitting with this output?

                          Best regards,
                          Severin
                          Attached Files

                          Comment


                          • #14
                            Looks like you got it figured out.

                            Comment

                            Working...
                            X