Announcement

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

  • quantile regression, loop-foreach

    Dear Clyde Schechter

    There is a slight twist in my qreg variables, which is giving me troubles while running them in a loop.. mentioned below is the code that I am using, where XtsysCFI is the dependant variable and all others are independant vars. Please note that XtsysCFI and XIFI belong to different panels. or in a way it is a cross panel sort of regression. that i want to see the effect of XIFI(one set of panel type) on XtsysCFI(other set of panel type). next to the codes is my data example.

    program define one_id
    qreg XtsysCFI XIFI L_Tbills L_MktR L_EV L_TEDSp L_Inf, q(0.99)
    foreach v of varlist XIFI L_Tbills L_MktR L_EV L_TEDSp L_Inf {
    gen coeff_`v' = _b[`v']
    gen se_`v' = _se[`v']
    gen t_`v' = coeff_`v'/se_`v'
    gen p_`v' = 2*t(e(df_r), -abs( t_`v'))
    }
    gen constant_term = _b[_cons]
    gen se_constant = _se[_cons]
    predict V
    exit
    end
    runby one_id, by(FI) status


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long FI float(Time_Period XtsysCFI XIFI L_Prices L_Tbills L_MktR L_EV L_Inf L_TEDSp)
    1 480            .         .        .       .       .     .      .        .
    1 481    .14411725         . .0672038 -16.535       .     .      .  -2.3525
    1 482    .15156017         . .0835295 -11.625     8.9     . -11.95 -1.34125
    1 483    .21712346         . .0798496   -.134   3.516     .  18.21    -1.15
    1 484     .3422176         . .0781215  -4.167  -5.058     .   8.68   -.6275
    1 485   .002527645         . .0903209    .982 -21.281     .  -1.03   -.3375
    1 486   .015975993         . .0657473    .278  -1.041     .  32.81  -.45062
    1 487   -.04165486         .  .074969    .139   2.221     .  -2.35  -.50812
    1 488     .8570709         . .0736191   2.075  -2.384     . -11.04      -.7
    1 489  .0031250215         . .0654767  10.298   3.017     .     14 -1.32875
    1 490     .2175392         . .0733345  35.135   -5.01     .   -9.7    -4.24
    1 491    .25854942         . .0745745   -.727 -15.387     .  18.64   -4.205
    1 492   -.01926262         .   .07685    .366  16.674     .  -6.65 -4.56125
    1 493    .02069786         . .0745791       0  -3.098     .  -7.52 -5.53875
    1 494     .3173947         . .0580505       0  -2.664     .   -1.5  -5.9075
    1 495     .2068724         . .0498555   5.383  -7.193     .  -9.13 -6.67125
    1 496      .426964         . .0479043   -.087   3.169     .   -5.5 -7.20375
    1 497    -.0753018         . .0466443     .52    .769     .  -9.11    -7.61
    1 498    .10299566         . .0375243  11.034   -.815     . -29.81 -9.04375
    1 499   -.21613307         . .0303341 -10.093 -10.609     .  -1.59    -7.91
    1 500     .2027448         . .0321417  -9.585   2.375     .  33.47  -7.0075
    1 501    -.3093559         .  .031865    .287 -10.462     . -25.98    -7.91
    1 502   -.16420217         . .0308261      -2  21.554     .   2.45    -8.09
    1 503   -.08708863         . .0338145 -19.728  -3.465     . -22.71 -6.22812
    1 504    -.2005374         . .0336571  -3.995  -6.471  9.25  -8.76    -6.05
    1 505 -.0002454049         . .0279009 -19.924  24.111 10.75  12.99    -4.47
    1 506   -.10337656         .   .03609     .63   8.615 10.89   21.5    -4.49
    1 507  -.003704032         . .0309914    .782   5.624   9.9  37.04    -4.41
    1 508    .01020024         . .0282982    .155   1.637  9.89    -.3    -4.53
    1 509    .12938884         .  .033633    -.31 -13.247 10.34 -12.05    -4.53
    2 510            .  .3849556        .       .       .     .      .        .
    1 510   .032016464         .   .04408  -2.333   6.221 10.39     25    -4.42
    1 511   -.06109645         . .0330991   1.911    .983 10.38  15.89    -4.58
    2 511            . -.0415979 .3431187    2.82   -1.17     . 257.58    -.996
    1 512    .09693163         . .0316686       0   9.949 10.48 -10.64    -4.59
    2 512            . -.2283536 .3281123    2.78   -1.41     . -24.58    -.974
    2 513            .         0 .3296109    2.82   -8.78     . -73.03    -1.03
    1 513    .14152934         . .0351229   -.469   2.212   9.8   1.32    -4.58
    1 514   -.05514001         . .0334291   -.471  12.106  9.52   -9.4    -4.65
    2 514            .         0   .32543    2.58    3.64     .     25    -.894
    2 515            .         0   .32543       0    8.26     .   -430    1.425
    1 515   -.04051322         . .0434067 -24.921    .321  9.46 -12.68    -3.34
    1 516     .3020173         .   .04959  -9.244  16.703   9.9  12.54    -2.94
    2 516            . -.4291332   .32543    2.04    5.97     .   6.06     -.66
    1 517    .15097298         .  .058837 -11.111  -5.962  9.84   3.23    -2.49
    2 517            . -.3982469 .3976787    2.28    5.04     .    4.3     -.93
    2 518            . -.3725341 .4287735       0    3.45     .  87.64     1.34
    1 518 -.0082018105         . .0553855 -16.927  -5.905 10.02   3.69    -1.85
    2 519            . -.3876064 .4756424     2.3   10.55     .  81.82   -1.021
    1 519    -.0747935         . .0612581 -34.483  12.394 10.23 -37.26     -.81
    2 520            . -.0865148 .5084478    2.39   18.44     .    300    -1.08
    1 520   -.20991796         . .0718027 -21.531   6.649 10.21      0     -.33
    1 521   -.06638288         . .0797373   9.756   6.555  9.74  25.33     -.52
    2 521            . -.1282595 .5422959    2.38    7.81     .    450     -1.1
    2 522            .   .357486 .5570995    2.25   -3.98     . 304.55   -1.134
    1 522   -.16017137         .   .12406  -7.778   9.341  9.79 -32.75     -.54
    2 523            . -.5621945 .5407044     2.2    3.07     .   5.62   -1.086
    1 523    -.1714864         . .1145765 -27.108  14.499  9.41 -26.94      -.1
    1 524    -.0406557         . .1088409       0  12.598  8.86  24.82     -.07
    2 524            .  .0264065 .5507024       0    6.29     .  45.74     1.14
    1 525 -.0044194986         . .1100355       0 -10.237  9.29  23.86     -.05
    2 525            . -.0222192 .5858518    2.37   10.04     .   -7.3    -1.21
    1 526   .037139542         . .1140039       0  -6.311  9.28  61.01     -.04
    2 526            . -.0933437 .6098683    2.37     .64     . -30.71   -1.201
    2 527            . -.4315497 .6122505       0    3.02     .   -100    1.172
    1 527    -.1508766         .  .091113   37.19   7.323  8.26  20.23     -.49
    1 528   -.19442508         . .0838474  -1.205   9.452  8.29   28.2     -.49
    2 528            . -.2398862 .6069409    2.46    5.77     .      .   -1.308
    2 529            .  -.126793 .7043023    2.18    7.03     . -66.67    -1.05
    1 529    -.0772997         . .1004205       0   7.944  8.32  -4.81     -.51
    2 530            . -.0273112  .790715       0    1.55     .  34.48     1.12
    1 530   -.14642256         .  .105205   2.439    -.02  8.35 -16.31     -.56
    2 531            . -.4355585 .7682244     1.7   -5.35     .      0     -.59
    1 531   .008173214         . .1129339   3.571   5.355  7.38   23.9     -.63
    1 532    .16021617         . .1099791   5.747   6.147  7.38  12.17     -.66
    2 532            .  .1995203 .7063832     .91    2.05 6.052 174.36      .27
    1 533   -.13840793         . .1099219  13.043   1.233  7.37  17.53     -.77
    2 533            .  .0047507 .6672567       0    4.49 5.918  -27.1    1.315
    1 534   -.21261966         . .1230468       0  -4.058  7.54  20.03     -.47
    2 534            .  -.368475 .6758518      .6    3.23 5.818    -50     1.01
    1 535  -.066786736         . .1174582  22.596    .203  7.58  10.41     -.85
    2 535            . -.3785119 .7043523     2.4    4.01 5.696 -25.64      -.7
    2 536            . -.4216251  .704395       0    3.89 4.906 165.52      1.8
    1 536   -.12084915         .   .11671   2.745   1.057  7.41   -.96     -.82
    2 537            . -.1181883 .7933378    2.66    2.68 4.904 112.99     -.64
    1 537   .017371073         . .1027805  14.504  -2.433  7.49   -2.6     -.98
    1 538   -.19863896         . .0998014   6.333   2.172  6.92  -3.33    -1.02
    2 538            . -.1018165 .8354295    2.66    1.04 4.859  23.78     -.49
    1 539   -.10281584         . .1004495  16.928   4.323  6.62   6.44    -1.32
    2 539            . -.2933779 .8149614       0    3.83 4.904  48.77     2.41
    1 540    -.2062522         . .0903648   1.877  11.051  6.45 -20.41    -1.24
    2 540            . -.1129385 .8334031     .87     .67 4.902 -13.91    1.694
    2 541            .  .0463896 .8346148    1.99    1.51 4.959  19.23      .76
    1 541   -.17810403         . .0934748  31.579   8.164  6.25  15.47    -2.25
    1 542  -.000890707         .  .099512      -6  20.228  7.12  16.92    -1.78
    2 542            .  .1280549 .8160575       0    3.54 4.772    2.9     2.92
    2 543            . -.1688652  .939693       0   15.47 3.459  18.18     3.12
    3 543            .  .3437548        .       .       .     .      .        .
    1 543  -.021723453         . .0927309  14.894  -6.112  7.47   3.02    -2.28
    1 544     .1960406         . .0965819  24.074  -8.956  7.88   8.29    -3.49
    end
    format %tm Time_Period
    label values FI FI
    label def FI 1 "786 PA Equity", modify
    label def FI 2 "AAYAN KK Equity", modify
    label def FI 3 "AAYANRE KK Equity", modify
    Could you please assist me how to loop the panels for qreg while the variables belong to different panel ids?

    Thanking in anticipation
Working...
X