Announcement

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

  • Multiple regression with two conditions for one variable

    Hi,

    I'm studying the affect from social infrastructure on economic growth, and how it changes over time. Because of lack of data I want to run three different regressions depending on how many years has passed since independence. In the first regression I want years 1-14. Would it be best to generate a new variable or can I have a condition in the code for the regression?

    This is the code I want to run:
    qui reg g_gdp length GB g_prim1 g_death patent1 polity2 length_g_prim1 length_g_death length_patent1 length_polity2 g_capital g_gov_con g_trade g_pop initial_gdp
    qui outreg using Thesis.doc, nocons addrow(Country fixed effects,yes \ Country-specific time trends,yes) se bdec (3) starlevels(10 5 1) sigsymbols(*,**,***) starloc(1) summstat(r2 \ rmse \ N) summtitle(R-squared \ Root mean square error \ Observations) summdec(2 2 0) title(Table 2. \ The effect from Social infrastructure on economic growth \ Dependent Variable: GDP growth) ctitle("", "" \ "Explanatory Variables" \ "" "(1) year 1-14") blankrows nolegend varlabels replace


    It is for the variable length, that I only want to include the values 1-14. Does anyone have any suggestions for how I should go about this?

  • #2
    Code:
    qui reg g_gdp length GB ... g_pop initial_gdp if inrange(length,1,14)
    For an explanation of this syntax see the output of
    Code:
    help if

    Comment


    • #3
      Thank you!

      Comment


      • #4
        I also want to just include some of the countries in the different regressions. I try to write:

        qui reg g_gdp length GB1 g_prim1 g_death patent1 polity2 length_g_prim1 length_g_death length_patent1 length_polity2 g_gov_con g_trade g_pop initial_gdp i.year if country == "Benin" | country == "Burkina Faso" | country == "Botswana" | country == "Central African Republic" | country == "Côte d'Ivoire" | country == "Congo" | country == "Algeria" | country == "Gabon" | country == "Kenya" | country == "Madagascar" | country == "Niger" | country == "Chad" | country == "Togo" if inrange(length, 1, 14), fe
        qui outreg using Thesis.doc, nocons addrow(Country fixed effects,yes) se bdec (3) starlevels(10 5 1) sigsymbols(*,**,***) starloc(1) summstat(r2 \ rmse \ N) summtitle(R-squared \ Root mean square error \ Observations) summdec(2 2 0) title(Table 2. \ The Effect from Social Infrastructure on Economic Growth \ Dependent Variable: GDP Growth) ctitle("", "" \ "Explanatory Variables" \ "" "(1) Year 1-14") blankrows nolegend varlabels replace


        But when I add the countries I get the error message invalid syntax. How should I write it?

        Comment


        • #5
          Code:
          if country == "Benin" | country == "Burkina Faso" | ... | country == "Chad" | country == "Togo" if inrange(length, 1, 14)
          should be
          Code:
          if ( country == "Benin" | country == "Burkina Faso" | ... |  == "Chad" | country == "Togo" ) & inrange(length, 1, 14)

          Comment


          • #6
            Thanks!

            Comment

            Working...
            X