Announcement

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

  • Need help with creating first difference operator for regression - econometrics

    Hi There Everyone.

    I hope you're all well.
    I had a question,
    I'm really lost - i need to create a first difference operator in stata, I've been struggling to understand how to do this.

    My data looks like this:
    observation Year quarter r bill rate pi
    1 1950 1 0.51 11.53832 0.5
    2 1950 2 0.51 11.53832 4.06
    3 1950 3 0.55 11.56103 5.5
    4 1950 4 0.623 11.60105 9.85
    5 1951 1 0.693 11.61927 14
    6 1951 2 0.75 11.60116 11.67
    7 1951 3 0.803 11.5962 8
    8 1951 4 0.913 11.59763 3.26
    9 1952 1 0.907 11.64858 3.39
    10 1952 2 1.013 11.67504 -2.93
    11 1952 3 1.11 11.68812 -2.58
    this is the regression i have to run
    Click image for larger version

Name:	regr.PNG
Views:	1
Size:	6.4 KB
ID:	1576557


    basically Δrt=rt​​​​​​ - rt-1
    Any help and guidance would be greatly appreciated please.

  • #2
    Code:
    tsset observation year
    now you can use the ‘D.’ operator.
    Best regards,

    Marcos

    Comment


    • #3
      It looks to me like the data in #1 are quarterly, not yearly. And observation does not appear to be a panel identifier. This looks more like just a single time series to me. So I think it's just a little more complicated:

      Code:
      gen qdate = yq(Year, quarter)
      format qdate %tq
      tsset qdate
      Then they can use the D. operator, which they can read about in -help tsvarlist-.

      Comment


      • #4
        Hi there thank you so much,
        i had another issue,

        . gen y1 = D1.GDPlog
        (1 missing value generated)

        . gen pi1 = D1.pi
        (1 missing value generated)

        . drop pi1

        . gen pi1 = L1.pi
        (1 missing value generated)

        . gen dr1 = D1.r
        (1 missing value generated)

        . gen dr2 = D2.r
        (2 missing values generated)

        . gen dr = D.r
        (1 missing value generated)

        . regress dr pi1 y1 dr2 dr1

        Source | SS df MS Number of obs = 186
        -------------+------------------------------ F( 4, 181) = .
        Model | 165.132359 4 41.2830897 Prob > F = .
        Residual | 0 181 0 R-squared = 1.0000
        -------------+------------------------------ Adj R-squared = 1.0000
        Total | 165.132359 185 .892607344 Root MSE = 0

        ------------------------------------------------------------------------------
        dr | Coef. Std. Err. t P>|t| [95% Conf. Interval]
        -------------+----------------------------------------------------------------
        pi1 | -9.47e-18 . . . . .
        y1 | -1.74e-15 . . . . .
        dr2 | -2.87e-16 . . . . .
        dr1 | 1 . . . . .
        _cons | 4.86e-17 . . . . .
        ------------------------------------------------------------------------------

        i dont know what i'm doing wrong, can you specify what i'm doing wrong?

        Comment


        • #5
          You have
          Code:
          gen dr1 = D1.r
          gen dr = D.r
          D.r and D1.r are the same thing. So your dependent variable dr, is exactly equal to dr1. Consequently the correct regression has the coefficient of dr1 = 1, and the constant term and all other coefficients equal to 0. In fact, to within some very tiny rounding errors, that's what you got.

          I'm pretty sure you didn't intend for dr and dr1 to be the same variable. But I wouldn't know what you actually need to do instead.

          Comment

          Working...
          X