Announcement

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

  • Controlling for averages of lags

    Dear Stata community,

    I'm using panel regression using data of 100 countries over 22 years to estimate the effect of financial openness on economic development. However, I'm running into an endogeneity problem: Openness may lead to higher growth, but countries that expect to grow a lot may tend to open up their economies. To control for this issue I want to control for recent growth trends. Specifically, I want to control for the average growth rate over the past three years. I'm not sure if there is an easy way to add this into the regression or if I have to create new variables. Does anyone have an idea how to do this?

    Thank you in advance for your time.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str42 country int year float loggdppc double(ka gdppcg)
    "Algeria" 1995 9.137277                 1 1.853423792861392
    "Algeria" 1996 9.160067               .75 2.305087244845765
    "Algeria" 1997 9.154971                 1 -.508245295794012
    "Algeria" 1998 9.189805               .75 3.544786287223985
    "Algeria" 1999 9.207232               .75 1.758011109300668
    "Algeria" 2000 9.231221              .875 2.427875700928467
    "Algeria" 2001 9.247847              .875 1.676475843908534
    "Algeria" 2002 9.289751 .9285714285714286 4.279453026560546
    "Algeria" 2003 9.346609 .9285714285714286 5.850520833432341
    "Algeria" 2004 9.375616 .9285714285714286 2.943232296389624
    end

  • #2
    I came up with a solution, it was actually easier than I thought. I created a variable country2 which numbers countries from 1 to 100. Then I used this code:

    Code:
    gen avgg3 = .
    levelsof country2, local(levels)
    foreach l of local levels {
    replace avgg3 = (L.gdppcg + L2.gdppcg + L3.gdppcg)/3 if country2 == `l'
    }

    Comment

    Working...
    X