Announcement

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

  • non parametric test with two variables?

    Dear all,
    I have a dataset containing 157 firms identified by a companyid variable, besides i have the stockprices of each individual company for a timeperiod of 156 weeks. I calculated the BHAR and now want to check whether the individual company bhar (bharpe1115) its mean is significantly different from the bhar of the benchmarks( bharsp600,). By performing t-tests i exactly know how to test if they differ by performing the following code : by week: ttest bharpe1115== bharsp600 . With the results as attachment; one can see that for every week whether the bhars differ.
    However literature in this topic requires a non parametric test. Literature uses the wilcoxon mann whitney test. I however, dont know if it is possible to execute this on two different variables (so not by group!), maybe there is some user written program i should know about?
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int date double PricePE int(companyid week) double(SP600 SP500VALUE SP500EQUALWEIGHTED) float(bharpe1115 bharsp600 bharsp500value bharsp500equal)
    19899              25.75 1  0            677.15            895.69            3106.84         1         1         1         1
    19906              25.21 1  1 686.9300000000001            898.64            3128.73  .9790291 1.0144429 1.0032935 1.0070457
    19913              25.75 1  2            676.23            898.91            3122.59         1  .9986414  1.003595 1.0050695
    19920 26.560000000000002 1  3            663.36             904.5            3122.26 1.0314564  .9796352  1.009836 1.0049633
    19927              24.04 1  4               666            904.51            3123.71  .9335923  .9835339 1.0098472   1.00543
    19934              24.25 1  5            659.83            896.73            3099.79  .9417475  .9744222 1.0011611  .9977308
    19941              25.29 1  6            649.48            873.84            3028.11   .982136  .9591376  .9756054  .9746591
    19948              25.92 1  7 657.1800000000001            884.59             3069.9 1.0066019  .9705088  .9876073  .9881101
    19955              27.87 1  8             665.6 898.9200000000001 3137.7200000000003 1.0823301  .9829432 1.0036062 1.0099393
    19962              28.19 1  9            671.84            906.45            3154.41 1.0947573  .9921583 1.0120131 1.0153114
    19969              27.98 1 10            672.48            908.34            3162.56  1.086602  .9931034 1.0141232 1.0179347
    19976 26.080000000000002 1 11            667.03            902.52            3145.23 1.0128155   .985055 1.0076255 1.0123566
    19983 27.080000000000002 1 12            661.91            907.95 3144.9900000000002 1.0516505  .9774939 1.0136877 1.0122794
    19990              25.66 1 13 648.9300000000001            903.87 3121.7000000000003  .9965048  .9583253 1.0091326  1.004783
    19997              25.01 1 14            626.61            880.46            3037.87  .9712622  .9253637  .9829963  .9778006
    20004 26.150000000000002 1 15            632.33            889.84            3066.86 1.0155339  .9338108  .9934687  .9871316
    20011               25.2 1 16            620.98            843.94            2912.69  .9786408  .9170494  .9422233  .9375089
    20018              26.72 1 17            634.63            870.51             3022.8 1.0376699  .9372074  .9718876    .97295
    20025 32.230000000000004 1 18            663.58            891.62            3109.05 1.2516505  .9799601   .995456 1.0007113
    20032              34.45 1 19            677.22            910.44            3178.16  1.337864 1.0001034 1.0164678 1.0229558
    20039              33.46 1 20 686.0600000000001 915.4200000000001            3203.15 1.2994175 1.0131581 1.0220277 1.0309993
    20046              30.72 1 21            669.21            921.37 3215.9300000000003 1.1930097  .9882744 1.0286707 1.0351129
    20053              31.16 1 22            686.48            929.37            3256.16  1.210097 1.0137783 1.0376023 1.0480617
    20060              32.01 1 23            681.41            931.83             3258.6  1.243107  1.006291 1.0403488 1.0488471
    20067              33.71 1 24            670.48            908.39            3180.77 1.3091263  .9901499  1.014179 1.0237958
    20074              37.44 1 25 675.5600000000001 904.1700000000001            3176.04 1.4539806  .9976519 1.0094676 1.0222734
    20081              36.79 1 26            695.08            938.13            3284.27  1.428738 1.0264786 1.0473825 1.0571095
    20088               37.4 1 27            695.08            927.97            3251.04  1.452427 1.0264786 1.0360392 1.0464137
    20095              36.69 1 28            675.27            908.41 3188.2000000000003 1.4248544  .9972237 1.0142013 1.0261874
    20102              36.71 1 29             677.5            896.94            3161.06  1.425631 1.0005169 1.0013956 1.0174518
    end
    format %tdnn/dd/CCYY date
    Attached Files

  • #2
    Is:
    Code:
    . signrank bharpe1115 = bharsp600
    
    Wilcoxon signed-rank test
    
            sign |      obs   sum ranks    expected
    -------------+---------------------------------
        positive |       26         443         232
        negative |        3          21         232
            zero |        1           1           1
    -------------+---------------------------------
             all |       30         465         465
    
    unadjusted variance     2363.75
    adjustment for ties        0.00
    adjustment for zeros      -0.25
                         ----------
    adjusted variance       2363.50
    
    Ho: bharpe1115 = bharsp600
                 z =   4.340
        Prob > |z| =   0.0000
    what you want?

    Comment


    • #3
      First of all, thanks for your reply.
      I think this is partly the answer, although i found the following in the literature (see attachment). Im not sure if im comparing the medians of the two groups with your code. I know this is more a statistical issue than a stata issue, but it would be nice if you could give me some explanation?
      greetings
      Attached Files

      Comment


      • #4
        From Stata help:

        'signrank tests the equality of matched pairs of observations by using the Wilcoxon matched-pairs signed-ranks test (Wilcoxon 1945). The null hypothesis is that both distributions are the same.

        signtest also tests the equality of matched pairs of observations (Arbuthnott [1710], but better explained by Snedecor and Cochran [1989]) by calculating the differences between varname and the expression. The null hypothesis is that the median of the differences is zero; no further assumptions are made about the distributions. This, in turn, is equivalent to the hypothesis that the true proportion of positive (negative) signs is one-half.'



        I am not familiar with your type of data but the choice of test would depend on the data and whether or not it conforms to the requirements of the test rather than 'we always use this test'. If the assumptions of the paired - test are not violated, and it is reported to be a robust test, then I see no problem in using it.

        Comment


        • #5
          Dear Martyn,
          Thanks a lot, I think I could argue why I could use this test with that!

          Comment

          Working...
          X