# Correct approach to testing for homogeneity of variance across ~2000 conditional distributions?

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'.

• Why do you want to do this? What is your goal, your real problem? Looks like the en.wikipedia.org/wiki/XY_problem – kjetil b halvorsen Mar 2 '19 at 8:17
• 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. – Ryan Mar 2 '19 at 17:05