Announcement

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

  • Panel data including interest yearly for each city

    I was wondering if I had to include interest which is yearly calculated for Holland to give each city each year the interest rate.

    So for example:
    Year 1 interest rate=2%
    Year 2 interest rate=3%
    City 1 in year 1:2%
    City 2 in year 2:3%
    Is this the correct way?

  • #2
    Adam:
    your should -reshapre- your data in -long- format (unless they are laid out this way already), as most of the Stata commands work at their best in -long- format.
    As you have a panel dataset, you shoud have a variable -city-, (that I assume to be your -panelid- or the cross-sectional dimension of your dataset) a variable -year- (which is the -timevar- or the time-series dimension of your panel dataset) and a variable -interest_rate- (you surely have other predictors and controls in the right-hand side of your regression equation):
    Code:
    set obs 2
    g id_city=1
    g year=2020 + _n
    g interest_rate=0.02 in 1
    replace interest_rate=0.03 in 2
    expand 2
    replace id=2 in 3/4
    list
         +---------------------------+
         | id_city   year   intere~e |
         |---------------------------|
      1. |       1   2021        .02 |
      2. |       1   2022        .03 |
      3. |       2   2021        .02 |
      4. |       2   2022        .03 |
         +---------------------------+
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Adam:
      your should -reshapre- your data in -long- format (unless they are laid out this way already), as most of the Stata commands work at their best in -long- format.
      As you have a panel dataset, you shoud have a variable -city-, (that I assume to be your -panelid- or the cross-sectional dimension of your dataset) a variable -year- (which is the -timevar- or the time-series dimension of your panel dataset) and a variable -interest_rate- (you surely have other predictors and controls in the right-hand side of your regression equation):
      Code:
      set obs 2
      g id_city=1
      g year=2020 + _n
      g interest_rate=0.02 in 1
      replace interest_rate=0.03 in 2
      expand 2
      replace id=2 in 3/4
      list
      +---------------------------+
      | id_city year intere~e |
      |---------------------------|
      1. | 1 2021 .02 |
      2. | 1 2022 .03 |
      3. | 2 2021 .02 |
      4. | 2 2022 .03 |
      +---------------------------+
      
      .
      Thanks a lot for your time to answer my question.
      So in my data set this would be correct?
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float GM_code int Year double Interest
      1 2000      5.405
      1 2001 4.95833333
      1 2002       4.89
      1 2003      4.095
      1 2004      4.095
      1 2005 3.37416667
      1 2006 3.78083333
      1 2007 4.28666667
      1 2008 4.22666667
      1 2009 3.68666667
      1 2010 2.99166667
      1 2011 2.98916667
      1 2012 1.93416667
      1 2013 1.96083333
      1 2014      1.455
      1 2015  .69083333
      1 2016      .2925
      1 2017      .5225
      1 2018  .57666667
      1 2019       -.07
      1 2020  -.3766667
      2 2000      5.405
      2 2001 4.95833333
      2 2002       4.89
      2 2003      4.095
      2 2004      4.095
      2 2005 3.37416667
      2 2006 3.78083333
      2 2007 4.28666667
      2 2008 4.22666667
      2 2009 3.68666667
      2 2010 2.99166667
      2 2011 2.98916667
      2 2012 1.93416667
      2 2013 1.96083333
      2 2014      1.455
      2 2015  .69083333
      2 2016      .2925
      2 2017      .5225
      2 2018  .57666667
      2 2019       -.07
      2 2020  -.3766667
      3 2000      5.405
      3 2001 4.95833333
      3 2002       4.89
      3 2003      4.095
      3 2004      4.095
      3 2005 3.37416667
      3 2006 3.78083333
      3 2007 4.28666667
      3 2008 4.22666667
      3 2009 3.68666667
      3 2010 2.99166667
      3 2011 2.98916667
      3 2012 1.93416667
      3 2013 1.96083333
      3 2014      1.455
      3 2015  .69083333
      3 2016      .2925
      3 2017      .5225
      3 2018  .57666667
      3 2019       -.07
      3 2020  -.3766667
      4 2000      5.405
      4 2001 4.95833333
      4 2002       4.89
      4 2003      4.095
      4 2004      4.095
      4 2005 3.37416667
      4 2006 3.78083333
      4 2007 4.28666667
      4 2008 4.22666667
      4 2009 3.68666667
      4 2010 2.99166667
      4 2011 2.98916667
      4 2012 1.93416667
      4 2013 1.96083333
      4 2014      1.455
      4 2015  .69083333
      4 2016      .2925
      4 2017      .5225
      4 2018  .57666667
      4 2019       -.07
      4 2020  -.3766667
      5 2000      5.405
      5 2001 4.95833333
      5 2002       4.89
      5 2003      4.095
      5 2004      4.095
      5 2005 3.37416667
      5 2006 3.78083333
      5 2007 4.28666667
      5 2008 4.22666667
      5 2009 3.68666667
      5 2010 2.99166667
      5 2011 2.98916667
      5 2012 1.93416667
      5 2013 1.96083333
      5 2014      1.455
      5 2015  .69083333
      end

      Comment


      • #4
        Adam:
        if -GM_code- is your -panelid- your dataset is in -long- format and you'll have no problem in running your regression.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          Originally posted by Carlo Lazzaro View Post
          Adam:
          if -GM_code- is your -panelid- your dataset is in -long- format and you'll have no problem in running your regression.
          Thanks a lot!

          Comment

          Working...
          X