new; cls; /* Block Sampling (Type II) fixing holiday locations ( real data from TOPIX ) */ /* */ /* Notice: Now we keep the data at the beginnig and at the end unchanged. */ /* We may face the same pattern as the original in some portions. It means that this */ /* version is less flexible. */ let data[982,2]= 0 -1.570125714 0 0.989999021 0 1.022373122 0 -1.056380945 2 -0.100201356 0 -0.133442505 0 0.108849472 0 1.209218221 3 0.545270327 0 -0.092067765 0 1.41073166 0 1.35310198 0 -0.692943046 2 0.129326065 0 1.011513702 0 0.493428706 0 -0.462799455 0 1.345592618 2 -0.524809302 0 -0.505128475 0 -1.499883379 0 -0.583203964 0 -0.563573416 2 0.550737622 0 -0.642053827 0 -0.169016466 1 0.71016026 2 0.502621735 0 0.606365949 0 -0.418418264 0 -0.165119658 0 -0.070327024 2 1.30799129 0 0.795807818 0 0.22519513 0 0.342182278 0 -0.365393248 2 -1.097037719 0 -1.430095876 0 0.70533029 0 0.480743991 0 3.696081574 2 0.089781088 0 1.277795645 0 2.124353286 0 0.730815243 0 -0.047663048 2 1.293857562 0 2.423377308 0 1.535428289 0 -2.316135534 0 3.080611459 3 -0.477606721 0 -2.412322158 0 1.794771657 0 0.939100538 2 0.070176825 0 0.044918851 0 -0.159277136 0 2.587714396 0 0.286415436 2 0.229767194 0 1.174256205 0 0.153366731 0 1.53053319 0 -0.160715516 2 -2.009010411 0 1.173756083 0 0.868013629 0 -0.404285071 0 0.380461189 2 -0.772879933 0 -0.284792366 0 -1.29817854 0 0.204097245 0 1.58725704 2 0.624789758 0 0.488446778 0 -0.206074067 1 -0.783686724 5 3.237671694 0 -0.923797458 2 0.39675067 0 -1.321785898 0 0.392349333 0 -0.676714265 0 -0.334887066 2 -1.874296407 0 0.7953586 0 -2.459115411 0 0.096830723 0 0.597350467 2 0.596839446 0 -0.672459592 0 -0.410414052 0 -0.088275148 0 -0.778652016 2 0.395480305 0 1.552043454 0 0.702659599 0 -0.686721348 0 -0.088071617 2 0.916390175 0 0.786422774 0 0.251337928 0 1.852369467 0 0.951144059 2 0.042723439 0 0.274731406 0 -0.137271356 0 1.150123735 0 -0.206048451 2 1.616891448 0 0.463320206 0 -1.161286077 0 0.138282693 0 -0.121962476 2 0.569536042 0 0.547368307 0 -0.636299236 0 2.179852413 0 0.877026639 2 1.793216094 0 -0.5301331 0 -0.115030428 0 -0.538338294 0 -0.319755922 2 1.336966372 0 -0.028303794 0 0.897763649 0 0.974482585 0 -0.312049943 2 0.594109626 1 -1.053684847 0 -2.777346129 0 -1.556233942 2 -0.011835102 0 -0.153983928 0 1.1246669 0 0.588475585 0 1.364298074 2 -0.699566898 0 0.906259486 0 -1.517539644 0 -1.982290606 0 -0.725184649 2 0.270630453 0 -0.019657538 0 -0.253788508 0 1.245171872 0 0.281159394 2 1.787749434 0 0.38264876 0 0.2905945 0 -0.208546413 0 1.586294186 2 1.310968319 0 -0.770050636 0 -0.817494984 0 -0.922086725 0 -0.182465771 2 1.314393721 0 -2.769757693 0 2.656204054 0 0.05011309 0 0.000668005 2 1.002308097 0 -0.494581179 0 -0.136339926 0 0.335527308 0 0.479077701 2 1.33571815 0 -0.682351129 1 -1.920888574 0 0.366360664 2 1.192512187 0 0.659319257 0 -3.327424808 1 -3.358737547 2 -0.072732362 0 2.753850709 0 -0.763821436 0 3.286702982 0 0.546013647 2 0.058725526 0 -0.390611297 0 0.16343603 0 0.823689379 0 0.378943275 3 0.778887538 0 -1.032011661 0 0.638445881 0 -1.738146811 2 -3.368786388 0 0.789218395 0 2.384046368 0 -0.223827408 0 0.662058769 2 1.334577908 0 0.573220173 0 -1.285534927 0 0.243896163 0 2.380579519 2 -0.089560456 0 0.531070728 1 1.604065943 0 0.040086939 2 -1.45779866 0 -0.085183754 0 1.359955016 0 -0.718415154 0 0.609191385 2 -0.190485229 0 -0.553392272 0 0.702416568 0 1.899496365 0 1.263218542 2 1.168067895 1 0.383146833 0 -1.17206505 0 1.291273497 2 0.945027799 0 -2.684874275 0 -1.858122101 0 -0.583836044 0 0.580112296 2 1.328605724 0 -0.040429534 0 -0.680561213 0 -0.888536734 0 1.061113157 2 -0.516149298 0 -0.624037642 0 0.465448064 0 0.32619792 0 0.938592861 2 -0.675070209 0 -0.254871545 0 2.014956569 1 1.164991577 2 -0.767309452 0 2.568251455 0 0.659778327 0 0.578256771 4 -0.275026557 0 -3.89624596 0 -2.591032993 0 -0.659480044 3 4.870647794 0 -1.313070842 0 0.063350521 0 -0.588591051 2 2.025767353 0 -0.963622476 0 -2.096451799 0 0.112118968 0 -0.366229993 2 1.271428687 0 -0.938269908 0 1.912296721 0 1.302111836 0 0.986282198 2 0.313730807 0 -0.634930226 0 0.863012505 0 1.024028662 0 0.676523167 2 0.775747597 0 -0.463237487 0 0.066390044 0 -1.056001531 3 -0.69976612 0 -1.600597625 0 0.057966558 0 1.525161377 0 0.154791586 2 -2.296828792 0 -2.173116 0 1.367845158 0 1.358854968 0 2.01790391 2 0.22821142 0 -0.551144582 0 0.365834946 0 -0.392599206 0 -1.879073312 2 -2.197719376 0 0.94711388 0 -0.263927744 0 -1.051172948 0 -0.638987609 2 -4.710328798 0 1.517168574 0 1.472072764 0 2.469519529 0 1.726055642 3 -0.099797724 0 -0.854436623 0 -0.409080081 0 -0.665221231 2 0.80317816 0 1.615226189 0 3.051560895 0 -1.183658738 0 -0.380881518 2 1.542031317 0 -1.053759091 0 -1.128676181 0 -2.229320446 0 1.195708786 2 2.305102121 0 -0.915792147 0 0.308150375 0 -2.511436426 0 -0.622115988 2 -6.317443208 0 2.791032459 0 1.456393777 0 0.565129766 0 0.313810353 2 1.620100201 0 0.26878423 0 0.156607706 0 -1.429324689 0 0.282409718 2 2.772822003 0 0.432632282 5 -0.356565351 0 -1.627057042 0 -0.557526226 0 -3.627348627 0 1.842080795 2 -0.192765819 0 0.961351818 0 -0.403718166 0 -1.869547666 0 -1.744111587 2 -3.604551652 0 -0.174208628 0 -0.985868067 0 1.256582471 0 -0.34048292 2 0.408702906 0 -0.431750374 0 0.290010627 0 1.249029231 0 0.934028214 2 2.474197323 0 -0.425866665 0 -0.010701415 0 -0.14615741 0 0.040340627 2 -0.061778206 0 -0.959928296 0 -1.671129914 0 -2.439113342 0 0.066979017 2 1.672446881 0 1.675072379 0 1.537053042 0 -0.526653494 0 -1.150901722 2 -0.684153182 0 1.753149357 0 0.260088069 0 1.022352985 0 -0.19207478 2 0.745517692 0 0.213677292 0 -0.359089198 0 -0.661069326 0 0.422210233 2 1.029514737 0 -0.181713928 0 -0.408041967 0 -1.902805824 0 0.361443885 2 -0.242086369 0 -2.186752263 0 -0.147974145 1 -1.060373619 2 -1.229772717 0 -0.156953538 0 0.138344807 0 -1.790576146 0 -1.699258837 2 0.015140671 0 1.820035988 0 0.186332942 0 -1.503900152 0 -0.658803283 2 1.774794343 0 -0.559502797 0 0.85226344 0 -0.017554994 0 0.670298826 2 0.170223073 0 0.459626562 0 -0.32512755 0 -1.298313089 0 0.778051249 2 -0.961126971 0 1.437244902 0 0.314601147 0 0.780545559 0 1.317348107 2 0.803279862 0 -0.255568812 0 -1.36276279 0 -0.489063078 0 -0.262345625 2 -0.337555306 0 -0.758996642 0 -0.457100632 0 0.13802253 0 1.574709544 2 -2.183438765 0 -0.429413761 0 0.819912582 0 0.036404822 3 -0.172028255 0 0.645430569 0 1.993902564 0 -0.457428394 0 -3.13918095 2 0.768040935 0 -0.319809471 0 -1.73948383 0 -0.601205604 0 2.154567042 2 1.411012926 0 0.603532789 0 0.762721469 0 -0.31593301 0 -0.292979664 3 -1.369934909 0 -1.551188013 0 -0.391242177 0 -0.943191362 2 0.762153477 0 -0.917786881 0 -2.171996736 0 -0.129413038 0 2.029861574 2 -0.799416248 0 -0.311834833 0 -0.794882423 0 0.055414652 0 -0.547677307 2 -1.079166534 0 -0.381889658 0 2.75102129 0 0.426316879 3 2.137042703 0 -0.180196339 0 0.067439703 0 -1.818111994 0 -0.733356073 2 -1.515282856 0 -0.469679988 0 0.922900482 0 -1.564907418 0 -0.047102986 2 -0.630412291 0 -0.954974295 0 -0.839343662 1 -0.354114341 2 1.378862598 0 0.141764291 0 -0.981029163 0 1.00157932 0 1.370223907 2 0.32521294 0 -1.402323334 0 1.047427244 0 -0.936999893 0 -0.196806531 2 1.472827781 0 0.570626249 0 -0.055265076 0 -1.495075097 0 -1.534046099 2 -0.610887238 0 -2.143256315 0 -1.944806567 0 -2.684413705 0 0.454683539 2 2.886833864 0 -0.013099848 0 -0.284767459 0 -0.177908463 0 -0.619730794 5 -0.212897948 0 1.247514201 3 -1.997426621 0 -1.368484924 0 -1.931474308 0 0.630477214 2 0.865471998 0 1.497571825 0 1.013404176 0 2.363311349 0 0.135681094 2 0.016756798 0 -0.375415343 0 -0.307791496 0 -0.282592357 0 -0.458605028 2 0.292362908 0 0.023875815 0 0.130061547 0 -0.093873601 0 -0.87525204 2 -1.969266899 0 -0.469983876 0 0.856537983 0 -1.41432711 0 1.298280726 3 -0.501254182 0 -0.354689264 0 0.349132098 0 -0.90195955 2 -0.843900442 0 0.901562719 0 -0.660296399 0 0.104717112 0 1.242560122 2 0.582736061 0 -0.800048714 0 -1.074370305 0 -1.151202587 0 -2.260397585 2 -0.509697876 0 2.335670757 0 1.154567785 0 0.004853701 0 0.126113616 2 -2.601077998 0 -2.979316195 0 -0.738251193 0 1.860431533 0 1.148984193 2 0.178550617 1 6.127119158 0 -1.279903845 0 1.764064023 2 4.279009399 0 -0.596860018 0 0.571438697 0 -3.973082986 0 -0.618936051 2 -0.698449209 0 1.996678804 0 0.801288189 0 1.026627886 0 -0.309318947 2 -2.41365393 0 -1.475235703 0 2.120359114 0 0.817886861 0 -0.163812798 2 -0.391003571 0 -0.666757004 0 2.677120976 0 1.317387476 0 -0.589211519 2 0.093936588 0 -0.248936883 0 1.003979363 0 1.324865992 0 0.526094949 3 3.256411413 0 0.885076989 4 1.167815981 0 -2.118793165 0 -1.314996349 0 -0.79897165 0 -0.325597367 2 -0.912808553 0 1.063773889 0 -1.594407778 0 1.456515761 0 -0.390757671 2 0.858093949 0 -0.262743759 0 -0.328858114 0 -0.68220803 0 -0.43289158 2 -0.753578619 0 0.433208336 0 -1.929037682 0 -1.433064736 0 -0.05494296 2 0.31094505 0 -0.50501305 0 -0.002294394 0 0.313842535 0 0.491308048 2 -0.634743972 0 -2.829500869 0 -0.037707095 0 -0.070739148 0 -0.513175357 2 -0.449115002 0 -0.434395871 0 0.234139922 0 2.463964501 0 1.277802661 2 -1.053760271 0 0.35171701 0 -0.585073062 0 -0.749481523 0 1.723478834 2 -1.086606 0 0.503810641 0 -1.199351708 0 -0.259334416 0 -1.671550835 2 -1.257110789 0 0.919901632 0 -1.757880634 0 1.701034473 0 -0.369887891 2 -0.145602001 0 -1.484139937 0 -2.0004133 0 -0.369115045 3 -2.669922604 0 1.373964489 0 0.780934078 0 0.263715005 0 -0.674950384 2 -1.336334141 0 1.848434446 0 1.379988193 0 2.326781491 0 -1.249619141 2 -0.104979998 0 0.469911058 0 -0.529010774 0 -2.745234529 0 -0.206975571 2 -1.310891354 0 2.68576341 0 -0.378574656 0 -1.62576384 0 -0.448637783 2 -1.261113679 0 0.317204033 0 0.578225294 0 -1.569470115 0 -0.178826163 2 0.854598313 0 -0.426820924 0 -2.054430631 0 -1.09573514 0 -0.983666221 2 -2.936682487 0 2.615418939 0 -1.134459227 0 0.27726026 0 -0.912710048 2 -2.326001878 0 0.202450284 0 -6.573632992 0 1.274643569 0 2.974715246 2 -3.680732299 0 1.656138254 0 2.434852021 0 -1.273902578 0 -2.641618271 3 1.105864321 0 -1.097850216 0 0.549435465 0 1.937708615 2 2.280762487 0 1.948365379 0 -1.631779661 0 1.964673807 0 -0.069105922 3 -2.597794479 0 -1.140709612 0 3.196141946 0 2.120759364 2 -1.45422753 0 0.593506677 0 0.87175493 0 -1.7736356 0 0.20288629 2 0.217388348 0 2.099010996 0 0.40802257 0 0.689298714 0 -0.598449082 2 -1.70069167 0 -1.384874324 0 -0.788860437 0 -0.329984935 0 -0.208574375 2 0.034160135 0 0.899137149 0 -2.382514886 0 0.760686076 0 -1.508768625 2 -0.942552631 0 -0.454459236 0 0.257420632 0 2.467585927 0 0.807597866 2 1.129368667 0 -0.887503055 0 0.289468659 0 0.361132064 3 2.445223258 0 -0.846727928 0 -2.466274058 0 -0.455802748 0 0.163909467 2 -2.001384345 0 -0.088439248 0 1.815218641 0 1.01550719 0 -1.173173382 2 -2.160516704 0 -0.848864044 0 2.094807591 0 -2.268410184 0 -0.610986755 2 -1.781842366 0 0.366372868 0 0.407185108 0 1.573848018 0 -0.490102417 3 -0.46758345 0 -0.882404327 0 1.964460954 0 1.799771925 6 2.092018196 2 0.111896081 0 -2.239768554 0 -0.657340536 0 -1.458373512 0 -1.017863532 3 -1.98162282 0 0.7408834 0 -0.27477698 0 2.282612881 2 -0.179789169 0 -2.079473814 0 -1.013103399 0 0.535887233 0 0.549261913 2 1.129681989 0 -1.852485938 0 -1.439702972 0 0.725015053 0 -1.608930834 2 -1.342287902 0 -1.844119477 0 -0.406755286 0 2.009993892 0 0.923225026 3 2.508356263 0 0.927824853 0 0.087433033 0 -0.156620289 2 -0.083495408 0 -2.237377274 0 -0.318227378 0 3.287375884 0 0.030332444 2 -0.209481383 0 -0.33486591 0 2.346667201 0 0.655130053 0 1.601819011 2 4.634791979 0 -0.346276485 0 -0.18150768 0 2.299692908 0 0.888306558 2 1.549127489 0 -2.416495356 0 -2.102861883 0 0.757558333 0 1.225074007 2 -0.832811923 0 2.240055862 0 -1.351665351 1 -1.951792947 2 -0.319095269 0 -0.846848114 0 1.230011725 0 0.4732038 0 -2.076037633 2 -0.636815248 0 1.435361448 0 1.455635186 0 0.668204086 0 -0.359742328 2 0.224990567 0 -1.71156263 0 0.598210878 0 -0.840184528 0 -1.202634286 2 0.869078898 0 1.17930516 0 1.056404704 0 0.520851197 0 -0.273360352 2 1.23829606 0 -0.127578159 0 -0.524687799 0 -0.036412628 0 -1.014856231 3 -0.476654554 0 0.447217627 0 -0.037728731 4 -1.145979903 0 0.708762267 0 0.842286596 0 -0.45478219 2 -1.033909476 0 -0.270184822 0 1.39981627 0 1.656851273 0 0.305371335 2 0.771906226 0 -0.06895039 0 1.185216209 0 0.636211363 0 0.224046906 2 -0.660399695 0 -0.069816668 0 -0.477649354 0 -0.396075371 0 -0.108861516 2 1.078019586 0 -1.269260116 0 -0.149493585 0 -0.73639823 0 -0.562005144 2 -0.805508023 0 0.754672412 0 -0.695222368 0 -1.767410641 0 -1.903495122 2 -2.746379268 0 1.519065542 0 -2.84200232 0 1.056422248 0 -2.036291796 2 1.07960048 0 0.31532401 0 -3.214135753 0 0.987709778 0 3.055306154 2 0.364253003 0 0.040822675 0 1.462457212 0 -1.049337674 0 0.928599431 2 -0.862813137 0 1.549838376 0 -1.234086755 0 -1.955835966 0 0.229785831 2 -1.884223488 0 -1.607079388 0 0.361953727 0 2.204050746 0 -2.041244374 2 0.174646083 0 0.140101924 0 -1.645158102 0 -0.888611333 0 -2.608124559 2 0.932998145 0 2.392595201 0 -1.026834318 0 -0.666464655 0 -0.290430626 2 -0.047091573 0 -1.682556925 0 2.404280506 0 -0.23930177 0 2.144591846 2 -2.1529257 0 -0.524343423 0 -0.244307907 0 0.96015448 0 -0.064487276 2 -1.753887721 0 0.129097815 0 0.183835234 0 1.429509037 0 0.235931284 2 1.84525678 0 -1.890944484 0 -0.930744005 0 -1.718173575 0 0.422496119 2 -1.205142791 0 -2.847679614 0 -1.993777754 0 1.972763426 0 -1.080983402 2 1.500433214 0 0.522945942 0 0.490789143 0 0.384170073 0 -1.336239976 3 2.608753842 0 -0.497794288 0 1.643052543 0 -1.751972681 3 -1.165618085 0 -1.672126978 0 1.44371033 0 2.407462623 2 -1.6336168 0 -1.938210881 0 -1.128810828 0 -1.085095236 0 0.902444737 2 -3.553884992 0 0.037182065 0 -1.935453477 0 -1.033404041 0 1.522558568 3 3.262898152 0 0.555171447 0 0.340901056 0 1.067255591 2 -0.546262498 0 -3.030569557 0 0.416503367 0 -0.775390854 0 1.437061939 2 0.02752262 0 -1.083671534 0 0.86557645 0 -0.922389034 0 0.537844027 3 2.105965757 0 -0.238610968 0 -0.301621728 0 -2.074587042 2 -2.977250871 0 0.289836261 0 -0.380657361 0 -1.510580906 0 1.857884286 2 -1.863953242 0 -0.822708839 0 1.666391698 0 2.029056846 0 1.312339415 2 1.769937288 0 -1.195373158 0 0.606950619 0 2.146459401 0 0.51549111 2 -0.495225632 0 0.276550714 0 -1.82397915 0 -0.895775203 0 -0.718956967 2 -0.670341469 0 0.184646361 0 -0.532660282 0 -0.071627774 0 -1.843463048 2 -0.955771617 0 0.49405429 0 -1.964060561 0 0.872685765 0 -0.052268515 3 0.889690968 0 -0.33920639 0 1.911481227 ; print holiday2(data); /* ** holiday2.txt - block sampling(Type II) fixing holiday locations for block bootstrap. ** ** It samples among the blocks where the number of holidays before the next block ** matches the number of holidays after the current block and the number of holidays ** before the next mext block matches the number of holidays after the next block. ** Two sets of information of the number of holidays are used sequentially, and the ** length of the next block should be the same pattern as that in the original data ** for convenience on calculation. ** ** (C) Copyright 2003 Yosuke Amijima. All Rights Reserved. ** ** Purpose: Samples data just once by blocks but fixes holiday locations. ** ** Format: y = holiday2(data); ** ** Input: data n x 2 matrix, its 1st column is Nt=0,1,2,3,... holiday interval. ** 2nd column is Rt=[ln(Pt)-ln(Pt-1)]*100. ** ** Output: y n x 1 vector, data by block sampling. ** ** ** Usage: For an appropriate function of f, say, to get vector b(7 parameters), ** we can consider the following bootstrap estimates of bstar: ** ** b=zeros(200,7); ** i=1; ** do while i<=200; ** bootdata=holiday2(data); ** b[i,.]=f(bootdata)'; ** i=i+1; ** endo; ** bstar=meanc(b); ** ** where f is something like an optimization routine ** to get parameter vector b. */ proc holiday2(data); local n,i,j,k,start,finish,index,datablock,nodestart,nodeend,x; local ngroup,bootindex,xi,xx,xiplus,y,length; /* trim the data without infomation nodes of holiday */ n=rows(data); i=1; do while i<=n; if data[i,1]/=0; start=i; break; endif; i=i+1; endo; i=n; do while i>=1; if data[i,1]/=0; finish=i; break; endif; i=i-1; endo; y=data; data=data[start:finish,.]; /* label the patterns of holiday */ datablock=zeros(rows(data),1); nodestart=zeros(rows(data),1); nodeend=zeros(rows(data),1); i=1; j=0; do while i<=rows(data); if data[i,1]/=0; j=j+1; endif; datablock[i]=j; i=i+1; endo; i=1; do while i<=rows(data); if data[i,1]/=0; index=data[i,1]; endif; nodestart[i]=index; i=i+1; endo; i=rows(data); do while i>=2; if data[i,1]/=0; index=data[i,1]; endif; nodeend[i-1]=index; i=i-1; endo; x=data~datablock~nodestart~nodeend; /* calculate the length of each block */ length=zeros(rows(data),1); i=rows(data)-1; j=0; do while i>=1; if data[i+1,1]/=0; j=1; else; j=j+1; endif; length[i]=j; i=i-1; endo; i=2; j=0; do while i<=rows(data)-1; if data[i,1]==0; j=j+1; length[i]=length[i]+j; else; j=0; endif; i=i+1; endo; x=x~length; /* block sampling when completely matched */ xi=zeros(1,6); /* initial dummy data */ k=1; do while k<=rows(x)-1; xx=selif(x,x[.,4].==x[k,4] .and x[.,5].==x[k,5] .and x[.,6].==x[k,6]); i=1; j=0; do while i<=rows(xx); if xx[i,1]/=0; j=j+1; endif; xx[i,3]=j; i=i+1; endo; ngroup=xx[rows(xx),3]; bootindex=ceil(ngroup*rndu(1,1)); xiplus=selif(xx,xx[.,3].==bootindex); xi=xi|xiplus; k=k+x[k,6]; endo; xi=xi[2:rows(xi),.]; /* remove the initial dummy data */ /* extend back to n x 2 data matrix of output y */ xi=xi[.,1:2]; y[start:finish-1,.]=xi; retp(y); endp;