I want to use the daily_residuals of the past 250 days to estimate the residual risk series, for each stock i in each month t,. After that according to the block minima method, I wnat to choose the minimum daily_residuals in every block of 20 days and denote them as X1,X2,…, Xn. I need such minimum values of an extreme sample. The following is the mock data sample. Please help me out how to consider past 250 days in each month for each firm to estimate the required series?
firm_id firm_month firm_year daily_residuals annual_trading_days period_formulation
2 1 3 -0.03361299 1 -249
2 1 3 0.23190793 2 -248
2 1 3 0.10199309 3 -247
2 1 3 -0.03039758 4 -246
2 1 3 -0.11719607 5 -245
2 1 3 -0.52591654 6 -244
2 2 3 0.16762214 7 -243
2 2 3 -0.38226898 8 -242
2 2 3 -0.07019789 9 -241
2 2 3 0.14705946 10 -240
2 2 3 -0.22529072 11 -239
2 2 3 -0.54650438 12 -238
2 2 3 -0.09094486 13 -237
2 2 3 -0.42596939 14 -236
2 2 3 0.19068412 15 -235
2 3 3 -0.10331164 16 -234
2 3 3 -0.36183579 17 -233
2 3 3 -0.2391495 18 -232
2 3 3 0.27293555 19 -231
2 3 3 -0.14572653 20 -230
2 3 3 -0.61432637 21 -229
2 3 3 -0.45197722 22 -228
2 3 3 -0.68543693 23 -227
2 3 3 -0.2987921 24 -226
2 3 3 -0.2222488 25 -225
2 3 3 -0.07104014 26 -224
2 3 3 -0.19574774 27 -223
2 3 3 -0.38104489 28 -222
2 4 3 -0.61960495 29 -221
2 4 3 0.16590241 30 -220
2 4 3 0.09019389 31 -219
2 4 3 0.27916815 32 -218
2 4 3 -0.45602749 33 -217
2 4 3 -0.14768243 34 -216
2 4 3 -0.09397658 35 -215
2 4 3 -0.54322865 36 -214
2 4 3 0.0023621 37 -213
2 4 3 -0.60071332 38 -212
2 5 3 -0.59242233 39 -211
2 5 3 -0.07078535 40 -210
2 5 3 -0.08996187 41 -209
2 5 3 0.22251079 42 -208
2 5 3 -2.7960517 43 -207
2 5 3 -0.05230188 44 -206
2 5 3 0.11086455 45 -205
2 5 3 -0.35335545 46 -204
2 6 3 0.08147279 47 -203
2 6 3 -0.03937032 48 -202
2 6 3 0.19951828 49 -201
2 6 3 0.16202642 50 -200
2 6 3 0.30301793 51 -199
2 7 3 -0.44077731 52 -198
2 7 3 0.16665149 53 -197
2 8 3 -0.36405543 54 -196
2 8 3 -0.46644073 55 -195
2 8 3 -0.55256689 56 -194
2 8 3 -0.61295267 57 -193
2 8 3 -0.54832912 58 -192
2 8 3 -0.40284584 59 -191
2 8 3 -0.14094117 60 -190
2 8 3 -0.06005564 61 -189
2 9 3 0.00146918 62 -188
2 9 3 -0.1935473 63 -187
2 9 3 -0.4664292 64 -186
2 9 3 -0.6547289 65 -185
2 9 3 -0.29404684 66 -184
2 9 3 0.17899844 67 -183
2 9 3 -0.44243067 68 -182
2 10 3 -0.61380011 69 -181
2 10 3 -0.50240394 70 -180
2 10 3 -0.49103979 71 -179
2 10 3 -0.66269378 72 -178
2 10 3 -0.60214488 73 -177
2 11 3 0.38024272 74 -176
2 11 3 -0.71502593 75 -175
2 11 3 0.17827406 76 -174
2 11 3 -0.42543686 77 -173
2 11 3 -0.32066038 78 -172
2 11 3 0.03700179 79 -171
2 11 3 -0.552001 80 -170
2 11 3 -0.03600875 81 -169
2 11 3 -0.05111171 82 -168
2 12 3 0.01975027 83 -167
2 12 3 -0.30591698 84 -166
2 13 4 -0.37406726 1 -249
2 13 4 -0.00948011 2 -248
2 13 4 0.28779486 3 -247
2 13 4 -0.15254011 4 -246
2 13 4 0.14455105 5 -245
2 13 4 -0.23084262 6 -244
2 13 4 0.48867686 7 -243
2 13 4 0.12600603 8 -242
2 13 4 0.43584181 9 -241
2 13 4 0.513529 10 -240
2 14 4 -0.15300232 11 -239
2 14 4 0.10002349 12 -238
2 14 4 -0.24784204 13 -237
2 14 4 -0.26292285 14 -236
2 14 4 0.32976763 15 -235
2 14 4 0.00389674 16 -234
2 14 4 -0.13263722 17 -233
2 14 4 0.18031637 18 -232
2 14 4 -0.17422845 19 -231
2 14 4 0.2640803 20 -230
2 15 4 -0.26822687 21 -229
2 15 4 0.11775817 22 -228
2 15 4 0.55223828 23 -227
2 15 4 0.06609797 24 -226
2 15 4 -0.14640377 25 -225
2 15 4 0.41238942 26 -224
2 15 4 0.46020082 27 -223
2 15 4 0.2102086 28 -222
2 15 4 -0.03611199 29 -221
2 15 4 0.25771612 30 -220
2 15 4 0.0821591 31 -219
2 16 4 0.09236162 32 -218
2 16 4 0.23789663 33 -217
2 16 4 0.63570685 34 -216
2 16 4 0.32056841 35 -215
2 17 4 -0.19120545 36 -214
2 17 4 0.48038906 37 -213
2 17 4 0.37687497 38 -212
2 17 4 0.64863562 39 -211
2 17 4 0.0533439 40 -210
2 17 4 0.62131349 41 -209
2 17 4 0.04417646 42 -208
2 17 4 0.35621847 43 -207
2 17 4 0.5901399 44 -206
2 17 4 0.78183078 45 -205
2 17 4 0.30244265 46 -204
2 17 4 -0.094565 47 -203
2 17 4 0.17703175 48 -202
2 17 4 0.55036808 49 -201
2 17 4 0.86730545 50 -200
2 17 4 0.19191488 51 -199
2 18 4 0.95058082 52 -198
2 18 4 0.90695198 53 -197
2 18 4 0.88396505 54 -196
2 18 4 0.51992421 55 -195
2 18 4 0.71624037 56 -194
2 18 4 0.78792218 57 -193
2 18 4 0.35978709 58 -192
2 18 4 0.37195476 59 -191
2 19 4 0.38125184 60 -190
2 19 4 0.18701172 61 -189
2 19 4 0.22441691 62 -188
2 19 4 0.28249061 63 -187
2 19 4 0.65779633 64 -186
2 19 4 0.41226577 65 -185
2 19 4 0.5201815 66 -184
2 19 4 0.98470259 67 -183
2 19 4 0.93226508 68 -182
2 19 4 0.49669688 69 -181
2 19 4 -0.02992089 70 -180
2 20 4 0.72312039 71 -179
2 20 4 0.66389136 72 -178
2 20 4 0.24635218 73 -177
2 20 4 0.58730777 74 -176
2 20 4 0.41923696 75 -175
2 20 4 0.06548436 76 -174
2 20 4 1.1367129 77 -173
2 20 4 0.45601752 78 -172
2 20 4 0.70934556 79 -171
2 20 4 0.596446 80 -170
2 21 4 0.5301975 81 -169
2 21 4 0.51621991 82 -168
2 21 4 0.16136374 83 -167
2 21 4 0.40673925 84 -166
2 21 4 1.0221992 85 -165
2 21 4 0.07510953 86 -164
2 22 4 1.0327384 87 -163
2 22 4 0.3061462 88 -162
2 22 4 0.602342 89 -161
2 22 4 0.8247953 90 -160
2 22 4 0.58222301 91 -159
2 22 4 0.79238363 92 -158
2 22 4 0.47383564 93 -157
2 22 4 0.46025872 94 -156
2 23 4 0.66889914 95 -155
2 23 4 0.56730489 96 -154
2 23 4 0.90689359 97 -153
2 23 4 -1.8694781 98 -152
2 23 4 0.50126135 99 -151
2 23 4 0.71743952 100 -150
2 24 4 0.65666771 101 -149
2 24 4 0.11327769 102 -148
2 24 4 0.3435621 103 -147
2 24 4 0.67771349 104 -146