Announcement

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

  • Panel data OLS time and ID restrictions.

    Hello

    I want to make an OLS regression in Stata my regression will be

    Code:
    regress  regress interestrate    lag_interestrate        inf_diff_quarterly      GDP4            if      ID==5
    My data is xtset in panel format by

    Code:
    xtset ID DATE
    My date is in quarterly format from 1997q1 to 2019q4 and I am trying to limit my time (want to regress for a specified time period). İs there way that ı can make regression for both ID restriction and also for example from 1997q1 to 2005q4.
    Thank in advance

  • #2
    MuhammetAli:
    I'm not sure to understand how a -regress. carried out in a single -id- can be any informative.
    In addition, if you want to -regress- theres no need to -xtset- your dataset.
    That said, the following toy example may be helpful:
    Code:
    . use "https://www.stata-press.com/data/r17/nlswork.dta"
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . g select=1 if year<=80
    (10,593 missing values generated)
    
    . regress ln_wage c.age##c.age i.year if idcode==1 & select==1
    note: c.age#c.age omitted because of collinearity.
    note: 80.year omitted because of collinearity.
    
          Source |       SS           df       MS      Number of obs   =         8
    -------------+----------------------------------   F(7, 0)         =         .
           Model |  1.80850822         7  .258358318   Prob > F        =         .
        Residual |           0         0           .   R-squared       =    1.0000
    -------------+----------------------------------   Adj R-squared   =         .
           Total |  1.80850822         7  .258358318   Root MSE        =         0
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   .1100501          .        .       .            .           .
                 |
     c.age#c.age |          0  (omitted)
                 |
            year |
             71  |  -.5326443          .        .       .            .           .
             72  |  -.0813369          .        .       .            .           .
             73  |  -.0010915          .        .       .            .           .
             75  |   -.224453          .        .       .            .           .
             77  |  -.4428844          .        .       .            .           .
             78  |   .1623608          .        .       .            .           .
             80  |          0  (omitted)
                 |
           _cons |  -.5296886          .        .       .            .           .
    ------------------------------------------------------------------------------
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thank you so much so I need to use dummy variable however I might want to use different selection next time should i create dummy every time. Is there no other way like in-range for this command?

      As for your question I use euro area countries in my dataset and ID 5 is the euro area total therefore for that one i use regress and for the the others i use xtreg if ID!=5. I will use the code you gave me as soon as I open the Stata

      Thank you so much again

      Comment


      • #4
        MuhammetAli:
        most depends on how you decide to -xtset- your dataset if you want to go -xtreg-.
        Conversely, if you want to go -regress-, you may want to try:
        Code:
        bysort idcode: regress ln_wage c.age##c.age i.year if year<=80
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment

        Working...
        X