Announcement

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

  • #61
    Please check this paper: Vogelsang, T. J. (1998). Trend function hypothesis testing in the presence of serial correlation. Econometrica, 123-148.

    Page 134 - section: Model with simple linear trend.
    Page 135 Table 11(i).
    Last edited by Sartaj Hussain; 02 Feb 2023, 19:37.

    Comment


    • #62
      I do not have access to that journal. Can you either show the material on those pages in a post or send me the article?

      Comment


      • #63
        I mailed the article.

        Comment


        • #64
          Thank you. I believe the following code does what you want. You did not say how you wanted the Vogelsang statistic stored in your data. So the code below simply shows them in the Results window. If you want to save them as variables in your data set (which is a questionable thing to do given that each is just a single value, but it's legal and might be convenient) you can just replace the -display- commands with -gen new_variable_name = `r(t_ps)'- commands. Or saving it as a scalar or local macro might make more sense. It all depends on what you plan to do with the results.

          The code begins by calculating the time series of cross-sectional means of idiovol and idiovol weighted by lagged mcap (named lmcpw_mean_idiovol). The core of the code is the program vogelsang, which calculates the Vogelsang T-PS statistic. Before using program -vogelsang-, you must -tsset- the data so that Stata will know which variable (mdate in this case) identifies time. To use program -vogelsang- you must specify which variable you wish to calculate T-PS for, and then specify in option -level()- the confidence level you intend to use for your trend test. This confidence level is 1 minus the Type I error rate you wish to allow expressed as a percentage. In other words, if you want, say, a .05 significance cutoff for your trend test, specify -level(95)-. The T-PS statistic is a bit peculiar because the actual calculation of the statistic depends on the significance cutoff you plan to use. And Vogelsang provides the necessary "b" values to do this only for level = 90, 95, 97.5, or 99. So you must specify one of those values in your -vogelsang- command's -level()- option. Again, to emphasize, you cannot omit -level()- and the only values permissible are 90, 95, 97.5, or 99.

          The code ends with a demonstration of the calculations, with T-PS displayed in the Results window.

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input float stock_id str52 stock int date float mdate double(pr mcap) float idiovol
          1 "20 Microns Ltd."  20423 671     36.5    128.8  .15180425
          1 "20 Microns Ltd."  20454 672     27.3    96.33  .10950197
          1 "20 Microns Ltd."  20485 673     26.1     92.1  .09301163
          1 "20 Microns Ltd."  20514 674    28.15    99.33  .07924972
          1 "20 Microns Ltd."  20545 675     31.7   111.86    .158713
          1 "20 Microns Ltd."  20575 676    28.55   100.74 .072114795
          1 "20 Microns Ltd."  20606 677     29.7    104.8  .06689945
          1 "20 Microns Ltd."  20636 678     29.3   103.39  .06400682
          1 "20 Microns Ltd."  20667 679     38.2   134.79  .21093673
          1 "20 Microns Ltd."  20698 680    36.45   128.62   .0909415
          1 "20 Microns Ltd."  20728 681    40.65   143.44  .08971238
          1 "20 Microns Ltd."  20759 682     35.7   125.97  .10669856
          1 "20 Microns Ltd."  20789 683    32.95   116.27  .08298702
          1 "20 Microns Ltd."  20820 684    38.75   136.74  .14690407
          1 "20 Microns Ltd."  20851 685    36.05   127.21  .05534502
          1 "20 Microns Ltd."  20879 686       35    123.5  .06207231
          1 "20 Microns Ltd."  20910 687     43.9   154.91  .22075494
          1 "20 Microns Ltd."  20940 688    37.25   131.44  .07736997
          1 "20 Microns Ltd."  20971 689    37.85   133.56  .08051722
          1 "20 Microns Ltd."  21001 690    38.55   136.03   .0807961
          1 "20 Microns Ltd."  21032 691    37.45   132.15 .069374084
          1 "20 Microns Ltd."  21063 692     41.7   147.14  .13633128
          1 "20 Microns Ltd."  21093 693     51.4   181.37   .1800664
          1 "20 Microns Ltd."  21124 694     58.3   205.72  .14240031
          1 "20 Microns Ltd."  21154 695     58.3   205.72   .1068619
          1 "20 Microns Ltd."  21185 696    52.75   186.14   .1121357
          1 "20 Microns Ltd."  21216 697     50.5    178.2   .0620272
          1 "20 Microns Ltd."  21244 698     49.1   173.26   .1247453
          1 "20 Microns Ltd."  21275 699     47.6   167.96  .14557002
          1 "20 Microns Ltd."  21305 700       43   151.73  .14636737
          1 "20 Microns Ltd."  21336 701     35.6   125.62  .07735473
          1 "20 Microns Ltd."  21366 702     41.7   147.14   .0823111
          1 "20 Microns Ltd."  21397 703    49.25   173.79  .16660585
          1 "20 Microns Ltd."  21428 704    42.45   149.79   .0817884
          1 "20 Microns Ltd."  21458 705     42.8   151.03  .05799506
          1 "20 Microns Ltd."  21489 706     42.8   151.03  .10888863
          1 "20 Microns Ltd."  21519 707     42.2   148.91  .04020227
          1 "20 Microns Ltd."  21550 708    37.05   130.74  .07178653
          1 "20 Microns Ltd."  21581 709    36.55   128.97  .10064302
          1 "20 Microns Ltd."  21609 710     38.2   134.79   .0774306
          1 "20 Microns Ltd."  21640 711     37.1   130.91  .04773393
          1 "20 Microns Ltd."  21670 712     40.6   143.26  .10399453
          1 "20 Microns Ltd."  21701 713    37.05   130.74   .0635552
          1 "20 Microns Ltd."  21731 714     33.8   119.27  .07565823
          1 "20 Microns Ltd."  21762 715    33.75   119.09  .10563102
          1 "20 Microns Ltd."  21793 716    40.05   141.32  .07741617
          1 "20 Microns Ltd."  21823 717    38.35   135.32  .07788575
          1 "20 Microns Ltd."  21854 718    33.55   118.39  .08756137
          1 "20 Microns Ltd."  21884 719     35.2   124.21  .06998083
          1 "20 Microns Ltd."  21915 720     34.9   123.15  .11265282
          1 "20 Microns Ltd."  21946 721     31.2   110.09   .0808599
          1 "20 Microns Ltd."  21975 722    25.55    90.16   .1146018
          1 "20 Microns Ltd."  22006 723    29.05   102.51  .22777008
          1 "20 Microns Ltd."  22036 724    26.15    92.27  .05658275
          1 "20 Microns Ltd."  22067 725     32.4   114.33  .19901267
          1 "20 Microns Ltd."  22097 726     28.6   100.92  .08823687
          1 "20 Microns Ltd."  22128 727    30.95   109.21  .11920004
          1 "20 Microns Ltd."  22159 728    28.25    99.68  .08832553
          1 "20 Microns Ltd."  22189 729     28.4   100.21  .05650701
          1 "20 Microns Ltd."  22220 730     32.1   113.27  .07832587
          1 "20 Microns Ltd."  22250 731     40.2   141.85   .1509842
          1 "20 Microns Ltd."  22281 732    36.65   129.33  .07885768
          1 "20 Microns Ltd."  22312 733    36.45   128.62  .06627448
          1 "20 Microns Ltd."  22340 734    35.15   124.03  .06961816
          1 "20 Microns Ltd."  22371 735     38.2   134.79  .06409864
          1 "20 Microns Ltd."  22401 736     64.1   226.19   .3120904
          1 "20 Microns Ltd."  22432 737    60.15   212.25  .12140137
          1 "20 Microns Ltd."  22462 738     66.5   234.66   .0796833
          1 "20 Microns Ltd."  22493 739    53.85   190.02  .07174803
          1 "20 Microns Ltd."  22524 740     61.2   215.95  .20695087
          1 "20 Microns Ltd."  22554 741    58.55    206.6  .09502423
          1 "20 Microns Ltd."  22585 742     58.1   205.01  .07524765
          1 "20 Microns Ltd."  22615 743    63.45   223.89  .08102456
          1 "20 Microns Ltd."  22646 744     91.5   322.87    .299464
          1 "20 Microns Ltd."  22677 745     71.2   251.24   .1011769
          1 "20 Microns Ltd."  22705 746    73.85   260.59 .069671996
          1 "20 Microns Ltd."  22736 747       81   285.82  .11349297
          1 "20 Microns Ltd."  22766 748    80.25   283.17  .16770604
          1 "20 Microns Ltd."  22797 749     68.6   242.07  .04877379
          1 "20 Microns Ltd."  22827 750     90.1   317.93   .1762419
          1 "20 Microns Ltd."  22858 751   109.65   386.92   .2041921
          1 "20 Microns Ltd."  22889 752    97.75   344.93  .08502114
          1 "20 Microns Ltd."  22919 753    88.95   313.87 .033111095
          1 "20 Microns Ltd."  22950 754    93.25   329.05  .08664793
          1 "20 Microns Ltd."  22980 755    91.05   321.28  .08273523
          2 "360 One Wam Ltd." 20423 671        .        .          .
          2 "360 One Wam Ltd." 20454 672        .        .          .
          2 "360 One Wam Ltd." 20485 673        .        .          .
          2 "360 One Wam Ltd." 20514 674        .        .          .
          2 "360 One Wam Ltd." 20545 675        .        .          .
          2 "360 One Wam Ltd." 20575 676        .        .          .
          2 "360 One Wam Ltd." 20606 677        .        .          .
          2 "360 One Wam Ltd." 20636 678        .        .          .
          2 "360 One Wam Ltd." 20667 679        .        .          .
          2 "360 One Wam Ltd." 20698 680        .        .          .
          2 "360 One Wam Ltd." 20728 681        .        .          .
          2 "360 One Wam Ltd." 20759 682        .        .          .
          2 "360 One Wam Ltd." 20789 683        .        .          .
          2 "360 One Wam Ltd." 20820 684        .        .          .
          2 "360 One Wam Ltd." 20851 685        .        .          .
          2 "360 One Wam Ltd." 20879 686        .        .          .
          2 "360 One Wam Ltd." 20910 687        .        .          .
          2 "360 One Wam Ltd." 20940 688        .        .          .
          2 "360 One Wam Ltd." 20971 689        .        .          .
          2 "360 One Wam Ltd." 21001 690        .        .          .
          2 "360 One Wam Ltd." 21032 691        .        .          .
          2 "360 One Wam Ltd." 21063 692        .        .          .
          2 "360 One Wam Ltd." 21093 693        .        .          .
          2 "360 One Wam Ltd." 21124 694        .        .          .
          2 "360 One Wam Ltd." 21154 695        .        .          .
          2 "360 One Wam Ltd." 21185 696        .        .          .
          2 "360 One Wam Ltd." 21216 697        .        .          .
          2 "360 One Wam Ltd." 21244 698        .        .          .
          2 "360 One Wam Ltd." 21275 699        .        .          .
          2 "360 One Wam Ltd." 21305 700        .        .          .
          2 "360 One Wam Ltd." 21336 701        .        .          .
          2 "360 One Wam Ltd." 21366 702        .        .          .
          2 "360 One Wam Ltd." 21397 703        .        .          .
          2 "360 One Wam Ltd." 21428 704        .        .          .
          2 "360 One Wam Ltd." 21458 705        .        .          .
          2 "360 One Wam Ltd." 21489 706        .        .          .
          2 "360 One Wam Ltd." 21519 707        .        .          .
          2 "360 One Wam Ltd." 21550 708        .        .          .
          2 "360 One Wam Ltd." 21581 709        .        .          .
          2 "360 One Wam Ltd." 21609 710        .        .          .
          2 "360 One Wam Ltd." 21640 711        .        .          .
          2 "360 One Wam Ltd." 21670 712        .        .          .
          2 "360 One Wam Ltd." 21701 713        .        .          .
          2 "360 One Wam Ltd." 21731 714        .        .          .
          2 "360 One Wam Ltd." 21762 715        .        .          .
          2 "360 One Wam Ltd." 21793 716  1235.05 10724.88          .
          2 "360 One Wam Ltd." 21823 717  1327.45 11527.26  .10851449
          2 "360 One Wam Ltd." 21854 718   1311.4 11398.11  .06815534
          2 "360 One Wam Ltd." 21884 719  1133.85  9876.49  .10201366
          2 "360 One Wam Ltd." 21915 720  1338.95 11665.33   .1548591
          2 "360 One Wam Ltd." 21946 721  1463.95  12759.9  .09001794
          2 "360 One Wam Ltd." 21975 722   1005.8  8768.67  .19371256
          2 "360 One Wam Ltd." 22006 723   953.05  8308.88    .153316
          2 "360 One Wam Ltd." 22036 724    844.6  7363.79  .05299322
          2 "360 One Wam Ltd." 22067 725  1021.75  8910.16  .14037482
          2 "360 One Wam Ltd." 22097 726  1070.25  9334.51   .0917381
          2 "360 One Wam Ltd." 22128 727   1023.5  8934.65  .09785583
          2 "360 One Wam Ltd." 22159 728   961.75  8402.17  .06192819
          2 "360 One Wam Ltd." 22189 729   919.95  8040.72  .07568683
          2 "360 One Wam Ltd." 22220 730  1015.65  8896.99  .07538057
          2 "360 One Wam Ltd." 22250 731  1011.85  8869.69 .072915204
          2 "360 One Wam Ltd." 22281 732   1013.9  8890.19  .06433145
          2 "360 One Wam Ltd." 22312 733   1212.4 10650.61    .089387
          2 "360 One Wam Ltd." 22340 734   1239.4 10892.19  .07450091
          2 "360 One Wam Ltd." 22371 735  1127.35  9911.39  .08722831
          2 "360 One Wam Ltd." 22401 736  1185.65 10425.99   .1233501
          2 "360 One Wam Ltd." 22432 737  1164.35 10239.89  .06242716
          2 "360 One Wam Ltd." 22462 738   1411.3  12411.7  .14326282
          2 "360 One Wam Ltd." 22493 739  1621.95 14336.16  .19245663
          2 "360 One Wam Ltd." 22524 740     1572  13902.7  .08563457
          2 "360 One Wam Ltd." 22554 741   1629.9 14419.77   .1597674
          2 "360 One Wam Ltd." 22585 742     1490 13192.93  .07566474
          2 "360 One Wam Ltd." 22615 743  1419.65 12586.08   .1090008
          2 "360 One Wam Ltd." 22646 744   1601.2 14197.31  .09659116
          2 "360 One Wam Ltd." 22677 745  1531.55 13581.43  .07130557
          2 "360 One Wam Ltd." 22705 746   1668.9 14804.45 .072800726
          2 "360 One Wam Ltd." 22736 747  1721.15  15271.3  .07746077
          2 "360 One Wam Ltd." 22766 748   1566.4 13903.23   .1180934
          2 "360 One Wam Ltd." 22797 749  1481.05  13146.7      .0755
          2 "360 One Wam Ltd." 22827 750  1671.95 14847.36  .07194163
          2 "360 One Wam Ltd." 22858 751  1677.45  14898.8  .03754364
          2 "360 One Wam Ltd." 22889 752   1840.3 16349.15  .12426206
          2 "360 One Wam Ltd." 22919 753   1771.4 15746.25  .09393045
          2 "360 One Wam Ltd." 22950 754  1828.55 16259.08 .073346466
          2 "360 One Wam Ltd." 22980 755   1776.5 15806.88  .04276332
          3 "3I Infotech Ltd." 20423 671     4.85   308.55   .3060178
          3 "3I Infotech Ltd." 20454 672     4.65   295.83 .070726916
          3 "3I Infotech Ltd." 20485 673     3.95   253.12   .1047636
          3 "3I Infotech Ltd." 20514 674     4.15   265.93  .09094843
          3 "3I Infotech Ltd." 20545 675     4.25   272.34  .06959453
          3 "3I Infotech Ltd." 20575 676      3.8   243.51  .07588033
          3 "3I Infotech Ltd." 20606 677      5.1   326.81   .2280496
          3 "3I Infotech Ltd." 20636 678      5.1   327.13  .12016416
          3 "3I Infotech Ltd." 20667 679     5.25   336.76  .19794016
          3 "3I Infotech Ltd." 20698 680     5.75   516.86  .12810433
          3 "3I Infotech Ltd." 20728 681     6.65   597.76  .11753883
          3 "3I Infotech Ltd." 20759 682     5.45   489.89  .13370286
          3 "3I Infotech Ltd." 20789 683     5.65   591.81  .08836084
          3 "3I Infotech Ltd." 20820 684      5.6   647.21   .1410187
          3 "3I Infotech Ltd." 20851 685      5.1   589.43  .06204581
          3 "3I Infotech Ltd." 20879 686     5.05   597.74  .07652818
          3 "3I Infotech Ltd." 20910 687      5.5   658.42  .08884872
          3 "3I Infotech Ltd." 20940 688     4.55   566.92 .065771624
          3 "3I Infotech Ltd." 20971 689     4.25   546.55  .14354813
          3 "3I Infotech Ltd." 21001 690     4.15   533.69  .09003264
          3 "3I Infotech Ltd." 21032 691      4.1   527.26  .08426387
          3 "3I Infotech Ltd." 21063 692     3.85   513.24   .0749923
          3 "3I Infotech Ltd." 21093 693      3.8   506.57   .0829519
          3 "3I Infotech Ltd." 21124 694     3.85   513.24  .10653754
          3 "3I Infotech Ltd." 21154 695        8  1067.32   .2758485
          3 "3I Infotech Ltd." 21185 696     6.15   982.81   .1855145
          3 "3I Infotech Ltd." 21216 697     5.85   943.44   .1086712
          3 "3I Infotech Ltd." 21244 698     5.05   815.76  .12166346
          3 "3I Infotech Ltd." 21275 699     4.95   799.68   .1494787
          3 "3I Infotech Ltd." 21305 700     4.75   767.37   .1535512
          3 "3I Infotech Ltd." 21336 701     4.25   686.61  .14887816
          3 "3I Infotech Ltd." 21366 702      3.6    581.6  .12549558
          3 "3I Infotech Ltd." 21397 703      3.6    581.6  .12537315
          3 "3I Infotech Ltd." 21428 704      3.4   549.41   .1612394
          3 "3I Infotech Ltd." 21458 705     3.35   541.33  .18406363
          3 "3I Infotech Ltd." 21489 706     3.75   605.97  .24836077
          3 "3I Infotech Ltd." 21519 707      3.6   581.99  .04507526
          3 "3I Infotech Ltd." 21550 708     3.35   541.58  .10845932
          3 "3I Infotech Ltd." 21581 709     3.35   541.58   .2566609
          3 "3I Infotech Ltd." 21609 710     3.85   622.41  .13771889
          3 "3I Infotech Ltd." 21640 711     3.75   606.24    .203421
          3 "3I Infotech Ltd." 21670 712      3.5   565.83   .0843905
          3 "3I Infotech Ltd." 21701 713      3.3   533.49  .09792581
          3 "3I Infotech Ltd." 21731 714     2.25   363.75  .16281416
          3 "3I Infotech Ltd." 21762 715     1.75   282.91   .1740527
          3 "3I Infotech Ltd." 21793 716        2   323.33   .2390153
          3 "3I Infotech Ltd." 21823 717        2   323.33   .1422637
          3 "3I Infotech Ltd." 21854 718     1.95   315.25 .074490055
          3 "3I Infotech Ltd." 21884 719     1.95   315.25  .10634084
          3 "3I Infotech Ltd." 21915 720     2.25   363.75  .27203667
          3 "3I Infotech Ltd." 21946 721     1.95   315.25  .17436054
          3 "3I Infotech Ltd." 21975 722      1.3   210.17   .2019477
          3 "3I Infotech Ltd." 22006 723      1.6   258.66    .320762
          3 "3I Infotech Ltd." 22036 724      1.6   258.66  .13443826
          3 "3I Infotech Ltd." 22067 725      2.7    436.5   .1723641
          3 "3I Infotech Ltd." 22097 726      2.4      388  .13619053
          3 "3I Infotech Ltd." 22128 727      3.7   598.16  .13160709
          3 "3I Infotech Ltd." 22159 728      3.3    533.5   .1590524
          3 "3I Infotech Ltd." 22189 729        3      485  .10993515
          3 "3I Infotech Ltd." 22220 730      3.4   549.66  .10065467
          3 "3I Infotech Ltd." 22250 731     6.45  1042.74  .10150602
          3 "3I Infotech Ltd." 22281 732     6.65  1075.08  .16562822
          3 "3I Infotech Ltd." 22312 733     6.15   994.24  .14929815
          3 "3I Infotech Ltd." 22340 734     7.45  1204.41  .13298213
          3 "3I Infotech Ltd." 22371 735     7.95  1285.24  .13116848
          3 "3I Infotech Ltd." 22401 736     8.75  1414.57  .14478727
          3 "3I Infotech Ltd." 22432 737     9.85  1592.41  .14785117
          3 "3I Infotech Ltd." 22462 738      9.3  1503.49  .07278715
          3 "3I Infotech Ltd." 22493 739     8.45  1366.07   .1158908
          3 "3I Infotech Ltd." 22524 740        .        .          .
          3 "3I Infotech Ltd." 22554 741    39.45   637.77          .
          3 "3I Infotech Ltd." 22585 742    97.95  1606.74  .14847663
          3 "3I Infotech Ltd." 22615 743    94.65  1565.85  .13450299
          3 "3I Infotech Ltd." 22646 744     77.7   1303.3 .066601284
          3 "3I Infotech Ltd." 22677 745    51.45   863.69  .08774507
          3 "3I Infotech Ltd." 22705 746    51.25   860.71  .16721526
          3 "3I Infotech Ltd." 22736 747    57.75   971.48  .14750819
          3 "3I Infotech Ltd." 22766 748    46.95   790.56  .09283502
          3 "3I Infotech Ltd." 22797 749     41.6   700.48  .05987921
          3 "3I Infotech Ltd." 22827 750    43.05   724.89  .08551042
          3 "3I Infotech Ltd." 22858 751     44.4   747.65   .1522279
          3 "3I Infotech Ltd." 22889 752    43.85   738.39  .15209863
          3 "3I Infotech Ltd." 22919 753     43.9   739.24 .065983735
          3 "3I Infotech Ltd." 22950 754    42.45   714.82  .05656059
          3 "3I Infotech Ltd." 22980 755    40.75   686.19  .06333806
          4 "3M India Ltd."    20423 671 11397.55 12839.42  .07020025
          4 "3M India Ltd."    20454 672  9881.15 11131.18  .05931601
          4 "3M India Ltd."    20485 673 10382.15 11695.56  .13843286
          4 "3M India Ltd."    20514 674 10724.95 12081.73  .04101915
          4 "3M India Ltd."    20545 675 13323.85 15009.41  .14088234
          4 "3M India Ltd."    20575 676 12415.15 13985.75  .05856196
          4 "3M India Ltd."    20606 677 12823.35 14445.59  .03768667
          4 "3M India Ltd."    20636 678 14619.65 16469.14  .07873284
          4 "3M India Ltd."    20667 679  12880.8 14510.31  .04725427
          4 "3M India Ltd."    20698 680  12883.9  14513.8 .028097766
          4 "3M India Ltd."    20728 681 13296.35 14978.43 .027521065
          4 "3M India Ltd."    20759 682 11293.45 12722.15  .06654049
          4 "3M India Ltd."    20789 683  11123.1 12530.25  .04974051
          4 "3M India Ltd."    20820 684  11957.5 13470.21  .07233124
          4 "3M India Ltd."    20851 685  11164.8 12577.23  .04566871
          4 "3M India Ltd."    20879 686 11567.55 13030.93  .03529178
          4 "3M India Ltd."    20910 687  11499.7 12954.49  .04965758
          4 "3M India Ltd."    20940 688  13835.2 15585.45  .10944718
          4 "3M India Ltd."    20971 689  13236.5 14911.01 .031300966
          4 "3M India Ltd."    21001 690 13378.25 15070.69  .04455712
          4 "3M India Ltd."    21032 691  14743.8 16608.99  .06961398
          4 "3M India Ltd."    21063 692  14301.4 16110.63  .02983945
          4 "3M India Ltd."    21093 693  14190.3 15985.47  .03149755
          4 "3M India Ltd."    21124 694 15441.15 17394.56  .08963791
          4 "3M India Ltd."    21154 695 19126.45 21546.08  .12155636
          4 "3M India Ltd."    21185 696 18796.15 21173.99 .063623324
          4 "3M India Ltd."    21216 697  20717.4  23338.3  .14194535
          4 "3M India Ltd."    21244 698 19412.85 21868.71  .03105159
          4 "3M India Ltd."    21275 699  20524.1 23120.54  .03873885
          4 "3M India Ltd."    21305 700  19543.6    22016  .04930488
          4 "3M India Ltd."    21336 701  19637.1 22121.33  .05655072
          4 "3M India Ltd."    21366 702  23420.9 26383.81  .10948846
          4 "3M India Ltd."    21397 703    25945 29227.22  .04893228
          4 "3M India Ltd."    21428 704 22568.05 25423.07 .069898285
          4 "3M India Ltd."    21458 705 19842.75    22353   .0974772
          4 "3M India Ltd."    21489 706    21634 24370.85  .05207479
          4 "3M India Ltd."    21519 707  20824.4 23458.83   .0847318
          4 "3M India Ltd."    21550 708  20151.6 22700.92  .04413396
          4 "3M India Ltd."    21581 709 22896.25 25792.79  .09397536
          4 "3M India Ltd."    21609 710 24260.85 27330.02  .06808542
          4 "3M India Ltd."    21640 711  22926.7 25827.09  .06719647
          4 "3M India Ltd."    21670 712  22741.8  25618.8  .06186471
          4 "3M India Ltd."    21701 713  23215.8 26152.76  .05808556
          4 "3M India Ltd."    21731 714  21107.9  23778.2  .05762339
          4 "3M India Ltd."    21762 715 20233.45 22793.12  .03594796
          end
          format %td date
          format %tm mdate
          
          capture program drop vogelsang
          program define vogelsang, rclass
              syntax varname, level(real)
              capture assert inlist(`level', 90, 95, 97.5, 99)
              if c(rc) != 0 {
                  display as error "level() must be 90, 95, 97.5, or 99"
                  exit(c(rc))
              }
              capture assert !missing("_:char _dta[tis]")
              if c(rc) != 0 {
                  display as error "Data must be tsset."
                  exit c(rc)
              }
              tempvar t z S tt u
              tempname tz rssy rssj jt b
              quietly {
                  if `level' == 90 {
                      scalar `b' = 1.451
                  }
                  else if `level' == 95 {
                      scalar `b' = 1.966
                  }
                  else if `level' == 97.5 {
                      scalar `b' = 2.685
                  }
                  else if `level' == 99 {
                      scalar `b' = 3.946
                  }
                  local time_var: char _dta[tis]
                  sort `time_var'
                  gen `t' = `time_var' - `time_var'[1] + 1
                  gen `tt' = sum(`t')
                  gen `z' = sum(`varlist')
                  regress `z' `t' `tt'
                  scalar `tz' = _b[`tt']/_se[`tt']
                  predict `u', resid
                  gen `S' = sum(`u')
                  regress `varlist' `t'
                  scalar `rssy' = e(rss)
                  regress `varlist' c.`t'##c.`t'##c.`t'##c.`t'##c.`t'##c.`t'##c.`t'##c.`t'##c.`t'
                  scalar `rssj' = e(rss)
                  scalar `jt' = (`rssy'-`rssj')/`rssj'
                  return scalar t_ps = `tz'*exp(-`b'*`jt')/(sqrt(_N)) // NEED TO INSERT b*
              }
              exit
          end
          
          //   CALCULATE MONTHLY CROSS-SECTIONAL SIMPLE AND
          //   LAGGED-MCAP WEIGHTED MEANS OF IDIOVOL
          xtset stock_id mdate
          gen lagged_mcap = L1.mcap
          by mdate, sort: egen mean_idiovol = mean(idiovol)
          by mdate, sort: egen numerator = total(lagged_mcap*idiovol)
          by mdate: egen denominator = total(lagged_mcap)
          gen lmcw_mean_idiovol = numerator/denominator
          drop numerator denominator
          by mdate: keep if _n == 1
          keep mdate mean_idiovol lmcw_mean_idiovol
          tsset mdate
          
          
          //   CALCULATE VOGELSANG'S T-PW STATISTIC
          //   FOR EACH OF THE TIME SERIES
          vogelsang mean_idiovol, level(95)
          display `r(t_ps)'
          
          vogelsang lmcw_mean_idiovol, level(99)
          display `r(t_ps)'

          Comment


          • #65
            This is amazing. But two clarifications:

            1. What does "NEED TO INSERT b* mean here:

            Code:
             return scalar t_ps = `tz'*exp(-`b'*`jt')/(sqrt(_N)) // NEED TO INSERT b*     }
            2. And how is t-stat generated by the code #64 different from t-stat of a simple linear trend test using following. I mean is the vogelsang t-ps in #64 also coming through a regression testing the trend in a mean idiovol variable

            Code:
            gen time = _n
            tsset time
            reg mean_idiovol time
            reg lmcw_mean_idiovol time.
            Moreover, apart from this, my objective is basically to test whether average idiovol of firms has changed in the Covid19 pandemic. The period for Covid19 pandemic is listed from February 2020 onwards. What should i do for this?
            Last edited by Sartaj Hussain; 04 Feb 2023, 13:22.

            Comment


            • #66
              What does "NEED TO INSERT b* mean here:
              Sorry, I meant to delete that comment (not the command, just the comment) but forgot to. While I was waiting for you to send me the article, I worked on the code for the Vogelsang T-PS. The "b" parameter that I needed only appears in that one command. So I wrote the rest of the code, leaving out `b'* from that expression, and put that comment in to remind myself that I needed to finish that command once I got the value(s) of "b". That's taken care of now. I should have removed the comment, but forgot to.

              And how is t-stat generated by the code #64 different from t-stat of a simple linear trend test using following:
              If the time series is stationary, the simple t-stat from the analysis in #65 is fine. But if it has a unit root, that t-stat produces misleading results. The Vogelsang T-PS works equally well whether there is a unit root or not. The motivation that Vogelsang provides in his article is that unit root tests are not particularly accurate (or, so he says, I wouldn't know), so it is convenient to have a test for trend that is equally good whether there is a unit root problem.

              Moreover, apart from this, my objective is basically to test whether average idiovol of firms has changed in the Covid19 pandemic.
              Answering this question stretches my knowledge of time-series analysis to, maybe beyond, its limits. My best guess is that you would want to create an indicator variable for the covid eraand then do a Newey-West regression to deal with the possibility of autocorrelation and heteroskedasticity. I have no idea how many lags would be appropriate for that. I also cannot advise you on what other variables might need to be included in the analysis to try to reduce extraneous variance or omitted variable bias. I suppose the general framework would be something like:
              Code:
              gen byte covid_era = (mdate >= tm(2020m2))
              newey mean_idiovol i.covid_era maybe_other_variables, lag(???)
              But I think you should run this by somebody with real expertise in econometrics before acting on my suggestions. I am an epidemiologist. Thedata I work with rarely includes high-frequency time series--getting such data is usually infeasible. So I have very little experience dealing with the special statistical issues that this kind of data can exhibit. There may be better ways of doing this that would be viewed more favorably by an econometrician.



              Comment


              • #67
                Fair enough. If we put AR(1) term and a term for intercept and a slope dummy to account for covid19. How can we get the vogelsang's t-stat for trend in this case.

                Comment


                • #68
                  The Vogelslang t-stat is just a simple test of linear time trend. I don't see how it would apply to this regression context.

                  Comment


                  • #69
                    Ok. What about the newey-west with specification in #67

                    Comment


                    • #70
                      I suppose it's reasonable. It looks reasonable to me. But, again, I have no idea if lag(1) is appropriate, and I wonder whether there should be additional variables in the model. I also wonder if an econometrician would recommend a different approach altogether.

                      Comment


                      • #71
                        In most literature, people used the vogelsang's trend statistics to test for presence of tend in the idiovol. That seems to be simplest and parsimonious choice. Lets do it seperately for covid and non covid periods. Moreover, if i use vogelsang's t stat. I require value of trend coefficient and adj R as well.
                        Last edited by Sartaj Hussain; 04 Feb 2023, 14:51.

                        Comment


                        • #72
                          Well, you can do that. But, first this will only help you if there is minimal or no trend pre-covid and an appreciable trend after, or vice versa. If there is a substantial trend in both eras, but it changes, you won't be able to detect that. In addition, it is not valid to infer that the trend is different in the two eras just because one passes a significance test and the other doesn't. General principle: the difference between statistically significant and not statistically significant is not, itself, necessarily statistically significant.

                          Comment


                          • #73
                            There seems to be trend in covid era from graphical inspection and no trend in pre covid era. Can i use it in that case

                            Moreover, the code gives only vogelsang's t stat. I require value of trend coefficient and adj R as well.

                            Comment


                            • #74
                              The trend coefficient is just the same as you would get from a simple OLS regression of idiovol on mdate, all Vogelsang does is calculate the t-statistic differently. Similarly, R2, adjusted or not, would not be affected.

                              Comment


                              • #75
                                Thanks indeed for explaining it nicely !

                                Comment

                                Working...
                                X