Announcement

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

  • Rolling regression for calculating expected inflation rate.

    Dear all,

    Suppose I have the following dataset:

    clear
    input int year double(inf gdp)
    1990 5.72458974 3.9071139
    1991 6.68398563 9.29407591
    1992 8.19824765 14.21616358
    1993 15.20220481 13.86757602
    1994 20.60060944 13.05215872
    1995 13.6705391 10.94922737
    1996 6.50109595 9.92837246
    1997 1.62216042 9.23076923
    1998 -.89258936 7.83761392
    1999 -1.26840965 7.66748617
    2000 2.06146138 8.49150849
    2001 2.04311501 8.33991055
    2002 .60485066 9.13064594
    2003 2.60544121 10.03560303
    2004 6.9543218 10.11122346
    2005 3.90263978 11.39577594
    2006 3.92791085 12.71947902
    2007 7.74917984 14.23138804
    2008 7.79180194 9.65428937
    2009 -.2105339 9.39981317
    2010 6.88114487 10.63614046
    2011 8.07559638 9.55091409
    2012 2.33512068 7.85962749
    2013 2.16101914 7.76861528
    2014 .791193 7.29951892
    2015 .06269939 6.90531667
    2016 1.07275629 6.73667525
    2017 3.88416989 6.75700761
    2018 2.93333231 6.56697386
    end

    I'd would like to calculate the expected inflation rate by using the t+1 real inflation rate as the dependent variable(the inf in the dataset) and the t real inflation rate and t real GDP(the gdp in the dataset) growth rate as independent variables. How can I construct my codes to reach this goal?

    Note: this regression is based on the thoery of Phillips Curve.

  • #2
    if I change the dataset like this:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year double(inf gdp) float(inf1 gdp1)
    1990  5.72458974   3.9071139          .         .
    1991  6.68398563  9.29407591    5.72459  3.907114
    1992  8.19824765 14.21616358   6.683986  9.294076
    1993 15.20220481 13.86757602   8.198248 14.216164
    1994 20.60060944 13.05215872  15.202205 13.867576
    1995  13.6705391 10.94922737   20.60061 13.052158
    1996  6.50109595  9.92837246   13.67054 10.949227
    1997  1.62216042  9.23076923   6.501096  9.928372
    1998  -.89258936  7.83761392  1.6221604  9.230769
    1999 -1.26840965  7.66748617  -.8925893  7.837614
    2000  2.06146138  8.49150849 -1.2684096  7.667486
    2001  2.04311501  8.33991055  2.0614614 8.4915085
    2002   .60485066  9.13064594   2.043115 8.3399105
    2003  2.60544121 10.03560303   .6048506  9.130646
    2004   6.9543218 10.11122346   2.605441 10.035603
    2005  3.90263978 11.39577594   6.954322 10.111223
    2006  3.92791085 12.71947902    3.90264 11.395776
    2007  7.74917984 14.23138804   3.927911  12.71948
    2008  7.79180194  9.65428937    7.74918 14.231388
    2009   -.2105339  9.39981317   7.791802  9.654289
    2010  6.88114487 10.63614046  -.2105339  9.399813
    2011  8.07559638  9.55091409   6.881145  10.63614
    2012  2.33512068  7.85962749   8.075597  9.550914
    2013  2.16101914  7.76861528  2.3351207  7.859628
    2014     .791193  7.29951892   2.161019  7.768615
    2015   .06269939  6.90531667    .791193  7.299519
    2016  1.07275629  6.73667525  .06269939  6.905317
    2017  3.88416989  6.75700761  1.0727563  6.736675
    2018  2.93333231  6.56697386    3.88417  6.757008
    end
    and use code as following:
    Code:
    Code:
    tsset year
    rolling,recursive window(1) clear:reg inf inf1 gdp1
    I am sure my codes are incorrect but I don't how to make it works.
    Last edited by Sc Meng; 08 Jan 2020, 09:34.

    Comment


    • #3
      I am confused. I read your regression as

      Code:
      reg inf L.inf gdp1
      and don't understand how rolling enters into it.

      Comment


      • #4
        Originally posted by Nick Cox View Post
        I am confused. I read your regression as

        Code:
        reg inf L.inf gdp1
        and don't understand how rolling enters into it.
        Maybe I misunderstand the code of rolling command.
        Last edited by Sc Meng; 08 Jan 2020, 09:58.

        Comment


        • #5
          Sure, I see and saw your code, but it doesn't match your word description,

          t+1 real inflation rate as the dependent variable(the inf in the dataset) and the t real inflation rate and t real GDP(the gdp in the dataset) growth rate as independent variable

          Comment


          • #6
            Originally posted by Nick Cox View Post
            Sure, I see and saw your code, but it doesn't match your word description,
            Yes, that's the main problem. I don't how to use it to reach my purpose. Thanks very much, still.

            In terms of "t+1 real inflation rate as the dependent variable(the inf in the dataset) and the t real inflation rate and t real GDP(the gdp in the dataset) growth rate as independent variable", I think I should add information like for each current period we need to regress all the former observations before the period, maybe like:

            For 1991's real inflation rate, it needs regression with 1990's real inflation rate and real GDP growth rate.
            For 1992's real inflation rate, it needs regression with 1991's and 1990's real inflation rate and real GDP growth rate.
            ......etc.
            And the fitted values are the expected inflation rate I need.

            If I do not make mistakes in understanding the method of calculating the expected inflation.

            I am so sorry for making you confused.
            Last edited by Sc Meng; 08 Jan 2020, 10:54.

            Comment


            • #7
              OK, With rangestat installed

              Code:
              ssc install rangestat

              you can do this, The results necessarily conflate artefacts of small sample size and any progressive change in the relationship. You need a minimum of 4 data points to fit 3 parameters too.

              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input int year double(inf gdp) float(inf1 gdp1)
              1990  5.72458974   3.9071139          .         .
              1991  6.68398563  9.29407591    5.72459  3.907114
              1992  8.19824765 14.21616358   6.683986  9.294076
              1993 15.20220481 13.86757602   8.198248 14.216164
              1994 20.60060944 13.05215872  15.202205 13.867576
              1995  13.6705391 10.94922737   20.60061 13.052158
              1996  6.50109595  9.92837246   13.67054 10.949227
              1997  1.62216042  9.23076923   6.501096  9.928372
              1998  -.89258936  7.83761392  1.6221604  9.230769
              1999 -1.26840965  7.66748617  -.8925893  7.837614
              2000  2.06146138  8.49150849 -1.2684096  7.667486
              2001  2.04311501  8.33991055  2.0614614 8.4915085
              2002   .60485066  9.13064594   2.043115 8.3399105
              2003  2.60544121 10.03560303   .6048506  9.130646
              2004   6.9543218 10.11122346   2.605441 10.035603
              2005  3.90263978 11.39577594   6.954322 10.111223
              2006  3.92791085 12.71947902    3.90264 11.395776
              2007  7.74917984 14.23138804   3.927911  12.71948
              2008  7.79180194  9.65428937    7.74918 14.231388
              2009   -.2105339  9.39981317   7.791802  9.654289
              2010  6.88114487 10.63614046  -.2105339  9.399813
              2011  8.07559638  9.55091409   6.881145  10.63614
              2012  2.33512068  7.85962749   8.075597  9.550914
              2013  2.16101914  7.76861528  2.3351207  7.859628
              2014     .791193  7.29951892   2.161019  7.768615
              2015   .06269939  6.90531667    .791193  7.299519
              2016  1.07275629  6.73667525  .06269939  6.905317
              2017  3.88416989  6.75700761  1.0727563  6.736675
              2018  2.93333231  6.56697386    3.88417  6.757008
              end
              
              rangestat (reg) inf inf1 gdp1, interval(year . 0)
              
              format reg_r2-se_cons %4.3f
              
              list reg* b*
              
                   +---------------------------------------------------------+
                   | reg_nobs   reg_r2   reg_ad~2   b_inf1   b_gdp1   b_cons |
                   |---------------------------------------------------------|
                1. |        .        .          .        .        .        . |
                2. |        1        .          .        .        .        . |
                3. |        2        .          .        .        .        . |
                4. |        3        .          .        .        .        . |
                5. |        4    0.963      0.890    0.951    0.583   -1.860 |
                   |---------------------------------------------------------|
                6. |        5    0.735      0.470    0.119    0.990    0.777 |
                7. |        6    0.564      0.274   -0.002    1.091   -0.044 |
                8. |        7    0.471      0.206    0.270    0.933   -2.628 |
                9. |        8    0.545      0.363    0.548    0.758   -4.411 |
               10. |        9    0.631      0.508    0.613    0.739   -5.035 |
                   |---------------------------------------------------------|
               11. |       10    0.646      0.545    0.567    0.750   -4.574 |
               12. |       11    0.662      0.577    0.577    0.749   -4.713 |
               13. |       12    0.676      0.605    0.596    0.750   -5.029 |
               14. |       13    0.683      0.620    0.589    0.758   -5.033 |
               15. |       14    0.671      0.611    0.555    0.822   -5.241 |
                   |---------------------------------------------------------|
               16. |       15    0.658      0.601    0.552    0.815   -5.358 |
               17. |       16    0.653      0.600    0.579    0.740   -4.919 |
               18. |       17    0.654      0.605    0.565    0.784   -5.218 |
               19. |       18    0.648      0.601    0.584    0.679   -4.393 |
               20. |       19    0.595      0.545    0.540    0.763   -5.354 |
                   |---------------------------------------------------------|
               21. |       20    0.557      0.505    0.479    0.806   -5.189 |
               22. |       21    0.558      0.509    0.481    0.809   -5.159 |
               23. |       22    0.541      0.493    0.452    0.864   -5.742 |
               24. |       23    0.549      0.504    0.452    0.863   -5.731 |
               25. |       24    0.562      0.521    0.454    0.880   -5.957 |
                   |---------------------------------------------------------|
               26. |       25    0.579      0.540    0.456    0.891   -6.107 |
               27. |       26    0.587      0.551    0.453    0.876   -5.909 |
               28. |       27    0.572      0.537    0.452    0.816   -5.193 |
               29. |       28    0.574      0.540    0.457    0.795   -4.992 |
                   +---------------------------------------------------------+
              
              .

              Comment


              • #8
                Originally posted by Nick Cox View Post
                OK, With rangestat installed

                Code:
                ssc install rangestat

                you can do this, The results necessarily conflate artefacts of small sample size and any progressive change in the relationship. You need a minimum of 4 data points to fit 3 parameters too.

                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input int year double(inf gdp) float(inf1 gdp1)
                1990 5.72458974 3.9071139 . .
                1991 6.68398563 9.29407591 5.72459 3.907114
                1992 8.19824765 14.21616358 6.683986 9.294076
                1993 15.20220481 13.86757602 8.198248 14.216164
                1994 20.60060944 13.05215872 15.202205 13.867576
                1995 13.6705391 10.94922737 20.60061 13.052158
                1996 6.50109595 9.92837246 13.67054 10.949227
                1997 1.62216042 9.23076923 6.501096 9.928372
                1998 -.89258936 7.83761392 1.6221604 9.230769
                1999 -1.26840965 7.66748617 -.8925893 7.837614
                2000 2.06146138 8.49150849 -1.2684096 7.667486
                2001 2.04311501 8.33991055 2.0614614 8.4915085
                2002 .60485066 9.13064594 2.043115 8.3399105
                2003 2.60544121 10.03560303 .6048506 9.130646
                2004 6.9543218 10.11122346 2.605441 10.035603
                2005 3.90263978 11.39577594 6.954322 10.111223
                2006 3.92791085 12.71947902 3.90264 11.395776
                2007 7.74917984 14.23138804 3.927911 12.71948
                2008 7.79180194 9.65428937 7.74918 14.231388
                2009 -.2105339 9.39981317 7.791802 9.654289
                2010 6.88114487 10.63614046 -.2105339 9.399813
                2011 8.07559638 9.55091409 6.881145 10.63614
                2012 2.33512068 7.85962749 8.075597 9.550914
                2013 2.16101914 7.76861528 2.3351207 7.859628
                2014 .791193 7.29951892 2.161019 7.768615
                2015 .06269939 6.90531667 .791193 7.299519
                2016 1.07275629 6.73667525 .06269939 6.905317
                2017 3.88416989 6.75700761 1.0727563 6.736675
                2018 2.93333231 6.56697386 3.88417 6.757008
                end
                
                rangestat (reg) inf inf1 gdp1, interval(year . 0)
                
                format reg_r2-se_cons %4.3f
                
                list reg* b*
                
                +---------------------------------------------------------+
                | reg_nobs reg_r2 reg_ad~2 b_inf1 b_gdp1 b_cons |
                |---------------------------------------------------------|
                1. | . . . . . . |
                2. | 1 . . . . . |
                3. | 2 . . . . . |
                4. | 3 . . . . . |
                5. | 4 0.963 0.890 0.951 0.583 -1.860 |
                |---------------------------------------------------------|
                6. | 5 0.735 0.470 0.119 0.990 0.777 |
                7. | 6 0.564 0.274 -0.002 1.091 -0.044 |
                8. | 7 0.471 0.206 0.270 0.933 -2.628 |
                9. | 8 0.545 0.363 0.548 0.758 -4.411 |
                10. | 9 0.631 0.508 0.613 0.739 -5.035 |
                |---------------------------------------------------------|
                11. | 10 0.646 0.545 0.567 0.750 -4.574 |
                12. | 11 0.662 0.577 0.577 0.749 -4.713 |
                13. | 12 0.676 0.605 0.596 0.750 -5.029 |
                14. | 13 0.683 0.620 0.589 0.758 -5.033 |
                15. | 14 0.671 0.611 0.555 0.822 -5.241 |
                |---------------------------------------------------------|
                16. | 15 0.658 0.601 0.552 0.815 -5.358 |
                17. | 16 0.653 0.600 0.579 0.740 -4.919 |
                18. | 17 0.654 0.605 0.565 0.784 -5.218 |
                19. | 18 0.648 0.601 0.584 0.679 -4.393 |
                20. | 19 0.595 0.545 0.540 0.763 -5.354 |
                |---------------------------------------------------------|
                21. | 20 0.557 0.505 0.479 0.806 -5.189 |
                22. | 21 0.558 0.509 0.481 0.809 -5.159 |
                23. | 22 0.541 0.493 0.452 0.864 -5.742 |
                24. | 23 0.549 0.504 0.452 0.863 -5.731 |
                25. | 24 0.562 0.521 0.454 0.880 -5.957 |
                |---------------------------------------------------------|
                26. | 25 0.579 0.540 0.456 0.891 -6.107 |
                27. | 26 0.587 0.551 0.453 0.876 -5.909 |
                28. | 27 0.572 0.537 0.452 0.816 -5.193 |
                29. | 28 0.574 0.540 0.457 0.795 -4.992 |
                +---------------------------------------------------------+
                
                .
                Thanks very much, Cox and I need to time digest suggestions from you.

                Comment


                • #9
                  This is an example of a recursive window. You may like to try asreg with the recursive option for this.

                  Code:
                  ssc install asreg
                  asreg inf inf1 gdp1, window(year 1) recursive
                  Regards
                  --------------------------------------------------
                  Attaullah Shah, PhD.
                  Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                  FinTechProfessor.com
                  https://asdocx.com
                  Check out my asdoc program, which sends outputs to MS Word.
                  For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                  Comment


                  • #10
                    Originally posted by Attaullah Shah View Post
                    This is an example of a recursive window. You may like to try asreg with the recursive option for this.

                    Code:
                    ssc install asreg
                    asreg inf inf1 gdp1, window(year 1) recursive
                    Thank you very much,Shah.
                    I have did like this to mactch my needs
                    Code:
                    asreg inf inf1 gdp, window(year 5) recursive fit
                    I sincerely appreciate the help from you.

                    Comment

                    Working...
                    X