0
$\begingroup$

I'm not well-versed in statistics so apologies in advance for struggling to ask this question the right way.

Essentially, I have 1836 timeseries of stock prices. For each of these timeseries, I am analyzing eleven separate technical indicators (i.e. applying some sort of filter/transformation to the timeseries, returning either True or False) on each date. If the signal is True, then I throw that day's return into a bucket.

The resulting dataset is a 3-dimensional matrix with an x-axis of 1,836 securities, a y-axis of 24,541 dates, and a z-axis of 11 technical indicators.

Across each technical indicator, and for each security, I want to test homogeneity of variance between the unconditional distribution of returns (any given day), and the distribution of returns contingent upon the technical indicator signaling True for that day.

The complexity of this problem is sort of throwing me off since I don't have any experience with statistics beyond an introductory level. If I test each individual security, I will have 1,836 p-values. This seems like a weird output. I could flip it around and test each 11 technical indicators, but then I still have 2 * 1,836 = 3,672 distributions to worry about.

So far I've looked at F-tests and the related Levene's, Bartlett's, and Brown-Forscythe tests, but I'm not sure how I'd implement them across this dataset. Would greatly appreciate any advice!

Edit: Here's a slice of the DataFrame for one technical indicator 'MA_a':

container['MA_a']

Out[13]: 
10006    {'all': [-0.002045, -0.004098, 0.004115, -0.01...
10030    {'all': [0.002907, 0.0, 0.0, 0.02029, 0.005682...
10049    {'all': ['C', '-0.010135', '0.013652', '-0.016...
10057    {'all': [0.014184, 0.020979, 0.006848999999999...
10078    {'all': [-0.009569, 0.0, -0.009662, 0.029268, ...
10102    {'all': [0.0073170000000000015, 0.016949000000...
10104    {'all': [0.065041, 0.045801999999999995, 0.021...
10107    {'all': [-0.016055, -0.030303, 0.004808, 0.005...
10108    {'all': [-0.012077, -0.043521, 0.0623720000000...
10137    {'all': ['C', '-0.010453', '0.035211', '-0.008...
10138    {'all': [-0.064706, 0.018868, -0.037037, -0.04...
10145    {'all': ['C', '0.000000', '-0.006579', '-0.005...
10147    {'all': [0.005814, 0.00578, 0.011494, -0.01136...
10153    {'all': ['C', '0.002688', '-0.013405', '-0.010...
10161    {'all': [0.0, 0.056995, 0.02451, 0.014354, -0....
10196    {'all': [0.0, 0.035714, -0.034483, 0.0, 0.1428...
10209    {'all': [0.01626, 0.004, 0.007968000000000001,...
10225    {'all': ['C', '0.003293', '0.000000', '-0.0010...
10233    {'all': ['C', '0.004630', '-0.004608', '-0.011...
10241    {'all': ['C', '0.009402', '-0.010161', '-0.010...
10276    {'all': [0.010638, 0.0035090000000000004, -0.0...
10292    {'all': [0.004425, 0.004405, 0.006579000000000...
10299    {'all': [-0.095455, -0.021357, 0.026958, -0.01...
10321    {'all': [0.0, 0.045455, -0.043478, 0.068182, 0...
10324    {'all': [0.013848, 0.005464, 0.016811000000000...
10353    {'all': [0.030709, 0.011459, -0.009063, 0.0, -...
10364    {'all': ['C', '-0.013841', '-0.014912', '-0.01...
10372    {'all': ['C', '0.003272', '0.000000', '0.00000...
10401    {'all': [0.004933, 0.009116, -0.003475, 0.0013...
10436    {'all': [0.007298999999999998, 0.0072459999999...

91650    {'all': ['C', '0.015024', '-0.006540', '-0.037...
91668    {'all': [0.0054670000000000005, 0.004284000000...
91849    {'all': [0.018185, -0.002576, 0.00645699999999...
91883    {'all': [-0.040653, -0.017822, -0.009274, 0.03...
91926    {'all': [-0.00928, -0.011151, 0.013532, 0.0302...
91937    {'all': [-0.06662, -0.051089, -0.035629, -0.03...
92121    {'all': ['C', '-0.030182', '-0.027747', '-0.01...
92156    {'all': ['C', '-0.008984', '-0.019061', '0.002...
92157    {'all': ['C', '-0.007756', '-0.005295', '0.009...
92239    {'all': [0.029039, -0.043172, 0.007373, -0.030...
92293    {'all': ['C', '-0.015368', '-0.036298', '0.016...
92322    {'all': [0.013966999999999999, -0.013871000000...
92402    {'all': [0.006794, -0.001295, -0.016791, 0.017...
92602    {'all': ['C', '0.000000', '0.012455', '-0.0031...
92611    {'all': [-0.01641, -0.013827, -0.001738, 0.001...
92614    {'all': [-0.000442, -0.007809, 0.015296, 0.004...
92618    {'all': [-0.038554000000000005, -0.006266, -0....
92655    {'all': [0.01385, 0.0, -0.027322000000000003, ...
92709    {'all': ['C', '0.050314', '-0.009820', '-0.027...
92772                    {'all': [0.035791], 'signal': []}
92778    {'all': [-0.020438, 0.029663, 0.000244, -0.005...
92890    {'all': [0.018072, 0.019882, 0.004177, -0.0036...
92988    {'all': ['C', '-0.062814', '0.002145', '-0.010...
93002    {'all': [0.017063, -0.007947, 0.025515, -0.005...
93089    {'all': [0.005807, -0.003439, 0.004068, -0.010...
93096    {'all': [-0.0248, -0.016817, -0.02795199999999...
93132    {'all': [-0.030789999999999998, 0.036696, 0.00...
93159    {'all': [-0.037385, 0.009203, -0.002736, 0.017...
93422    {'all': ['C', '-0.009894', '-0.028946', '0.048...
93429    {'all': [0.019218, -0.013241, 0.000256, -0.003...
Name: MA_a, Length: 1830, dtype: object

Zooming in further, here's a slice of the technical indicator 'MA_a' for one security '10006':

{'all': DATE
 1957-03-01   -0.002045
 1957-03-04   -0.004098
 1957-03-05    0.004115
 1957-03-06   -0.012295
 1957-03-07   -0.008299
 1957-03-08   -0.006276
 1957-03-11   -0.006316
 1957-03-12    0.006356
 1957-03-13    0.012632
 1957-03-14   -0.002079
 1957-03-15    0.000000
 1957-03-18   -0.006250
 1957-03-19    0.023061
 1957-03-20    0.016393
 1957-03-21    0.008065
 1957-03-22   -0.020000
 1957-03-25   -0.004082
 1957-03-26    0.004098
 1957-03-27    0.000000
 1957-03-28    0.004082
 1957-03-29    0.012195
 1957-04-01    0.006024
 1957-04-02    0.001996
 1957-04-03   -0.003984
 1957-04-04    0.008000
 1957-04-05   -0.003968
 1957-04-08   -0.009960
 1957-04-09    0.002012
 1957-04-10   -0.008032
 1957-04-11    0.004049

 1984-05-17   -0.002375
 1984-05-18   -0.002381
 1984-05-21    0.002387
 1984-05-22   -0.002381
 1984-05-23    0.002387
 1984-05-24   -0.002381
 1984-05-25    0.002387
 1984-05-29   -0.002381
 1984-05-30    0.000000
 1984-05-31    0.004773
 1984-06-01    0.007126
 1984-06-04   -0.002358
 1984-06-05    0.004728
 1984-06-06   -0.002353
 1984-06-07    0.000000
 1984-06-08    0.000000
 1984-06-11    0.009434
 1984-06-12   -0.004673
 1984-06-13    0.002347
 1984-06-14    0.000000
 1984-06-15    0.000000
 1984-06-18   -0.002342
 1984-06-19    0.002347
 1984-06-20    0.002342
 1984-06-21   -0.002336
 1984-06-22   -0.011710
 1984-06-25    0.009479
 1984-06-26    0.000000
 1984-06-27    0.011737
 1984-06-28    0.000000
 Name: 10006, Length: 6864, dtype: float64, 'signal': 9024     0.014463
 9025     0.002037
 9026    -0.002033
 9027    -0.002037
 9037     0.006135
 9046     0.012397
 9078    -0.013972
 9079     0.004049
 9080     0.000000
 9081    -0.012097
 9082    -0.004082
 9086     0.008333
 9087     0.001033
 9088     0.001032
 9190    -0.005970
 9191    -0.006006
 9194     0.015528
 9195    -0.009174
 9200    -0.012121
 9239    -0.002899
 9240     0.000000
 9241    -0.005814
 9242     0.005848
 9243     0.000000
 9244     0.000000
 9245     0.000000
 9246     0.000000
 9247     0.002907
 9248     0.000000
 9249     0.002899

 15608   -0.048951
 15609    0.000000
 15610    0.000000
 15611   -0.003676
 15612    0.000000
 15613    0.011070
 15614    0.000000
 15615   -0.007299
 15616   -0.007353
 15620    0.026119
 15621   -0.010909
 15624    0.007407
 15625   -0.003676
 15626    0.014760
 15627   -0.003636
 15702    0.000000
 15703    0.002488
 15704    0.000000
 15705    0.000000
 15706   -0.002481
 15707   -0.002488
 15708    0.000000
 15709    0.004988
 15710   -0.004963
 15711   -0.002494
 15712    0.000000
 15714    0.007595
 15717    0.015228
 15838   -0.011710
 15840    0.000000
 Length: 785, dtype: float64}

As you can see, there are two subsamples, 'all' and 'signal'.

$\endgroup$
  • $\begingroup$ Why do you want to do this? What is your goal, your real problem? Looks like the en.wikipedia.org/wiki/XY_problem $\endgroup$ – kjetil b halvorsen Mar 2 '19 at 8:17
  • $\begingroup$ For an academic thesis, I am testing the null hypothesis that securities’ returns are not affected by my filter rules. (I.e. that the distributions are the same.) I am not concerned with median/mean return since those should theoretically be the same, but rather volatility (variance/stdev) which I believe drops substantially on days where my signals flash True. $\endgroup$ – Ryan Mar 2 '19 at 17:05
  • $\begingroup$ Van YouTube please add extra informatikk AS editor to YouTube Q? $\endgroup$ – kjetil b halvorsen Mar 2 '19 at 17:25
  • $\begingroup$ Could you please ask your question another way? I’m having a hard time understanding what you’re asking but I’d be glad to upload whatever you need to YouTube. $\endgroup$ – Ryan Mar 2 '19 at 21:44
  • $\begingroup$ Hmm... I'm quite surprised tosee that comment underwriten by me. Not sure how that come to be. Starting some RussianCollusion investigations right now .. . (and then deleting) $\endgroup$ – kjetil b halvorsen Mar 2 '19 at 21:57
0
$\begingroup$

It depends on what you want to do with the results.

Even if none of the 1,836 raw time series really had different variances from their filtered counterparts, you would find about 5% of your p-values being significant using a standard significance level of 0.05.

I assume you are trying to make money by investing based on your results. In that case, one approach would be to determine how much money you will lose by concluding that the variances are not the same when, in fact, they are. Based on this you can set whatever significance level you want based on how often you can afford to be wrong, that is based on how large of losses you can absorb.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for the answer! Actually this research is for an academic thesis — I am completely indifferent as to whether or not the results generate an actionable trading opportunity. I’ll take what you said at face value because the math behind it eludes me, so with that in mind, can you think of another way I can group the data that would allow me to make a statistical conclusion? $\endgroup$ – Ryan Mar 2 '19 at 17:03
  • $\begingroup$ Benjamini Y, Hochberg Y. Controlling the false discovery rate: A practical and powerful approach to multiple testing. J R Stat Soc 1995, 57, 289-300. $\endgroup$ – Jdub Mar 4 '19 at 4:19
  • $\begingroup$ There are maybe two things you might be interested in. One is saying that overall, across all the time series, you don't have equal variances. This would be related to controlling what is called the family-wise error rate. The other is that you want to say which particular time series don't have equal variances. This would be related to controlling what is called the false discovery rate, and this is a common procedure in genomics. Here is a website to give you a broad overview: biostathandbook.com/multiplecomparisons.html $\endgroup$ – Jdub Mar 4 '19 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.