Announcement

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

  • #16
    Clyde Schechter Thank you for your reply, Clyde!

    Here is my partial dataset:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double permno float(quarter P1 double_P2 exret_m mktrf_m)
    10010 106 1 1       -.3845   -.08600003
    10010 113 1 1   .018909574    .04789996
    10010 114 1 1  -.006199956   .032999992
    10010 115 1 1    .08460915    .01489997
    10010 116 1 1   -.04751635   .015699983
    10010 117 1 1   -.18891817  -.013499975
    10011 122 1 1    .21622217   -.06120002
    10011 123 1 1   -.25600004    .02460003
    10011 124 1 1    .12746811   .026499987
    10011 125 1 1   -.29489768   -.04939997
    10011 126 1 1   -.25460005  -.015900016
    10011 127 1 1   -.05643159    .10839999
    10011 128 1 1    -.0926857  -.026600003
    10011 130 1 1     .0212096   .011899948
    10011 131 1 1    .05434287   .015300035
    10011 132 1 1   -.08062506         .023
    10011 133 1 1    .27919006  .0031000376
    10011 134 1 1     .1753142 -.0012000203
    10011 135 1 1  -.067873776   .016499996
    10012 181 1 1   -.25230002   .005699992
    10018 114 1 1  -.006199956   .032999992
    10018 115 1 1    -.4273526    .01489997
    10018 116 1 1     .7205727   .015699983
    10018 117 1 1  -.007099986  -.013499975
    10018 118 1 1    .04905558   -.00760001
    10018 138 1 1  -.003700018   -.02310002
    10018 140 1 1   -.25460005    .02190006
    10018 142 1 1   -.14715713   .033499956
    10028 167 1 1     .6489855   .016100049
    10028 168 1 1    -.1696169        .0424
    10028 169 1 1   -.27018887   -.07209998
    10028 170 1 1  -.001399994       -.1035
    10028 171 1 1   -.09855747   -.05760002
    end
    format %tq quarter
    ------------------ copy up to and including the previous line ------------------


    Data descriptions:
    P1: first single sort
    double_P2: second sort based on P1
    exret_m is the quarterly excess returns
    mktrf_m is the market factor

    The above 4*4 table is built after running
    Code:
    -program define myregress-, -rangestat-, -runby myregress- and -table P1 double_P2-
    similarly following the code in the post #9.

    Do you think it's possible to get the t-stat for the difference of excess returns based on P1 and double_P2? Many thanks for your help in advance! Hope to hear from you!
    Last edited by Jae Li; 08 Dec 2017, 10:20.

    Comment


    • #17
      Jae, this was not helpful. The code that you post near the bottom of #16 makes no sense. It represents, I suppose, some sort of summary of some things you have done along the way, but it is nothing that can be run. The data you are showing are, more or less, the raw data you started with, except that some of the variable names have changed.

      So I still don't know what you're trying to do here.

      Comment


      • #18
        Clyde Schechter Yes, that was a summary of codes I've done along the way. I should have put the full codes for better understanding. My apologies!

        Code:
        capture program drop myregress
        program define myregress
        rangestat (reg) exret_m mktrf_m, interval(quarter -2 0) by(permno)
        end
        runby myregress, by( P1 double_P2 ) verbose
        gen t_alpha = b_cons / se_cons
        table P1 double_P2, c(mean exret_m mean b_cons)
        table P1 double_P2, c(mean t_alpha)
        In this case, it can generate a 4*4 excess returns as early posted in the #14. Do you know how to get the t-stat for the difference of excess returns based on P1 and double_P2? Many thanks for your time and patience! Sorry for the confusion early!
        Last edited by Jae Li; 08 Dec 2017, 11:36.

        Comment


        • #19
          This is somewhat better, but still not adequate. In your example data P1 and double_P2 are always both 1, so the net result is just a single statistic, not a four by four grouping. You need to give a better example.

          Comment


          • #20
            @Clyde Schechter What about this data example? Is it adequate?

            ----------------------- copy starting from the next line -----------------------
            [CODE]
            * Example generated by -dataex-. To install: ssc install dataex
            clear
            input double permno float(quarter P1 double_P2 exret_m mktrf_m)
            10010 106 1 1 -.3845 -.08600003
            10010 113 1 1 .018909574 .04789996
            10010 114 1 1 -.006199956 .032999992
            10010 115 1 1 .08460915 .01489997
            10010 116 1 1 -.04751635 .015699983
            10010 117 1 1 -.18891817 -.013499975
            10011 122 1 1 .21622217 -.06120002
            10011 123 1 1 -.25600004 .02460003
            10011 124 1 1 .12746811 .026499987
            10011 125 1 1 -.29489768 -.04939997
            10011 126 1 1 -.25460005 -.015900016
            10011 127 1 1 -.05643159 .10839999
            10011 128 1 1 -.0926857 -.026600003
            10011 130 1 1 .0212096 .011899948
            10011 131 1 1 .05434287 .015300035
            10011 132 1 1 -.08062506 .023
            10011 133 1 1 .27919006 .0031000376
            10011 134 1 1 .1753142 -.0012000203
            10011 135 1 1 -.067873776 .016499996
            10012 181 1 2 -.25230002 .005699992
            10018 114 1 2 -.006199956 .032999992
            10018 115 1 2 -.4273526 .01489997
            10018 116 1 2 .7205727 .015699983
            10018 117 1 2 -.007099986 -.013499975
            10018 118 1 2 .04905558 -.00760001
            10018 138 1 2 -.003700018 -.02310002
            10018 140 1 2 -.25460005 .02190006
            10018 142 1 2 -.14715713 .033499956
            10028 167 1 2 .6489855 .016100049
            10028 168 1 2 -.1696169 .0424
            10028 169 1 3 -.27018887 -.07209998
            10028 170 1 3 -.001399994 -.1035
            10028 171 1 3 -.09855747 -.05760002
            10028 172 1 3 -.0010000467 .01090002
            10028 173 1 3 -.062538445 .014199972
            10028 174 1 3 .007396698 -.012399971
            10028 175 1 3 .14554143 .04289997
            10028 176 1 3 -.014793754 -.013199985
            10028 177 1 3 -.04767501 .018599987
            10028 178 1 3 .10108984 .016000032
            10028 179 1 3 .13093007 .03429997
            10028 180 1 3 .017507792 -.01969999
            10028 181 1 4 .09274125 .005699992
            10028 182 1 4 -.06207162 .004899979
            10028 183 1 4 -.09976333 -.0024999976
            10028 184 1 4 .12411964 .014600039
            10028 185 1 4 -.05180866 -.003499985
            10028 186 1 4 -.17076665 .018399954
            10028 187 1 4 .028520346 .008700013
            10028 188 1 4 -.05840665 .006800056
            10028 189 1 4 .4234511 -.019599974
            10028 190 1 4 -.048899 .03219998
            10028 191 1 4 -.02139157 -.008700013
            10028 192 1 4 -.068366766 -.0092999935
            10028 193 1 4 -.3253044 -.0844
            10028 194 1 4 -.18562704 -.09240001
            10028 195 1 4 .36 .017400026
            10028 196 1 4 -.0002000332 .08949995
            10028 197 1 4 .13392055 .0042999983
            10028 198 1 4 .14553106 .04079998

            Comment


            • #21
              No. You still have P1 = 1 in all observations. So you can't get a 4 x 4 table out of that, just a 1 x 4.

              Comment


              • #22
                @Clyde Schechter In my original dataset, P1 has values from 1 to 4. Since -dataex- only genenrates first 100 observations so you can only see P1 =1 for now.

                Comment


                • #23
                  Then rearrange the data set so that the first 100 observations contain examples of all combinations of P1 and double_P2. You could do something like this:

                  Code:
                  by P1 double_p2 (permno quarter), sort: keep if _n <= 25
                  dataex

                  Comment


                  • #24
                    Clyde Schechter Thank you for the code! It works! Here it is:

                    Code:
                    * Example generated by -dataex-. To install: ssc install dataex
                    clear
                    input double permno float(quarter P1 double_P2 exret_m mktrf_m)
                    10010 106 1 1       -.3845   -.08600003
                    10010 113 1 1   .018909574    .04789996
                    10010 114 1 1  -.006199956   .032999992
                    10010 115 1 1    .08460915    .01489997
                    10010 116 1 1   -.04751635   .015699983
                    10010 117 1 1   -.18891817  -.013499975
                    10011 122 1 1    .21622217   -.06120002
                    10011 123 1 1   -.25600004    .02460003
                    10011 124 1 1    .12746811   .026499987
                    10011 125 1 1   -.29489768   -.04939997
                    10011 126 1 1   -.25460005  -.015900016
                    10011 127 1 1   -.05643159    .10839999
                    10011 128 1 1    -.0926857  -.026600003
                    10011 130 1 1     .0212096   .011899948
                    10011 131 1 1    .05434287   .015300035
                    10011 132 1 1   -.08062506         .023
                    10011 133 1 1    .27919006  .0031000376
                    10011 134 1 1     .1753142 -.0012000203
                    10011 135 1 1  -.067873776   .016499996
                    10012 181 1 1   -.25230002   .005699992
                    10018 114 1 1  -.006199956   .032999992
                    10018 115 1 1    -.4273526    .01489997
                    10018 116 1 1     .7205727   .015699983
                    10018 117 1 1  -.007099986  -.013499975
                    10018 118 1 1    .04905558   -.00760001
                    10001 208 1 2    .04875994   .031100035
                    10001 209 1 2  -.027325034    .03890002
                    10001 210 1 2 .00040102005        .0273
                    10001 211 1 2   -.01533115    .01180005
                    10001 212 1 2   .030684114    .04030001
                    10001 213 1 2    .00632298  -.012000024
                    10001 214 1 2  .0044118166    .03770006
                    10001 215 1 2   -.05885786   .028100014
                    10001 217 1 2  .0090562105    .02610004
                    10001 218 1 2     .0509752   -.01969999
                    10001 219 1 2   -.03782606 -.0005999804
                    10001 220 1 2 -.0004950762   -.01120001
                    10001 221 1 2    .02999997  -.015299976
                    10001 222 1 2   .003366947  -.030799985
                    10001 223 1 2   -.13225102  -.021700025
                    10003 127 1 2   -.27303082    .10839999
                    10003 128 1 2    .13296366  -.026600003
                    10003 129 1 2     -.176277   -.02340001
                    10003 130 1 2    .29151773   .011899948
                    10003 132 1 2  -.031071484         .023
                    10003 133 1 2   -.02173084  .0031000376
                    10003 134 1 2   .033114314 -.0012000203
                    10003 135 1 2   -.07048184   .016499996
                    10003 136 1 2    .04729998       -.0478
                    10003 137 1 2   -.10310006   -.03030002
                    10001 204 2 3    .07230437  .0045000315
                    10001 205 2 3   .008260846  -.017499983
                    10001 206 2 3   .005009174   -.07590002
                    10001 207 2 3    .05183494   .007400036
                    10002 171 2 3    .05739057   -.05760002
                    10002 172 2 3     .0956037    .01090002
                    10002 173 2 3    .04015744   .014199972
                    10002 174 2 3   -.05424935  -.012399971
                    10002 175 2 3    .02264738    .04289997
                    10002 176 2 3  -.024722695  -.013199985
                    10002 177 2 3   .030157924   .018599987
                    10002 179 2 3    .15990233    .03429997
                    10002 185 2 3    .08456087  -.003499985
                    10003 131 2 3     .4062909   .015300035
                    10003 139 2 3   -.10440004   .008599997
                    10003 140 2 3   -.09031433    .02190006
                    10003 142 2 3    .07070005   .033499956
                    10009 128 2 3  -.017685711  -.026600003
                    10009 134 2 3    .05622363 -.0012000203
                    10009 135 2 3    -.0563541   .016499996
                    10009 136 2 3   -.14158887       -.0478
                    10009 137 2 3    .05074608   -.03030002
                    10009 138 2 3    .02446902   -.02310002
                    10009 140 2 3   .029646516    .02190006
                    10009 141 2 3  -.015569508   .027199984
                    10001 216 2 4    .07959414  .0042999983
                    10002 191 3 4    -.0203706  -.008700013
                    10003 126 3 4    -.0480783  -.015900016
                    10009 129 3 4     .1682285   -.02340001
                    10009 130 3 4   -.08593327   .011899948
                    10009 131 3 4     .0860889   .015300035
                    10009 132 3 4      .115147         .023
                    10009 133 3 4  -.002500057  .0031000376
                    10009 147 3 4  -.004600048   -.01700002
                    10009 148 3 4    .05742836   -.05019999
                    10009 150 3 4  -.014015377    .05350006
                    10009 152 3 4  -.013801038    .04760003
                    10009 153 3 4   -.08900565    .03180003
                    10009 154 3 4   .072323084    .06149995
                    10009 156 3 4   -.04452991   .034500003
                    10009 158 3 4   -.06512451  -.028100014
                    10009 159 3 4    -.2071027    .07720006
                    10009 160 3 4    1.2303333    .05200005
                    10009 161 4 4 -.0011236668    .04639995
                    10009 162 4 4  .0044602156   -.05449998
                    10020 109 4 4  -.004799962    .03939998
                    10020 110 4 4  -.036145627  -.025900006
                    10020 111 4 4    .16276658   .068099976
                    10020 112 4 4   .008100033   -.02270001
                    10020 113 4 4    -.0182333    .04789996
                    end
                    format %tq quarter

                    Comment


                    • #25
                      OK, this is workable. The results from this example will not look very good, because although all combinations of P1 and double_P2 are represented, not all of them have estimates of alpha, due to the restrictions on the regression and the limited number of firms represented. But in a larger data set it should be fine.

                      FIrst let me point out that the use of -runby- to call a program that just runs -rangestat- is unnecessary. You can dispense with the program, and just include P1 and double_P2 in the -by()- option of -rangestat- and come out with the same results. I suspect that if your data set is large, you will also see a noticeable speedup this way.

                      Code:
                      rangestat (reg) exret_m mktrf_m, interval(quarter -2 0) by(permno P1 double_P2)
                      
                      regress b_cons i.P1##i.double_P2
                      margins P1#double_P2, pwcompare(effects)
                      Once through the -rangestat- you want to contrast the constant terms (new variable b_cons) in the different combinations of quartiles. The simplest way to do that is with a regression on the combinations of P1 and double_P2, followed by -margins- with the -pwcompare- option.

                      Do remember that you will be carrying out 16 comparisons, so the p-values cannot be taken at face value. You should consider a Bonferroni correction when interpreting them.

                      If you only want to compare the highest pair of quartiles with the lowest pair of quartiles, that would be simpler:
                      Code:
                      lincom _b[4.P1] + _b[4.double_p2] + _b[4.P1#4.double_P2]

                      Comment


                      • #26
                        @Clyde Schechter Thank you so much for opening a new door of Stata for me! After reading each of their Stata description files, I've had a general understanding of how to manage factor variables and pairwise comparisons in Stata. May I ask you a question about -margins, pwcompare-? It generates 120 pairwise comparisons of adjusted linear predictions as the following shows. I wonder that why not carry out 16 comparisons instead? Many thanks to you indeed!

                        Code:
                        . margins P1#double_P2, pwcompare(effects)
                        
                        Pairwise comparisons of adjusted predictions
                        Model VCE    : OLS
                        
                        Expression   : Linear prediction, predict()
                        
                            
                        Delta-method    Unadjusted    Unadjusted
                        Contrast   Std. Err.      t    P>t    [95% Conf. Interval]
                            
                        P1#double_P2 
                        (1 2) vs (1 1)     .0066408   .0015452     4.30   0.000    .0036122    .0096694
                        (1 3) vs (1 1)     .0125654   .0015541     8.09   0.000    .0095194    .0156115
                        (1 4) vs (1 1)     .0184079   .0014567    12.64   0.000    .0155528    .0212629
                        (2 1) vs (1 1)     .0009883   .0014757     0.67   0.503    -.001904    .0038806
                        (2 2) vs (1 1)     .0122937   .0016005     7.68   0.000    .0091569    .0154306
                        (2 3) vs (1 1)     .0171407   .0015985    10.72   0.000    .0140077    .0202737
                        (2 4) vs (1 1)     .0168002   .0014566    11.53   0.000    .0139454     .019655
                        (3 1) vs (1 1)     .0066588   .0014796     4.50   0.000    .0037589    .0095587
                        (3 2) vs (1 1)     .0184003   .0016293    11.29   0.000    .0152068    .0215937
                        (3 3) vs (1 1)     .0176743   .0016072    11.00   0.000    .0145243    .0208243
                        (3 4) vs (1 1)     .0238599   .0014497    16.46   0.000    .0210185    .0267014
                        (4 1) vs (1 1)     .0101597   .0014279     7.12   0.000    .007361    .0129583
                        (4 2) vs (1 1)     .0119128   .0015496     7.69   0.000    .0088757      .01495
                        (4 3) vs (1 1)      .014856    .001513     9.82   0.000    .0118905    .0178214
                        (4 4) vs (1 1)     .0177632   .0013913    12.77   0.000    .0150362    .0204901
                        (1 3) vs (1 2)     .0059247   .0016345     3.62   0.000    .0027212    .0091282
                        (1 4) vs (1 2)     .0117671   .0015421     7.63   0.000    .0087446    .0147896
                        (2 1) vs (1 2)    -.0056525   .0015601    -3.62   0.000    -.0087102   -.0025948
                        (2 2) vs (1 2)      .005653   .0016786     3.37   0.001    .0023629     .008943
                        (2 3) vs (1 2)     .0104999   .0016767     6.26   0.000    .0072136    .0137862
                        (2 4) vs (1 2)     .0101595    .001542     6.59   0.000    .0071372    .0131817
                        (3 1) vs (1 2)     .0000181   .0015637     0.01   0.991    -.0030468     .003083
                        (3 2) vs (1 2)     .0117595   .0017062     6.89   0.000    .0084155    .0151035
                        (3 3) vs (1 2)     .0110335    .001685     6.55   0.000    .007731     .014336
                        (3 4) vs (1 2)     .0172192   .0015356    11.21   0.000    .0142095    .0202288
                        (4 1) vs (1 2)     .0035189    .001515     2.32   0.020    .0005496    .0064881
                        (4 2) vs (1 2)     .0052721   .0016302     3.23   0.001    .0020769    .0084672
                        (4 3) vs (1 2)     .0082152   .0015954     5.15   0.000    .0050882    .0113422
                        (4 4) vs (1 2)     .0111224   .0014805     7.51   0.000    .0082206    .0140242
                        (1 4) vs (1 3)     .0058424    .001551     3.77   0.000    .0028025    .0088824
                        (2 1) vs (1 3)    -.0115772   .0015689    -7.38   0.000    -.0146521   -.0085022
                        (2 2) vs (1 3)    -.0002717   .0016868    -0.16   0.872    -.0035778    .0030344
                        (2 3) vs (1 3)     .0045752   .0016849     2.72   0.007    .0012729    .0078776
                        (2 4) vs (1 3)     .0042348   .0015509     2.73   0.006    .0011951    .0072745
                        (3 1) vs (1 3)    -.0059066   .0015725    -3.76   0.000    -.0089887   -.0028245
                        (3 2) vs (1 3)     .0058348   .0017142     3.40   0.001    .002475    .0091946
                        (3 3) vs (1 3)     .0051089   .0016931     3.02   0.003    .0017904    .0084273
                        (3 4) vs (1 3)     .0112945   .0015445     7.31   0.000    .0082673    .0143217
                        (4 1) vs (1 3)    -.0024058    .001524    -1.58   0.114    -.0053928    .0005812
                        (4 2) vs (1 3)    -.0006526   .0016386    -0.40   0.690    -.0038642     .002559
                        (4 3) vs (1 3)     .0022905    .001604     1.43   0.153    -.0008533    .0054344
                        (4 4) vs (1 3)     .0051977   .0014898     3.49   0.000    .0022778    .0081177
                        (2 1) vs (1 4)    -.0174196   .0014724   -11.83   0.000    -.0203055   -.0145337
                        (2 2) vs (1 4)    -.0061141   .0015975    -3.83   0.000    -.0092451   -.0029831
                        (2 3) vs (1 4)    -.0012672   .0015955    -0.79   0.427    -.0043943    .0018599
                        (2 4) vs (1 4)    -.0016076   .0014533    -1.11   0.269    -.004456    .0012407
                        (3 1) vs (1 4)     -.011749   .0014763    -7.96   0.000    -.0146426   -.0088555
                        (3 2) vs (1 4)    -7.61e-06   .0016264    -0.00   0.996    -.0031953    .0031801
                        (3 3) vs (1 4)    -.0007336   .0016042    -0.46   0.647    -.0038777    .0024106
                        (3 4) vs (1 4)     .0054521   .0014464     3.77   0.000    .0026171     .008287
                        (4 1) vs (1 4)    -.0082482   .0014245    -5.79   0.000    -.0110403   -.0054562
                        (4 2) vs (1 4)     -.006495   .0015465    -4.20   0.000    -.0095262   -.0034639
                        (4 3) vs (1 4)    -.0035519   .0015098    -2.35   0.019    -.0065111   -.0005927
                        (4 4) vs (1 4)    -.0006447   .0013879    -0.46   0.642    -.0033649    .0020754
                        (2 2) vs (2 1)     .0113055   .0016148     7.00   0.000    .0081405    .0144705
                        (2 3) vs (2 1)     .0161524   .0016128    10.01   0.000    .0129913    .0193135
                        (2 4) vs (2 1)      .015812   .0014723    10.74   0.000    .0129263    .0186976
                        (3 1) vs (2 1)     .0056706   .0014951     3.79   0.000    .0027403    .0086008
                        (3 2) vs (2 1)      .017412   .0016434    10.59   0.000    .0141909    .0206331
                        (3 3) vs (2 1)      .016686   .0016214    10.29   0.000    .0135081     .019864
                        (3 4) vs (2 1)     .0228717   .0014656    15.61   0.000    .0199992    .0257441
                        (4 1) vs (2 1)     .0091714   .0014439     6.35   0.000    .0063413    .0120015
                        (4 2) vs (2 1)     .0109246   .0015644     6.98   0.000    .0078584    .0139908
                        (4 3) vs (2 1)     .0138677   .0015282     9.07   0.000    .0108726    .0168628
                        (4 4) vs (2 1)     .0167749   .0014078    11.92   0.000    .0140157    .0195341
                        (2 3) vs (2 2)     .0048469   .0017278     2.81   0.005    .0014606    .0082333
                        (2 4) vs (2 2)     .0045065   .0015974     2.82   0.005    .0013757    .0076373
                        (3 1) vs (2 2)    -.0056349   .0016184    -3.48   0.000    -.0088069    -.002463
                        (3 2) vs (2 2)     .0061065   .0017564     3.48   0.001    .0026641    .0095489
                        (3 3) vs (2 2)     .0053806   .0017358     3.10   0.002    .0019785    .0087826
                        (3 4) vs (2 2)     .0115662   .0015911     7.27   0.000    .0084476    .0146848
                        (4 1) vs (2 2)    -.0021341   .0015713    -1.36   0.174    -.0052137    .0009455
                        (4 2) vs (2 2)    -.0003809   .0016826    -0.23   0.821    -.0036788     .002917
                        (4 3) vs (2 2)     .0025622    .001649     1.55   0.120    -.0006697    .0057942
                        (4 4) vs (2 2)     .0054694   .0015381     3.56   0.000    .0024548     .008484
                        (2 4) vs (2 3)    -.0003404   .0015954    -0.21   0.831    -.0034673    .0027864
                        (3 1) vs (2 3)    -.0104818   .0016164    -6.48   0.000    -.0136499   -.0073138
                        (3 2) vs (2 3)     .0012596   .0017545     0.72   0.473    -.0021793    .0046984
                        (3 3) vs (2 3)     .0005336   .0017339     0.31   0.758    -.0028649    .0039321
                        (3 4) vs (2 3)     .0067193   .0015891     4.23   0.000    .0036046    .0098339
                        (4 1) vs (2 3)     -.006981   .0015692    -4.45   0.000    -.0100567   -.0039054
                        (4 2) vs (2 3)    -.0052278   .0016807    -3.11   0.002    -.0085221   -.0019336
                        (4 3) vs (2 3)    -.0022847   .0016471    -1.39   0.165    -.0055129    .0009435
                        (4 4) vs (2 3)     .0006225    .001536     0.41   0.685    -.0023881     .003633
                        (3 1) vs (2 4)    -.0101414   .0014762    -6.87   0.000    -.0130347   -.0072481
                        (3 2) vs (2 4)        .0016   .0016263     0.98   0.325    -.0015874    .0047875
                        (3 3) vs (2 4)     .0008741    .001604     0.54   0.586    -.0022698     .004018
                        (3 4) vs (2 4)     .0070597   .0014463     4.88   0.000    .004225    .0098944
                        (4 1) vs (2 4)    -.0066406   .0014244    -4.66   0.000    -.0094323   -.0038488
                        (4 2) vs (2 4)    -.0048874   .0015464    -3.16   0.002    -.0079183   -.0018565
                        (4 3) vs (2 4)    -.0019443   .0015097    -1.29   0.198    -.0049032    .0010147
                        (4 4) vs (2 4)     .0009629   .0013877     0.69   0.488    -.001757    .0036828
                        (3 2) vs (3 1)     .0117414   .0016469     7.13   0.000    .0085135    .0149693
                        (3 3) vs (3 1)     .0110155    .001625     6.78   0.000    .0078306    .0142003
                        (3 4) vs (3 1)     .0172011   .0014695    11.71   0.000    .014321    .0200812
                        (4 1) vs (3 1)     .0035008   .0014479     2.42   0.016    .000663    .0063387
                        (4 2) vs (3 1)      .005254   .0015681     3.35   0.001    .0021806    .0083274
                        (4 3) vs (3 1)     .0081971   .0015319     5.35   0.000    .0051946    .0111996
                        (4 4) vs (3 1)     .0111043   .0014118     7.87   0.000    .0083372    .0138715
                        (3 3) vs (3 2)     -.000726   .0017624    -0.41   0.680    -.0041803    .0027284
                        (3 4) vs (3 2)     .0054597   .0016202     3.37   0.001    .0022842    .0086352
                        (4 1) vs (3 2)    -.0082406   .0016007    -5.15   0.000    -.0113778   -.0051034
                        (4 2) vs (3 2)    -.0064874   .0017101    -3.79   0.000    -.0098392   -.0031356
                        (4 3) vs (3 2)    -.0035443    .001677    -2.11   0.035    -.0068312   -.0002574
                        (4 4) vs (3 2)    -.0006371   .0015681    -0.41   0.685    -.0037106    .0024364
                        (3 4) vs (3 3)     .0061856   .0015979     3.87   0.000    .0030539    .0093174
                        (4 1) vs (3 3)    -.0075146   .0015781    -4.76   0.000    -.0106076   -.0044217
                        (4 2) vs (3 3)    -.0057615    .001689    -3.41   0.001    -.0090718   -.0024511
                        (4 3) vs (3 3)    -.0028183   .0016555    -1.70   0.089    -.006063    .0004263
                        (4 4) vs (3 3)     .0000889    .001545     0.06   0.954    -.0029394    .0031171
                        (4 1) vs (3 4)    -.0137003   .0014174    -9.67   0.000    -.0164784   -.0109222
                        (4 2) vs (3 4)    -.0119471     .00154    -7.76   0.000    -.0149654   -.0089288
                        (4 3) vs (3 4)     -.009004   .0015031    -5.99   0.000    -.01195   -.0060579
                        (4 4) vs (3 4)    -.0060968   .0013806    -4.42   0.000    -.0088026   -.0033909
                        (4 2) vs (4 1)     .0017532   .0015194     1.15   0.249    -.0012248    .0047312
                        (4 3) vs (4 1)     .0046963   .0014821     3.17   0.002    .0017915    .0076011
                        (4 4) vs (4 1)     .0076035   .0013576     5.60   0.000    .0049427    .0102644
                        (4 3) vs (4 2)     .0029431   .0015997     1.84   0.066    -.0001922    .0060784
                        (4 4) vs (4 2)     .0058503   .0014851     3.94   0.000    .0029396    .0087611
                        (4 4) vs (4 3)     .0029072   .0014468     2.01   0.045    .0000714     .005743

                        Comment


                        • #27
                          Your 4x4 table has 16 cells. If you compare each of the 16 cells with all of the others, you will have 256 comparisons. Actually, we don't compare any cell with itself, and we don't compare both A vs B and B vs A so it's actually 16*15/2 = 120 comparisons.

                          You say you only want 16 comparisons. Well, which 16 specific comparisons do you want?

                          Comment


                          • #28
                            Clyde Schechter Thank you for your explanations! Now I understand why there are 120 comparisons instead of 16 comparisons in total.

                            I would only need the comparisons between the highest quartile and the lowest quartile and then get the t-statistics for their differences respectively, such as the bold font in the following:
                            double_P2
                            P1 1(L) 2 3 4(H) H-L
                            1(L) -0.00246 -0.0041 -0.00086 0.004634 0.00709
                            2 -0.00047 0.004816 0.008216 0.006208 0.006674
                            3 0.005488 0.005446 0.008915 0.005792 0.000304
                            4(H) 0.002287 0.002242 0.0032 0.001667 -0.00062
                            H-L 0.004744 0.006345 0.004058 -0.00297



                            May I ask that, is this following line of codes able to satisfy my aim? Many thanks for your help!
                            lincom _b[4.P1] + _b[4.double_p2] + _b[4.P1#4.double_P2]
                            Last edited by Jae Li; 09 Dec 2017, 10:36.

                            Comment


                            • #29
                              To calculate the differences you highlight in boldface, the code would be:

                              Code:
                              forvalues i = 1/4 {
                                  lincom _b[4.P1#`i'.double_P2] - _b[1.P1#`i'.double_P2] + _b[4.P1] - _b]1.P1]
                              }
                              forvalues i = 1/4 {
                                  lincom _b[`i'.P1#4.double_P2] - _b[`i'.P1#1.double_P2] + _b[4.double_P2] - _b[1.double_P2]
                              }
                              Again, bear in mind you are still testing multiple hypotheses so that nominal p-values can be misleading.

                              Comment


                              • #30
                                Clyde Schechter Thank you for your quick response! My old method is to generate a group variable by keeping the observations only with the highest quartile or the lowest quartile, such as 1 or 2. Then, use -ttest- on the excess returns by the group variables with an -unequal- option. Finally, save the scalar of t-statistics. Just like the following codes:

                                gen H_L= .
                                replace H_L = 1 if P1==1 & double_P2 == 1
                                replace H_L = 2 if P1==1 & double_P2 == 4
                                qui ttest alpha, by(H_L) unequal
                                scalar t_D1 = r(t)
                                scalar p_D1 = r(p)

                                May I ask that where is wrong with this logic? Thank you very much indeed!

                                Moreover, you mentioned early that

                                p-values cannot be taken at face value. You should consider a Bonferroni correction when interpreting them.
                                If adds the option of Bonferroni correction at below, does it counteract the problem of multiple comparisons? For instance, to obtain the Bonferroni adjusted p-value, multiply the uncorrected p-value by the total number of comparisons, if so, do the nominal p-values be corrected?

                                Code:
                                margins P1#double_P2, pwcompare(effects) mcompare(bonferroni)
                                Thank you very much for your help!
                                Last edited by Jae Li; 09 Dec 2017, 12:17.

                                Comment

                                Working...
                                X