Announcement

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

  • SUR Estimation - Equation residuals

    Hi,

    I need to extract equationwise error terms of components of my SUR estimation. However by using post estimation predict command I am only able to produce one error term from entire estimation. How could I calculate error terms for all equations and store them seperately?


    The following code simulates what I am trying to do by using sample data from stata repository. I need both residual series for open and high equations. In my original work this SUR system includes 11 different equations representing 11 different co-integration vectors. Now I am trying to produce their residuals to estimate short term 11 VEC equations by using SUR estimation.


    Click image for larger version

Name:	Residuals_SUR.PNG
Views:	1
Size:	43.5 KB
ID:	1638405


    Thank you very much


    Code:
    .  sysuse sp500.dta
    (S&P 500)
    
    . tsset date
    
    Time variable: date, 02jan2001 to 31dec2001, but with gaps
            Delta: 1 day
    
    . sureg (open L1.open L2.open L1.high L2.high L3.high) (high L1.open L2.open L1.high L2.high)
    
    Seemingly unrelated regression
    ------------------------------------------------------------------------------
    Equation             Obs   Params         RMSE  "R-squared"      chi2   P>chi2
    ------------------------------------------------------------------------------
    open                  90        5      7.61825      0.9928   12416.11   0.0000
    high                  90        4     11.59675      0.9828    5156.78   0.0000
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    open         |
            open |
             L1. |  -.4114277   .1297403    -3.17   0.002    -.6657139   -.1571415
             L2. |   .0716423    .091755     0.78   0.435    -.1081943    .2514789
                 |
            high |
             L1. |   1.339624   .0796114    16.83   0.000     1.183588    1.495659
             L2. |    .094866   .1446546     0.66   0.512    -.1886517    .3783837
             L3. |  -.0810755   .0515966    -1.57   0.116     -.182203    .0200519
                 |
           _cons |   -29.7035   11.58405    -2.56   0.010    -52.40783   -6.999178
    -------------+----------------------------------------------------------------
    high         |
            open |
             L1. |   -.614001   .1973872    -3.11   0.002    -1.000873   -.2271291
             L2. |   .0386898   .1194357     0.32   0.746       -.1954    .2727795
                 |
            high |
             L1. |   1.374734   .1211697    11.35   0.000     1.137246    1.612223
             L2. |   .2000723   .2200332     0.91   0.363    -.2311849    .6313294
                 |
           _cons |  -6.871725   17.42993    -0.39   0.693    -41.03377    27.29032
    ------------------------------------------------------------------------------
    
    . predict residuals, equation(open : high)
    (option xb assumed; fitted values)
    equation open : high not found
    r(303);
    
    . predict residuals
    (option xb assumed; fitted values)
    (158 missing values generated)
    
    . list residuals
    
         +----------+
         | residu~s |
         |----------|
      1. |        . |
    Last edited by Omer Zeybek; 28 Nov 2021, 02:25.

  • #2
    Omer:
    do you mean something along the following lines?
    Code:
    . use https://www.stata-press.com/data/r16/auto
    (1978 Automobile Data)
    
    . sureg (Eq_1: price = foreign length) (Eq_2: weight = foreign length)
    
    Seemingly unrelated regression
    --------------------------------------------------------------------------
    Equation             Obs   Parms        RMSE    "R-sq"       chi2        P
    --------------------------------------------------------------------------
    Eq_1                  74       2    2423.914    0.3154      34.09   0.0000
    Eq_2                  74       2    245.1264    0.8992     659.84   0.0000
    --------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    Eq_1         |
         foreign |   2801.143    750.427     3.73   0.000     1330.333    4271.953
          length |   90.21239   15.50941     5.82   0.000      59.8145    120.6103
           _cons |  -11621.35   3060.448    -3.80   0.000    -17619.72   -5622.982
    -------------+----------------------------------------------------------------
    Eq_2         |
         foreign |  -133.6775   75.88944    -1.76   0.078    -282.4181    15.06306
          length |   31.44455   1.568441    20.05   0.000     28.37046    34.51864
           _cons |   -2850.25    309.498    -9.21   0.000    -3456.855   -2243.645
    ------------------------------------------------------------------------------
    
    . predict res_1, equation(Eq_1) residuals
    
    . predict res_2, equation(Eq_2) residuals
    
    . list price weight foreign length res_1 res_2 in 1/10
    
         +-------------------------------------------------------------+
         |  price   weight    foreign   length       res_1       res_2 |
         |-------------------------------------------------------------|
      1. |  4,099    2,930   Domestic      186   -1059.155   -68.43694 |
      2. |  4,749    3,350   Domestic      173    763.6059    760.3422 |
      3. |  3,799    2,640   Domestic      168    264.6678     207.565 |
      4. |  4,816    3,250   Domestic      196   -1244.279   -62.88247 |
      5. |  7,827    4,080   Domestic      222   -578.8013   -50.44081 |
         |-------------------------------------------------------------|
      6. |  5,788    3,670   Domestic      218   -2256.952   -334.6626 |
      7. |  4,453    2,230   Domestic      170     738.243   -265.3241 |
      8. |  5,189    3,280   Domestic      200   -1232.129   -158.6607 |
      9. | 10,372    3,880   Domestic      207    3319.385    221.2275 |
     10. |  4,082    3,400   Domestic      200   -2339.129   -38.66067 |
         +-------------------------------------------------------------+
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you very much Carlo
      That's exactly what I need to do

      Comment

      Working...
      X