Announcement

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

  • Accessing the coefficient estimate in a threshold regression

    Hi,

    I need your help. When we run a simple regression, we may access the coefficient by typing
    Code:
    _b[x1]
    ,
    Code:
    _b[_cons]
    , etc

    Code:
    . reg y x1 
    
    . di _b[x1]
    1.6517423
    
    . di _b[_cons]
    3.1274369
    How can we access the coefficients in two regions of a threshold regression? If I type the same command as above, I got the coefficient estimate for region 1, but I do not know how to get estimate of region 2. Thank you very much.

    Code:
    . threshold y, threshvar(z) regionvars(x1)
    
    
    Full sample:    1 - 2282                         AIC              =  6566.4751
    Number of thresholds =  1                        BIC              =  6589.4063
    Threshold variable: z                       HQIC             =  6574.8388
    
    ---------------------------------
    Order     Threshold        SSR
    ---------------------------------
    1        111.2900      40409.1139
    ---------------------------------
    
    ------------------------------------------------------------------------------
            y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    Region1      |
     x1 |    1.97371   .1257285    15.70   0.000     1.727287    2.220134
           _cons |   3.561658   .1437241    24.78   0.000     3.279964    3.843352
    -------------+----------------------------------------------------------------
    Region2      |
    x1 |   2.061766   .2232064     9.24   0.000      1.62429    2.499243
           _cons |  -.5468127    .223591    -2.45   0.014    -.9850429   -.1085825
    ------------------------------------------------------------------------------
    
    . di _b[x1]
    1.9737103
    
    . di _b[_cons]
    3.5616576





  • #2
    The coeflegend option is what you need. As is typical of most estimation commands, you can "replay" the results by issuing the command with no arguments, and you can change the options.
    Code:
    threshold y, threshvar(z) regionvars(x1)
    threshold, coeflegend
    Here's an example using the regress command.
    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . regress mpg weight
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =    134.62
           Model |   1591.9902         1   1591.9902   Prob > F        =    0.0000
        Residual |  851.469256        72  11.8259619   R-squared       =    0.6515
    -------------+----------------------------------   Adj R-squared   =    0.6467
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.4389
    
    ------------------------------------------------------------------------------
             mpg | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          weight |  -.0060087   .0005179   -11.60   0.000    -.0070411   -.0049763
           _cons |   39.44028   1.614003    24.44   0.000     36.22283    42.65774
    ------------------------------------------------------------------------------
    
    . regress, coeflegend
    
          Source |       SS           df       MS      Number of obs   =        74
    -------------+----------------------------------   F(1, 72)        =    134.62
           Model |   1591.9902         1   1591.9902   Prob > F        =    0.0000
        Residual |  851.469256        72  11.8259619   R-squared       =    0.6515
    -------------+----------------------------------   Adj R-squared   =    0.6467
           Total |  2443.45946        73  33.4720474   Root MSE        =    3.4389
    
    ------------------------------------------------------------------------------
             mpg | Coefficient  Legend
    -------------+----------------------------------------------------------------
          weight |  -.0060087  _b[weight]
           _cons |   39.44028  _b[_cons]
    ------------------------------------------------------------------------------

    Comment


    • #3
      Thank you, William. Your elaboration is extremely helpful.
      Is there anyway to access the threshold?

      Comment


      • #4
        I think it's time for you to review Chapter 20 "Estimation and postestimation commands" in the Stata User's Guide PDF included in your Stata installation and accessible through Stata's Help menu.

        You'll then see that the output of help threshold tells you that among the estimates returned by threshold in e() the matrix e(thresholds) has the threshold values.
        Code:
        . webuse usmacro
        (Federal Reserve Economic Data - St. Louis Fed)
        
        . threshold fedfunds, regionvars(l.fedfunds inflation ogap) threshvar(l2.ogap) optthresh(5) nodots
        
        Searching for threshold: 1
        (running 177 regressions)
        Searching for threshold: 2
        (running 146 regressions)
        Searching for threshold: 3
        (running 105 regressions)
        Searching for threshold: 4
        (running 52 regressions)
        Searching for threshold: 5
        (running 40 regressions)
        
        Threshold regression
        
        Full sample: 1955q3 thru 2010q4                     Number of obs  =       222
        Number of thresholds = 2                            Max thresholds =         5
        Threshold variable: L2.ogap                         BIC            =  -60.0780
        
        ---------------------------------
        Order     Threshold           SSR
        ---------------------------------
            1       -3.1787      142.0608
            2       -0.5351      126.4718
        ---------------------------------
        
        ------------------------------------------------------------------------------
            fedfunds | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
        Region1      |
            fedfunds |
                 L1. |   .8533835   .0435617    19.59   0.000     .7680042    .9387628
                     |
           inflation |   .2818775   .0679414     4.15   0.000     .1487148    .4150403
                ogap |   .1444994    .072028     2.01   0.045     .0033272    .2856717
               _cons |    .542808   .4297171     1.26   0.207     -.299422    1.385038
        -------------+----------------------------------------------------------------
        Region2      |
            fedfunds |
                 L1. |   .9406721   .0338085    27.82   0.000     .8744087    1.006935
                     |
           inflation |  -.0191805   .0462729    -0.41   0.679    -.1098737    .0715128
                ogap |   .2387934   .0565521     4.22   0.000     .1279534    .3496334
               _cons |    .638354   .1591717     4.01   0.000     .3263832    .9503249
        -------------+----------------------------------------------------------------
        Region3      |
            fedfunds |
                 L1. |   .8892742   .0593484    14.98   0.000     .7729535    1.005595
                     |
           inflation |   .1851127   .0532112     3.48   0.001     .0808206    .2894047
                ogap |   .1984744    .039236     5.06   0.000     .1215733    .2753754
               _cons |  -.3086232   .2215645    -1.39   0.164    -.7428817    .1256352
        ------------------------------------------------------------------------------
        
        . matrix list e(thresholds)
        
        e(thresholds)[1,4]
                    c1          c2          c3          c4
        r1  -1.000e+10  -3.1787388  -.53508854   1.000e+10
        
        . display e(thresholds)[1,2]
        -3.1787388
        
        . // in older versions of Stata e() matrices cannot be directly subscripted
        . matrix t = e(thresholds)
        
        . display t[1,2]
        -3.1787388
        
        . // other good stuff
        . display e(nthresholds)
        2
        
        . matrix list r(table)
        
        r(table)[9,12]
                   Region1:    Region1:    Region1:    Region1:    Region2:    Region2:    Region2:
                         L.                                              L.                        
                  fedfunds   inflation        ogap       _cons    fedfunds   inflation        ogap
             b    .8533835   .28187753   .14449944   .54280799    .9406721  -.01918045   .23879342
            se   .04356166   .06794144   .07202796   .42971709   .03380846   .04627289   .05655206
             z   19.590242   4.1488308   2.0061575   1.2631752   27.823569  -.41450729   4.2225416
        pvalue   1.873e-85   .00003342   .04483945   .20652621   2.25e-170   .67850263   .00002416
            ll   .76800421   .14871476   .00332722  -.29942204   .87440873  -.10987365   .12795342
            ul   .93876278   .41504031   .28567165    1.385038   1.0069355   .07151275   .34963342
            df           .           .           .           .           .           .           .
          crit    1.959964    1.959964    1.959964    1.959964    1.959964    1.959964    1.959964
         eform           0           0           0           0           0           0           0
        
                   Region2:    Region3:    Region3:    Region3:    Region3:
                                     L.                                    
                     _cons    fedfunds   inflation        ogap       _cons
             b   .63835404   .88927419   .18511267   .19847436  -.30862322
            se   .15917173   .05934838   .05321122   .03923596   .22156451
             z   4.0104738   14.983968   3.4788278   5.0584805  -1.3929272
        pvalue    .0000606   9.347e-51   .00050361   4.226e-07   .16364182
            ll   .32638319   .77295351    .0808206   .12157328  -.74288168
            ul   .95032489   1.0055949   .28940474   .27537544   .12563523
            df           .           .           .           .           .
          crit    1.959964    1.959964    1.959964    1.959964    1.959964
         eform           0           0           0           0           0
        
        .

        Comment

        Working...
        X