Announcement

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

  • How to include dummy variables in ivreg model in Stata?

    I have a model:
    ivreg ldemand social_housing transport year (lprice = utilities)
    But I want to make year as dummy variable. How can I do it in Stata? i.year doesn't work for ivreg
    Last edited by Daniil Yefimov; 04 Jul 2018, 01:35.

  • #2
    Daniil:
    I cannot replicate your problem:
    Code:
    use http://www.stata-press.com/data/r15/nlswork
    
    . xtreg ln_w age i.year c.age#c.age tenure not_smsa union south, re
    
    Random-effects GLS regression                   Number of obs     =     19,007
    Group variable: idcode                          Number of groups  =      4,134
    
    R-sq:                                           Obs per group:
         within  = 0.1387                                         min =          1
         between = 0.2613                                         avg =        4.6
         overall = 0.2266                                         max =         12
    
                                                    Wald chi2(17)     =    3619.52
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |      .0638    .004675    13.65   0.000     .0546372    .0729629
                 |
            year |
             71  |   .0122226   .0133882     0.91   0.361    -.0140179    .0384631
             72  |   .0033013   .0131535     0.25   0.802     -.022479    .0290816
             73  |  -.0171295   .0142374    -1.20   0.229    -.0450342    .0107752
             77  |  -.0591987   .0177349    -3.34   0.001    -.0939585    -.024439
             78  |   -.028641   .0198267    -1.44   0.149    -.0675005    .0102186
             80  |  -.0675303   .0224566    -3.01   0.003    -.1115444   -.0235162
             82  |  -.0752261   .0253439    -2.97   0.003    -.1248993    -.025553
             83  |  -.0574366   .0270078    -2.13   0.033    -.1103709   -.0045022
             85  |  -.0248232   .0300102    -0.83   0.408     -.083642    .0339957
             87  |  -.0047382   .0332305    -0.14   0.887    -.0698689    .0603924
             88  |   .0252851   .0355943     0.71   0.477    -.0444785    .0950487
                 |
     c.age#c.age |   -.000905   .0000672   -13.47   0.000    -.0010368   -.0007733
                 |
          tenure |   .0222127   .0007477    29.71   0.000     .0207472    .0236782
        not_smsa |   -.156615   .0092359   -16.96   0.000     -.174717    -.138513
           union |   .1142884   .0065282    17.51   0.000     .1014933    .1270835
           south |  -.1108392   .0090233   -12.28   0.000    -.1285246   -.0931538
           _cons |    .664906   .0741773     8.96   0.000     .5195212    .8102908
    -------------+----------------------------------------------------------------
         sigma_u |  .33168145
         sigma_e |  .25427557
             rho |  .62983588   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . xtivreg ln_w age i.year c.age#c.age not_smsa (tenure = union south), re
    
    G2SLS random-effects IV regression              Number of obs     =     19,007
    Group variable: idcode                          Number of groups  =      4,134
    
    R-sq:                                           Obs per group:
         within  = 0.0596                                         min =          1
         between = 0.1780                                         avg =        4.6
         overall = 0.1212                                         max =         12
    
                                                    Wald chi2(15)     =    1017.96
    corr(u_i, X)       = 0 (assumed)                Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          tenure |     .17626   .0111856    15.76   0.000     .1543367    .1981834
             age |   .0491276   .0087104     5.64   0.000     .0320556    .0661996
                 |
            year |
             71  |  -.0316701    .027218    -1.16   0.245    -.0850164    .0216762
             72  |  -.0252266   .0259762    -0.97   0.331     -.076139    .0256858
             73  |  -.0761155   .0276047    -2.76   0.006    -.1302197   -.0220113
             77  |  -.1561267   .0291789    -5.35   0.000    -.2133162   -.0989373
             78  |  -.1898602   .0338453    -5.61   0.000    -.2561957   -.1235248
             80  |  -.1867523   .0346128    -5.40   0.000    -.2545921   -.1189125
             82  |   -.264212   .0379957    -6.95   0.000    -.3386823   -.1897417
             83  |  -.3274644   .0421063    -7.78   0.000    -.4099912   -.2449376
             85  |   -.293698   .0444716    -6.60   0.000    -.3808608   -.2065353
             87  |  -.3123237   .0481168    -6.49   0.000    -.4066308   -.2180166
             88  |  -.4193996   .0556621    -7.53   0.000    -.5284953   -.3103039
                 |
     c.age#c.age |  -.0010334     .00013    -7.95   0.000    -.0012882   -.0007787
                 |
        not_smsa |  -.2082097   .0131004   -15.89   0.000    -.2338859   -.1825334
           _cons |    .903967   .1323148     6.83   0.000     .6446347    1.163299
    -------------+----------------------------------------------------------------
         sigma_u |  .33970135
         sigma_e |  .61262621
             rho |  .23516437   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    Instrumented:   tenure
    Instruments:    age 71.year 72.year 73.year 77.year 78.year 80.year 82.year
                    83.year 85.year 87.year 88.year c.age#c.age not_smsa union
                    south
    ------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      Cross-posted at https://stackoverflow.com/questions/...in-ivreg-model

      Please note our policy on cross-posting (FAQ Advice #8), which is that you are asked to tell us about it. https://www.statalist.org/forums/help#crossposting

      Comment


      • #4
        Daniil:
        in my previous post I've misread -ivreg- for -xtivregress-.
        Tracking down some details, I've noticed that -ivreg-, that dates back to Stata 10 (by the way: if you're using that release, as per FAQ you should have made explicit in your post), has been replaced by -ivregress-.
        Being a bit old-fashioned. -ivreg- does not allow -fvvarlist- notation (and some other options which are instead available with -ivregress-).
        However, the usual -xi:- trick can work this nuisance around, as you can see from the following toy-example:
        Code:
        webuse hsng2
        
        . xi: ivreg rent pcturban (hsngval = faminc i.region)
        i.region          _Iregion_1-4        (naturally coded; _Iregion_1 omitted)
        
        Instrumental variables (2SLS) regression
        
              Source |       SS           df       MS      Number of obs   =        50
        -------------+----------------------------------   F(2, 47)        =     42.66
               Model |  36677.4033         2  18338.7017   Prob > F        =    0.0000
            Residual |  24565.7167        47  522.674823   R-squared       =    0.5989
        -------------+----------------------------------   Adj R-squared   =    0.5818
               Total |    61243.12        49  1249.85959   Root MSE        =    22.862
        
        ------------------------------------------------------------------------------
                rent |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
             hsngval |   .0022398   .0003388     6.61   0.000     .0015583    .0029213
            pcturban |    .081516   .3081528     0.26   0.793    -.5384074    .7014394
               _cons |   120.7065   15.70688     7.68   0.000     89.10834    152.3047
        ------------------------------------------------------------------------------
        Instrumented:  hsngval
        Instruments:   pcturban faminc _Iregion_2 _Iregion_3 _Iregion_4
        ------------------------------------------------------------------------------
        
        .
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment

        Working...
        X