Announcement

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

  • Error in runby program

    Hi,

    I am using the following code to run quantile regression on my weekly dataset (from 2009w1 to 2022w52) for no of firms (FI):

    capture program drop one_id
    program define one_id
    bsqreg Xit1 L.ch_tbill3M L.Tyield_10Y3M L.TEDspread, q(0.95) reps(1000)
    foreach v of varlist L.ch_tbill3M L.Tyield_10Y3M L.TEDspread{
    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

    BUT! This does not give the regression results, rather gives by-groups with errors for all of my firms.

    Can you please help me sort what is wrong and where. Please see the dataex example of my data:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long FI float(time_period Xit1 ch_tbill3M Tyield_10Y3M TEDspread) double(EquityVolaity lnMktReturns)
    1 2548     4.319854     . 1.095 -1.785 2.7810151370826133                   .58
    1 2549    11.198747 -.105 1.053  -1.68 2.6373930914446317   -5.0966443592027515
    1 2550    11.547153  -.05  1.23  -1.62 2.7471525921865956   -6.0594689314225025
    1 2551   -4.0552254 -.275 1.508 -1.335 2.8945651093842018     5.768873571119743
    1 2552     4.881758  .175 1.673  -1.48 3.0241858667411057    -1.991847612206841
    1 2553    1.0567293 -.145  1.61 -1.305  3.034059877746771    2.5356717733132266
    1 2554      .459858   .02  1.52 -1.425  3.030627951001934    -4.506250579274458
    1 2555    -3.024092  .105 1.653  -1.53  3.092315907276839   -1.7166912828761864
    1 2556    2.1109364  -.11   1.8  -1.48 3.0940024905512584     -6.12921043198019
    1 2557   -11.633823   .04  1.84  -1.55 3.0924642970343443     6.168079637594314
    1 2558   -14.991961 -.072 1.772 -1.508 3.2043445446557355    3.6051576393061833
    1 2559    -5.308059  .362 1.785   -1.9 3.0698937688069337     5.773014579491893
    1 2560    -6.756507 -.005  1.66 -1.955 3.1211297339023254     1.718899834085095
    1 2561    -1.368871  -.06  1.88 -1.965  3.098783571849712   -1.7325095351009716
    1 2562     2.561398 -.005 1.833  -2.07 2.9999885894402594     2.799619199471798
    1 2563  -.002892359 -.142  1.94 -2.098 2.9880034600740117   -1.7004987920957886
    1 2564    -1.683539 -.043 2.068 -2.055  3.002231214485392    1.5097348839948999
    1 2565   -2.3027122   .33 2.065 -2.415  2.984462719971723     4.427532952758093
    1 2566     4.521911 -.077 2.077 -2.348  2.980802817647755    -4.358603999869878
    1 2567   -2.5147085  .247  2.18 -2.605  2.974963310740649   -.27334385343462597
    1 2568    -6.123905 -.188 2.458 -2.427 2.8132807402624866    1.4274460393891875
    1 2569   -2.6233845  .233 2.505   -2.7  2.819373196980759     3.955216240050557
    1 2570    -3.055772   .16 2.285  -2.91  2.864585014574879     2.285386994160068
    1 2571    4.3797665  .185 2.298 -3.105  3.957455658876803   -4.0535909772619405
    1 2572    -.6446486 -.095   2.2  -3.01 3.8944374500454835    .09991162495808209
    1 2573     2.478275  -.24 2.238  -2.79 3.6172532078372033   -1.9599851728097357
    1 2574    1.0908253 -.075   2.2 -2.735 3.4750176000920776    -.9049598134603207
    1 2575    -7.202776  .127 2.243 -2.892  3.447632558511944     5.310846239404697
    1 2576    -2.682509  .175 2.305 -3.107  3.577521914393277     2.184798861600997
    1 2577    -12.03259  .101 2.112 -3.248  3.409088907839278    3.7051050388190574
    1 2578   -3.3782475  .192 1.957  -3.48  3.411585127758548    1.3013032649590623
    1 2579   -3.2574146  .145 1.753 -3.635  3.007273272297112    3.6933033164836155
    1 2580    2.5389755 -.168 1.698 -3.477  2.864177177454631    -3.895810281397721
    1 2581    -7.275897  .223 1.473  -3.71 3.0201286992730085     4.532463424223117
    1 2582   -4.3456073  -.02 1.553  -3.69 2.9365829060079713     -1.19171698435996
    1 2583    -4.778137  -.29  1.68   -3.4 2.9639544890784557    3.5398987737451373
    1 2584   -4.4333167   .02 1.695  -3.42 2.9642756982928673     2.090023451631084
    1 2585   -4.0617146 -.012 1.637 -3.408 2.9478012264953635    .44208361053973116
    1 2586    1.3284702  .109 1.418 -3.517   2.88958518713842    -2.401686437228359
    1 2587    -7.220234  .291 1.215 -3.818 2.9810821464315618     3.256906878939119
    1 2588    .14784923  .307  1.29 -4.125 2.9251752850883026    1.7260137073954815
    1 2589    2.6474974  .135  1.27  -4.27  2.686807666528203    .48243537409371573
    1 2590     4.915802  -.23  1.32  -4.04  2.672799369515991    -4.554990827434343
    1 2591    -.8929854  -.06  1.46  -3.98  2.936154756044888   -1.0755933376382465
    1 2592     .3394441  -.01  1.37  -3.98 2.8816950042676526     2.435344052258398
    1 2593      2.66699  -.08  1.31   -3.9 2.8858866207539298    -.4479993872042405
    1 2594     .7590156  -.12   1.2  -3.78  2.701274978916767    -2.456250576395207
    1 2595    .19012913   .16 1.235  -3.94  2.787976380143928     2.832449794397311
    1 2596    2.9141114  .145 1.255 -4.085   2.75575251078178   -1.4874778656138934
    1 2597     2.867997 -.227 1.322 -3.858   2.77700533861429     .3098934651309841
    1 2598    -6.155504  .042 1.507   -3.9 2.5985662200160533    2.9543792479823643
    1 2599   -3.0247836   .08 1.495  -3.98 2.6247966144001147    1.6718947944442966
    1 2600    .29157594   .11  1.42  -4.09 2.5493119535812254     .8656841566197312
    1 2601   -2.4448085   .01 1.295   -4.1 2.5455003180567313   -.23861763948450082
    1 2602     5.468619  -.08 1.215  -4.02  2.454794879531334   -3.0916265354032157
    1 2603     4.456677  -.05  1.23  -3.97  2.392561543265756    -3.899028578186635
    1 2604     6.042566  -.15 1.393  -3.82  2.384997926518158   -1.2804159468561467
    1 2605    -5.164382   .19  1.32  -4.01 2.3873240990007476    1.0749817252307041
    1 2606    -5.160646   .05 1.338  -4.05  2.272078297317733     1.598770897339594
    1 2607    -6.139617 -.083 1.283 -3.947 2.2525190580241485    .05759157380940147
    1 2608    -2.468813  .075 1.163 -4.012    2.2499418287691     2.753166936101085
    1 2609   -2.4825625  .188 1.185   -4.2  2.264554475542964    1.0675203517278584
    1 2610    -2.962508  -.01 1.175  -4.18 2.1679566713010217     1.139591130238571
    1 2611    -.9253118  .065 1.193 -4.235  2.150015242988553     .4865781240443999
    1 2612    -.7023807 -.017 1.234 -4.208 2.1500567214032924    .22804143182495423
    1 2613    -1.608995  .037 1.265 -4.215  1.890207055879812     .8185291156125228
    1 2614    1.4403573 -.057 1.332 -4.078  1.869984474347242     .7280622822523631
    1 2615     1.715052  .017 1.275 -4.075 1.8132818424280914   -2.1375509721209727
    1 2616     4.749873  -.05  1.24 -3.975 1.8792067734105444   -1.5405111967285314
    1 2617     8.147844  -.17 1.148 -3.765   1.82742329196346    -7.093184143475756
    1 2618      7.92156   .13 1.075 -3.895  2.313249053508092    2.8720918931733186
    1 2619     4.190766 -.235 1.212  -3.66 2.3858015256263365     -6.89407681399508
    1 2620    -4.797509   .08 1.168  -3.74 2.7960679296398676    3.4829652743497306
    1 2621    1.5745316   .07 1.077  -3.82  2.827968412816362    -.2037278847078549
    1 2622    -6.711472   .16  .893  -3.98 2.7926954814800915    1.2806551825628505
    1 2623   -1.8557957   .02  .825     -4 2.8031632806409794    1.0249878594640722
    1 2624     7.764712 -.047  .779 -3.963 2.8195157839811436   -3.0627936317464544
    1 2625     2.553438 -.018   .65 -3.975 2.8181832655031687    -4.028753861211932
    1 2626    -8.001785  .087  .558 -4.102  2.826107381556637     3.678179644790373
    1 2627      .789074  .008  .562  -4.15 2.9433928208206344      .587078951414072
    1 2628    -4.904974  .055  .575 -4.245  2.935778188101532     .8350581643263473
    1 2629    -2.899087 -.105  .705  -4.18   2.91866111025161     .7987634212173264
    1 2630     3.143196   .07   .58  -4.28 2.9257814018464234    1.5738165889767148
    1 2631    2.2358754 -.065  .515 -4.225  2.880616788970083    -2.345432769903252
    1 2632    .07238327 -.097  .507 -4.128 2.9010395790442143    -.6291933084513827
    1 2633    -2.829714 -.078  .475  -4.05 2.8821452263009215   -1.3726385359829767
    1 2634    -4.885795  .047  .478 -4.097  2.881135036356614     3.842659609385382
    1 2635    -3.344429  .168  .422 -4.265  3.025178504147273    .43073203022233003
    1 2636   -1.0319948  .075  .485  -4.34 3.0191456843439957    1.7130187916681274
    1 2637    -2.257353   .05   .38  -4.39  3.043432595676172    -.7631997801212318
    1 2638   -.04816874  .018  .365 -4.408 3.0184959403969995    -.4879688899808514
    1 2639   -2.1208224 -.016  .326 -4.392  3.005617945437295    2.2280607057951314
    1 2640     1.757735 -.062   .48  -4.33  2.622653542150745    .16253091024615604
    1 2641   -1.2915785  .028  .512 -4.368 2.5542834176523206      -.88280002122249
    1 2642     -5.00667 -.105   .67 -4.263 2.0425098690095247    .27569461757710356
    1 2643     2.887916  .235  .475 -4.488 1.9195546308133273    2.9733133181954963
    1 2644     6.048915 -.048  .635  -4.43 2.0044520637773826    -2.288448655416536
    1 2645     2.717326  .265   .51 -4.695 2.0694307165252583   -1.3677593018010419
    1 2646    .22709808 -.072  .562 -4.623  2.086470772923708    -.6725921789694679
    1 2647   -4.7307963 -.091  .638 -4.532 1.9739522876260853    2.0656900650754118
    1 2648    -2.736385  .108  .648  -4.64 1.7703093089415542     1.108799410255161
    1 2649     .8076484  .017  .618 -4.657 1.6276314643423193    .37387699320388923
    1 2650    -1.851746  .091  .607 -4.748 1.6268113189864757    .30893150064145836
    1 2651      2.92324 -.098  .565  -4.65  1.623114529268775    -.6588081400407209
    1 2652    2.3358452 -.083  .726 -4.567 1.6323744631098123    -.8846509176016479
    1 2653    -.9978039 -.037  .662  -4.52  1.621837836933651    2.0836232541292286
    1 2654   -2.4875324  .075  .728 -4.595 1.5724729402559996    -.9683154933373135
    1 2655   -2.2551382 -.135  .713  -4.46 1.5840823086047489     .3741832872738627
    1 2656    -3.754616   .19   .71  -4.65  1.537876065576412    1.8113702799147073
    1 2657   -2.4380145 -.053  .773 -4.597 1.3740726283899911    .37470702593740307
    1 2658    4.3284817 -.017  .732  -4.58 1.3739002979759858    1.1267008073025377
    1 2659    1.0210705  -.06  .687  -4.52 1.3509381874579056     -2.04307621061917
    1 2660    2.0520597  .053  .682 -4.573  1.423863630635252     .5624195919647393
    1 2661     5.470477 -.078  .658 -4.505 1.4163079973793051    -4.622119944849135
    1 2662   -4.4948854 -.085  .678  -4.43 1.6926628200562752   -.38176665505436613
    1 2663    -3.794471   .05  .673   -4.5  1.693604079629665    2.4970131620495963
    1 2664    -2.399703  .062   .72 -4.562 1.7671561967812408    2.4916699993821236
    1 2665   -1.2301767  .098  .707  -4.66 1.8397222106164126    1.5800300368849285
    1 2666   -.02084734 -.038   .71 -4.622 1.7618170066209218   -1.8240118736859503
    1 2667     -3.17759  -.04  .676 -4.592 1.7340149081434277     1.275432996929629
    1 2668    2.0387292  .033  .555 -4.625  1.715194995191062   -1.8915277356327964
    1 2669     4.431844  .095  .438  -4.73 1.7660864784253272   -1.7051377914081334
    1 2670    2.0286262 -.068  .453 -4.662 1.7610357346456798    -.6787760757977161
    1 2671     3.648649 -.014  .429 -4.648 1.7508231171898256    .43859022795343583
    1 2672   -.39606455 -.055   .41 -4.593 1.7515992200879589     -1.04958792416316
    1 2673    2.0959997  .017  .402  -4.61 1.7628684943765864   -2.1888938028388063
    1 2674   -.57866335 -.115  .443 -4.495 1.8155626647177474   -.43398535606679733
    1 2675     .9597614 -.047  .407 -4.448 1.8095845981981475   -1.7077387418239696
    1 2676   -1.1954378 -.023  .422 -4.425  1.767361813090533     .4869458777954068
    1 2677    -2.151988  .112  .491 -4.537  1.769036574149272    1.8281514181618677
    1 2678     4.020121 -.087  .522  -4.44  1.819907298817361    1.4108646608935513
    1 2679     -.798795  -.28  .535  -4.15  1.800898058442117    -3.949651724233625
    1 2680   -2.2499597  .052  .528 -4.182 1.9635516889520077    2.8618321887743607
    1 2681     6.821631 -.017   .37 -4.155 2.0602210491300665   -3.9654748575038923
    1 2682     8.320492 -.573  .683 -3.562 2.1743817739648046    -7.522734047108302
    1 2683    -6.329792 -.287  .803 -3.265 2.6367421119673335    1.5766933469140159
    1 2684    2.9761906 -.048  .693 -3.207 2.5353182171185713   -1.7273692224239454
    1 2685   -4.2899795  .228  .632 -3.425  2.548695824188542     2.367308297120483
    1 2686     3.468886  .022  .621 -3.437  2.541440730099301    1.0446577226284726
    1 2687    4.3446507 -.042  .518 -3.385 2.4765897543220756   -1.1445500903614576
    1 2688    3.3386025  -.13  .595 -3.235  2.428675361234843   -1.1312620043498918
    1 2689     .7114637  -.01  .415 -3.215 2.4185564795835353   -6.1976626730332605
    1 2690    1.4596647   .15  .485 -3.345  2.639852149859998     2.684532930652011
    1 2691   -12.182372  .028    .5 -3.363 2.7490823934272424     3.795944489814311
    1 2692   -2.0574746  .172   .47 -3.525 2.9129117867801324    1.0547974820407093
    1 2693    -5.270694  .067  .445 -3.572  2.934053294285755   -1.5218474941745161
    1 2694     4.460663   .09  .438 -3.632 2.9332823701430137     5.052613607414843
    1 2695    1.1965858 -.179  .372 -3.423 3.1688320999331028   -1.7081874977930358
    1 2696     4.334311 -.293  .495  -3.12  3.157061366348881     .3749084326963342
    1 2697    10.010023 -.207  .592 -2.903  3.160271783331769   -2.8173405167613232
    1 2698    -7.745926  -.14  .562 -2.743 3.1929218714922425     -4.76452240483819
    1 2699    -5.994937  .257  .468  -2.98  3.322992243493245     7.377902286377069
    1 2700     3.174716 -.162  .427 -2.818  3.702215341502475   -2.0075714069156563
    1 2701     .2497762  .027   .36 -2.845  3.698228023091123    -1.083340338159949
    1 2702   -1.1120242  .062  .383 -2.917  3.619329337570441    -.4800649948455351
    1 2703   -1.0945833  .006  .307 -2.933 3.5481368849425876    -2.067495742524925
    1 2704   -1.1993505   .22  .227 -3.183   3.11073174175345    2.1076513183821906
    1 2705    -.8100374 -.013   .24  -3.19 3.1255876525035298    1.0186192233876556
    1 2706    -3.161332   .01  .235  -3.22 3.1071720480439073    1.1709856678108885
    1 2707    -1.691623  -.01   .12  -3.21 3.0767826841817936    -.8794244540155812
    1 2708   -1.4080682  .255  .173 -3.475 3.0757760261973823   -.15581816512680075
    1 2709    -.0408997  .102  .091 -3.587 3.0653838996064957   -1.1698759724747483
    1 2710    -2.132569  .008  .155 -3.595 3.0661034645954475     2.615907787896311
    1 2711     .0715478  .017  .125 -3.612  2.772921126406654    -.8035809639706244
    1 2712    1.4485713 -.122  .145  -3.49 2.7385126512327522   -1.4613518717704372
    1 2713    -.3117352  -.06  .432  -3.43 2.6458533451889323    1.4829147087733219
    1 2714    -1.322089 -.097  .497 -3.333 2.6551428757497284     -.143761919415108
    1 2715    -2.276538 -.193  .467  -3.14 2.6319334877419096    1.5269143410572479
    1 2716    1.6668047  -.01  .465  -3.13 2.4166808015148824    -.3524065440918702
    1 2717    .27338463 -.125  .375 -3.005 2.3888892739421492    .08439425599848158
    1 2718   -1.4830655  -.03  .393 -2.975 2.3877226130783806     1.015932407617238
    1 2719   -1.6529385  -.24  .455 -2.735 2.3092622283079054   -.13705283499548868
    1 2720  -.000658736  -.12  .485 -2.615  2.029760525169237     .7748446636045287
    1 2721     6.540211  -.04  .283 -2.575 1.3105454692554044    -2.611736751486615
    1 2722     6.276432 -.268  .315 -2.307 1.3622552663857266    -5.761644200987351
    1 2723     5.970535 -.054  .435 -2.253 1.8352911630212743   -.43370760723127944
    1 2724    -.6386299 -.246  .391 -2.017 1.8349015287334982     .8803489005351751
    1 2725    -2.921783  .248  .328 -2.265 1.7940036585804615  -.014313000670992726
    1 2726   -1.9986483 -.008  .283 -2.257  1.771275372345322     -.178343870448602
    1 2727   -2.0514207  .118  .235 -2.375 1.7040406914706847    -.2284578117936453
    2 2548     2.629078     . 1.095 -1.785 2.7810151370826133                   .58
    2 2549    4.5859957 -.105 1.053  -1.68 2.6373930914446317   -5.0966443592027515
    2 2550    1.7701292  -.05  1.23  -1.62 2.7471525921865956   -6.0594689314225025
    2 2551     -.371591 -.275 1.508 -1.335 2.8945651093842018     5.768873571119743
    2 2552   -2.2165937  .175 1.673  -1.48 3.0241858667411057    -1.991847612206841
    2 2553   -2.3378265 -.145  1.61 -1.305  3.034059877746771    2.5356717733132266
    2 2554     .6057283   .02  1.52 -1.425  3.030627951001934    -4.506250579274458
    2 2555     .1524332  .105 1.653  -1.53  3.092315907276839   -1.7166912828761864
    2 2556      4.98236  -.11   1.8  -1.48 3.0940024905512584     -6.12921043198019
    2 2557   -.27283683   .04  1.84  -1.55 3.0924642970343443     6.168079637594314
    2 2558    -6.869445 -.072 1.772 -1.508 3.2043445446557355    3.6051576393061833
    2 2559     1.405144  .362 1.785   -1.9 3.0698937688069337     5.773014579491893
    2 2560    -1.555155 -.005  1.66 -1.955 3.1211297339023254     1.718899834085095
    2 2561    -4.268001  -.06  1.88 -1.965  3.098783571849712   -1.7325095351009716
    2 2562      .880039 -.005 1.833  -2.07 2.9999885894402594     2.799619199471798
    2 2563   -3.1911955 -.142  1.94 -2.098 2.9880034600740117   -1.7004987920957886
    2 2564     -7.74969 -.043 2.068 -2.055  3.002231214485392    1.5097348839948999
    2 2565    -3.062011   .33 2.065 -2.415  2.984462719971723     4.427532952758093
    2 2566     2.663042 -.077 2.077 -2.348  2.980802817647755    -4.358603999869878
    2 2567    -3.066733  .247  2.18 -2.605  2.974963310740649   -.27334385343462597
    2 2568     -5.82618 -.188 2.458 -2.427 2.8132807402624866    1.4274460393891875
    2 2569     .4897721  .233 2.505   -2.7  2.819373196980759     3.955216240050557
    2 2570    -.8992565   .16 2.285  -2.91  2.864585014574879     2.285386994160068
    2 2571     2.447538  .185 2.298 -3.105  3.957455658876803   -4.0535909772619405
    2 2572   -1.6546135 -.095   2.2  -3.01 3.8944374500454835    .09991162495808209
    2 2573   -.26566568  -.24 2.238  -2.79 3.6172532078372033   -1.9599851728097357
    2 2574     .9731455 -.075   2.2 -2.735 3.4750176000920776    -.9049598134603207
    2 2575    -3.337402  .127 2.243 -2.892  3.447632558511944     5.310846239404697
    2 2576     -4.51124  .175 2.305 -3.107  3.577521914393277     2.184798861600997
    2 2577    -9.304085  .101 2.112 -3.248  3.409088907839278    3.7051050388190574
    2 2578    1.0691315  .192 1.957  -3.48  3.411585127758548    1.3013032649590623
    2 2579   -1.7883765  .145 1.753 -3.635  3.007273272297112    3.6933033164836155
    2 2580   -4.7040987 -.168 1.698 -3.477  2.864177177454631    -3.895810281397721
    2 2581   -2.9189386  .223 1.473  -3.71 3.0201286992730085     4.532463424223117
    2 2582   -1.5403048  -.02 1.553  -3.69 2.9365829060079713     -1.19171698435996
    2 2583    -2.499435  -.29  1.68   -3.4 2.9639544890784557    3.5398987737451373
    2 2584   -1.7295512   .02 1.695  -3.42 2.9642756982928673     2.090023451631084
    2 2585   -.13412775 -.012 1.637 -3.408 2.9478012264953635    .44208361053973116
    2 2586     .4360868  .109 1.418 -3.517   2.88958518713842    -2.401686437228359
    2 2587    -6.739823  .291 1.215 -3.818 2.9810821464315618     3.256906878939119
    2 2588   -3.7318716  .307  1.29 -4.125 2.9251752850883026    1.7260137073954815
    2 2589     3.693121  .135  1.27  -4.27  2.686807666528203    .48243537409371573
    2 2590     4.988012  -.23  1.32  -4.04  2.672799369515991    -4.554990827434343
    2 2591    -4.898635  -.06  1.46  -3.98  2.936154756044888   -1.0755933376382465
    2 2592    -3.525192  -.01  1.37  -3.98 2.8816950042676526     2.435344052258398
    2 2593   -2.1811442  -.08  1.31   -3.9 2.8858866207539298    -.4479993872042405
    2 2594     1.887825  -.12   1.2  -3.78  2.701274978916767    -2.456250576395207
    2 2595     .9658713   .16 1.235  -3.94  2.787976380143928     2.832449794397311
    2 2596     .9112878  .145 1.255 -4.085   2.75575251078178   -1.4874778656138934
    2 2597   -2.0088067 -.227 1.322 -3.858   2.77700533861429     .3098934651309841
    2 2598   -.03829229  .042 1.507   -3.9 2.5985662200160533    2.9543792479823643
    2 2599     -3.55804   .08 1.495  -3.98 2.6247966144001147    1.6718947944442966
    2 2600    -.7254243   .11  1.42  -4.09 2.5493119535812254     .8656841566197312
    2 2601     5.371403   .01 1.295   -4.1 2.5455003180567313   -.23861763948450082
    2 2602     2.432629  -.08 1.215  -4.02  2.454794879531334   -3.0916265354032157
    2 2603    2.8201625  -.05  1.23  -3.97  2.392561543265756    -3.899028578186635
    2 2604    1.6230736  -.15 1.393  -3.82  2.384997926518158   -1.2804159468561467
    2 2605   -3.6646495   .19  1.32  -4.01 2.3873240990007476    1.0749817252307041
    2 2606     2.467511   .05 1.338  -4.05  2.272078297317733     1.598770897339594
    2 2607     .1116983 -.083 1.283 -3.947 2.2525190580241485    .05759157380940147
    2 2608    1.0175803  .075 1.163 -4.012    2.2499418287691     2.753166936101085
    2 2609   -1.7283446  .188 1.185   -4.2  2.264554475542964    1.0675203517278584
    2 2610    -.8380722  -.01 1.175  -4.18 2.1679566713010217     1.139591130238571
    2 2611    -3.631711  .065 1.193 -4.235  2.150015242988553     .4865781240443999
    2 2612    -.8254657 -.017 1.234 -4.208 2.1500567214032924    .22804143182495423
    2 2613    -.4738091  .037 1.265 -4.215  1.890207055879812     .8185291156125228
    2 2614     1.643637 -.057 1.332 -4.078  1.869984474347242     .7280622822523631
    2 2615    -.5034129  .017 1.275 -4.075 1.8132818424280914   -2.1375509721209727
    2 2616     2.568371  -.05  1.24 -3.975 1.8792067734105444   -1.5405111967285314
    2 2617     4.903638  -.17 1.148 -3.765   1.82742329196346    -7.093184143475756
    2 2618     3.948631   .13 1.075 -3.895  2.313249053508092    2.8720918931733186
    2 2619     3.290211 -.235 1.212  -3.66 2.3858015256263365     -6.89407681399508
    2 2620    -5.385956   .08 1.168  -3.74 2.7960679296398676    3.4829652743497306
    2 2621     3.113426   .07 1.077  -3.82  2.827968412816362    -.2037278847078549
    2 2622    -3.842795   .16  .893  -3.98 2.7926954814800915    1.2806551825628505
    2 2623   -1.9090574   .02  .825     -4 2.8031632806409794    1.0249878594640722
    2 2624     3.079694 -.047  .779 -3.963 2.8195157839811436   -3.0627936317464544
    2 2625     2.802812 -.018   .65 -3.975 2.8181832655031687    -4.028753861211932
    2 2626    -2.727195  .087  .558 -4.102  2.826107381556637     3.678179644790373
    2 2627    1.9733664  .008  .562  -4.15 2.9433928208206344      .587078951414072
    2 2628    -2.248065  .055  .575 -4.245  2.935778188101532     .8350581643263473
    2 2629   -1.5520164 -.105  .705  -4.18   2.91866111025161     .7987634212173264
    2 2630    -1.519746   .07   .58  -4.28 2.9257814018464234    1.5738165889767148
    2 2631    1.2139436 -.065  .515 -4.225  2.880616788970083    -2.345432769903252
    2 2632     .1164318 -.097  .507 -4.128 2.9010395790442143    -.6291933084513827
    2 2633    -4.813754 -.078  .475  -4.05 2.8821452263009215   -1.3726385359829767
    2 2634    -1.364688  .047  .478 -4.097  2.881135036356614     3.842659609385382
    2 2635   -1.9965447  .168  .422 -4.265  3.025178504147273    .43073203022233003
    2 2636   -1.5564448  .075  .485  -4.34 3.0191456843439957    1.7130187916681274
    2 2637   -1.0920383   .05   .38  -4.39  3.043432595676172    -.7631997801212318
    2 2638    -.4994613  .018  .365 -4.408 3.0184959403969995    -.4879688899808514
    2 2639    -3.131054 -.016  .326 -4.392  3.005617945437295    2.2280607057951314
    2 2640     1.258569 -.062   .48  -4.33  2.622653542150745    .16253091024615604
    2 2641    .48974925  .028  .512 -4.368 2.5542834176523206      -.88280002122249
    2 2642    -2.530986 -.105   .67 -4.263 2.0425098690095247    .27569461757710356
    2 2643   -1.2059354  .235  .475 -4.488 1.9195546308133273    2.9733133181954963
    2 2644     3.688177 -.048  .635  -4.43 2.0044520637773826    -2.288448655416536
    2 2645    -.8842745  .265   .51 -4.695 2.0694307165252583   -1.3677593018010419
    2 2646     .5872384 -.072  .562 -4.623  2.086470772923708    -.6725921789694679
    2 2647     -2.55284 -.091  .638 -4.532 1.9739522876260853    2.0656900650754118
    2 2648    .56127834  .108  .648  -4.64 1.7703093089415542     1.108799410255161
    2 2649    -.4186761  .017  .618 -4.657 1.6276314643423193    .37387699320388923
    2 2650   -1.9698036  .091  .607 -4.748 1.6268113189864757    .30893150064145836
    2 2651    1.1523995 -.098  .565  -4.65  1.623114529268775    -.6588081400407209
    2 2652     .9903656 -.083  .726 -4.567 1.6323744631098123    -.8846509176016479
    2 2653   -1.2012292 -.037  .662  -4.52  1.621837836933651    2.0836232541292286
    2 2654   -1.0957601  .075  .728 -4.595 1.5724729402559996    -.9683154933373135
    2 2655   -3.5324504 -.135  .713  -4.46 1.5840823086047489     .3741832872738627
    2 2656    -2.893765   .19   .71  -4.65  1.537876065576412    1.8113702799147073
    2 2657    -.2990567 -.053  .773 -4.597 1.3740726283899911    .37470702593740307
    2 2658   -3.0940266 -.017  .732  -4.58 1.3739002979759858    1.1267008073025377
    2 2659    -6.628171  -.06  .687  -4.52 1.3509381874579056     -2.04307621061917
    2 2660    -.1947127  .053  .682 -4.573  1.423863630635252     .5624195919647393
    2 2661    2.1755579 -.078  .658 -4.505 1.4163079973793051    -4.622119944849135
    2 2662    -7.978063 -.085  .678  -4.43 1.6926628200562752   -.38176665505436613
    2 2663    -2.832858   .05  .673   -4.5  1.693604079629665    2.4970131620495963
    2 2664     .1591145  .062   .72 -4.562 1.7671561967812408    2.4916699993821236
    2 2665     2.640844  .098  .707  -4.66 1.8397222106164126    1.5800300368849285
    2 2666   -1.8284698 -.038   .71 -4.622 1.7618170066209218   -1.8240118736859503
    2 2667    -3.908869  -.04  .676 -4.592 1.7340149081434277     1.275432996929629
    2 2668    -.9826771  .033  .555 -4.625  1.715194995191062   -1.8915277356327964
    2 2669     .1717184  .095  .438  -4.73 1.7660864784253272   -1.7051377914081334
    2 2670   -.09962656 -.068  .453 -4.662 1.7610357346456798    -.6787760757977161
    2 2671  .0045263274 -.014  .429 -4.648 1.7508231171898256    .43859022795343583
    2 2672      .191198 -.055   .41 -4.593 1.7515992200879589     -1.04958792416316
    2 2673    1.2106097  .017  .402  -4.61 1.7628684943765864   -2.1888938028388063
    2 2674     3.299508 -.115  .443 -4.495 1.8155626647177474   -.43398535606679733
    2 2675    -2.618746 -.047  .407 -4.448 1.8095845981981475   -1.7077387418239696
    2 2676  -.071456514 -.023  .422 -4.425  1.767361813090533     .4869458777954068
    2 2677    -1.841077  .112  .491 -4.537  1.769036574149272    1.8281514181618677
    2 2678      .328508 -.087  .522  -4.44  1.819907298817361    1.4108646608935513
    2 2679   -1.3590776  -.28  .535  -4.15  1.800898058442117    -3.949651724233625
    2 2680    -3.391631  .052  .528 -4.182 1.9635516889520077    2.8618321887743607
    2 2681     3.175262 -.017   .37 -4.155 2.0602210491300665   -3.9654748575038923
    2 2682     12.00679 -.573  .683 -3.562 2.1743817739648046    -7.522734047108302
    2 2683    -2.954155 -.287  .803 -3.265 2.6367421119673335    1.5766933469140159
    2 2684     .2159312 -.048  .693 -3.207 2.5353182171185713   -1.7273692224239454
    2 2685    -3.831357  .228  .632 -3.425  2.548695824188542     2.367308297120483
    2 2686     -.652559  .022  .621 -3.437  2.541440730099301    1.0446577226284726
    2 2687     2.029698 -.042  .518 -3.385 2.4765897543220756   -1.1445500903614576
    2 2688    2.3429224  -.13  .595 -3.235  2.428675361234843   -1.1312620043498918
    2 2689     5.558948  -.01  .415 -3.215 2.4185564795835353   -6.1976626730332605
    2 2690     1.898694   .15  .485 -3.345  2.639852149859998     2.684532930652011
    2 2691   -3.6434615  .028    .5 -3.363 2.7490823934272424     3.795944489814311
    2 2692   -.58795494  .172   .47 -3.525 2.9129117867801324    1.0547974820407093
    2 2693    -7.430851  .067  .445 -3.572  2.934053294285755   -1.5218474941745161
    2 2694     3.823885   .09  .438 -3.632 2.9332823701430137     5.052613607414843
    
    end
    format %tw time_period
    label values FI FI
    label def FI 1 "AU000000ANZ3", modify
    label def FI 2 "AU000000AUB9", modify

  • #2
    The problem is not with -runby-, nor is your program problematic except in one respect: -bsqreg- does not allow time-series operators in its varlist.

    So you have to create the lagged variables yourself, and then use them in your regression. Also, the way -runby- works, you will need to -tsset- the data inside your program.

    So, like this:
    Code:
    capture program drop one_id
    program define one_id
        tsset time_period
        foreach v of varlist ch_tbill3M Tyield_10Y3M TEDspread {
            gen L_`v' = L.`v'
        }
        bsqreg Xit1 L_ch_tbill3M L_Tyield_10Y3M L_TEDspread, q(0.95) reps(1000)
        foreach v of varlist L_ch_tbill3M L_Tyield_10Y3M L_TEDspread{
            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
        drop L_*
        exit
    end
    
    runby one_id, by(FI) status

    Comment


    • #3
      Thank you Clyde,
      The code is definitely helpful but one problem I am facing is that since I have 800 plus firms in my sample, the estimation is taking ages and after 2 hours, it gets stuck and does not compute further. Any way to work around this issue.

      Another thing is that could you explain to me how does reps (1000) in the code be different than reps (150)? Will it have any impact on the estimation time?

      Thanking in anticipation!

      Regards

      Comment


      • #4
        Hi,

        Can someone help me around the above issue in #3. Is there a way to work around this. Any advice is appreciated.

        Regards

        Comment


        • #5
          -bsqreg- is -qreg- estimated using bootstrapping. The execution time is directly proportional to the number of reps specified. So reps(1000) means a little more than 6 times as long for execution as reps(150). Technically speaking, bootstrap estimation is an asymptotic procedure: it converges to correct results as the number of replications grows larger and larger. There is no hard and fast number of reps that is "enough." It depends on the particular estimation taking place. You might find https://www.stata.com/support/faqs/s...es-guidelines/ helpful in thinking about what you should do in this regard. I suspect that you can do with considerably fewer than 1000 reps, but you may have to do some experimentation to find out.

          after 2 hours, it gets stuck and does not compute further
          Based just on this description, it is impossible to know what is going wrong. Were there any messages? Add the -verbose- option to your -runby- command and try again. You will get the detailed output of program one_id, and this will better enable you to see what is happening when it gets stuck. -qreg- itself is an iterative estimator, so you have the 1000 reps of the bootstrap amplified by however many iterations it takes for each of the 1000 reps to converge. My best guess is that the "getting stuck" is due to some rep of some FI taking hundreds of iterations to converge. But that's a guess with low confidence.

          I would also add that 2 hours is hardly "forever." If you are doing complicated calculations on a large data set, you have to expect it to take time. In my work, from time to time I will fit models that take 2 weeks or somewhat longer before they finish.

          Comment

          Working...
          X