I have a time-series dataset of indices with continuously compounded monthly returns. I would like to calculate correlations between those indices over different time-periods, specifically correlations from 1 to 60 months. To specify further, ideally I generate correlations between the indices for 1 month period, 2 month period, 3 month period all the way up to 60 months.
Two ideas:
1. Maybe I could use rangestat and construct a loop that constantly changes the interval in combination with corr or pwcorr. Anyhow, I think I have to create a little program that can be set to a certain interval.
2. Note that the data is continuously compounded returns so that gives the nice characteristic that the return are additive and I can easily create a two month return by just adding two months. So another idea is to create a lot of return series, literally 1 - 60 months and then calculate the correlations within all the specific return series.
For example: generate r_gbond_JPMEMBI_2 = r_gbond_JPMEMBI+r_gbond_JPMEMBI[_n-1] gives the laged two month return
generate r_gbond_JPMEMBI_3 = r_gbond_JPMEMBI+r_gbond_JPMEMBI[_n-2] gives the three month laged return etcetera
Do this for for all variables and then calculate correlations.
The main problem is that I have a lot of indices and thus I need some way to automate the process. Your help would be much appreciated.
A sample of the data with some real estate indices:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(r_re_FTSEEPRAREITDEV r_re_FTSEEPRANAREITEU r_re_FTSEEPRANAREITUK r_re_SPGLOBALREIT r_re_MSCIACRE r_re_MSCIWRE) -.05162523 -.04030233 -.07434651 -.010409984 . . -.09698088 .01532312 .016828181 -.006122915 . . -.002636437 -.014649783 -.03800836 -.010806148 . . .07515127 .021124316 .010486507 .005307399 . . .0014856636 .0007706555 -.0038241546 .0039621447 . . .021289164 -.017118428 -.03940146 -.01572046 . . -.09736057 -.08761826 -.12379114 -.0487009 . . -.12628321 -.12328941 -.0763804 -.07591192 . . .08007725 .034514215 .07083003 -.0305426 . . -.036439285 -.012624208 .04094776 .015516215 . . .012934634 -.0039319834 .02928039 -.003341476 . . .05312132 -.011827523 -.022934675 .07726614 . . .06833479 .05488331 .05039921 .03074277 . . -.035352755 .0002936297 -.023580836 .05135107 . . -.000463594 -.012422153 .0017770927 .008525574 . . -.03213529 -.05157338 -.08219742 .0017398874 . . -.04967258 -.014533903 -.007557125 -.020859247 . . .06990364 -.0015414078 .03498264 .01519351 . . -.02015444 -.023443414 .008141014 -.002187706 . . .03827149 .005455268 .06047079 -.0021925026 . . .0041388883 -.030362396 -.06078674 .014382467 . . -.0404014 -.04721412 -.030551694 -.00978375 . . .04791783 -.0583634 -.04390069 .0531814 . . -.03872818 -.009711257 -.003732656 .02131665 . . -.021304484 -.05412758 -.08693027 -.02775957 . . -.0424856 -.0468741 -.1220344 -.027480064 . . .009562914 .0019252073 .072584495 .007685776 . . .1131023 .002231083 .034344565 .025822785 . . -.0495815 -.08152438 -.08682602 -.010626207 . . -.05037133 -.07346926 -.13674332 .019087717 . . -.010274403 -.06089723 -.07246526 -.025602397 . . -.034191713 .004955563 .1497641 .002737132 . . .006457075 .028832454 .10574977 .007958157 . . -.02656632 .04643786 .031800687 .01900884 . . -.020543424 -.0013953436 .04385412 .015031768 . . .020943286 .024060924 .09868106 .04648336 . . .0818183 .09048246 .07977673 .04772651 . . .066127084 .04261853 .0255801 .064137064 . . .07237468 .01815754 -.02513874 -.031465627 . . .05364956 .06155997 .1080012 -.00320171 . . -.034886785 .05233388 .04873068 .022373874 . . .008627071 .07669845 .04605032 .03037035 . . .0577249 .05947014 .09811786 .028325785 . . .006444008 -.026136676 .016754149 .014029594 . . .08371858 .04114962 .04290646 -.006337878 . . -.04187677 -.010553096 .00249387 -.03855579 . . .16559055 .05578623 .04673462 .018466195 . . .030681754 .08417988 .04031807 .0415403 . . -.0347584 -.033512957 -.02060734 .004775558 . . -.070866525 -.08062889 -.11452986 -.018269738 . . .002910073 -.0015617495 .0488515 -.01564824 . . .02445207 -.034290295 -.05436609 .01564824 . . -.04485165 -.03810589 -.00605877 -.017950874 . . .032447837 .03217828 .06761778 -.007271558 . . .014973599 -.013641444 -.019237615 0 . . -.011113128 -.05855602 -.05561113 -.02366478 . . .0027238606 -.011178024 -.014531055 -.026503013 . . -.09054806 .0006460059 -.02752384 -.03767325 . . -.002764932 -.0012924293 .024805296 .04202373 . . -.0369584 -.03522503 -.04349966 -.009596165 -.06684145 -.05341139 .04304272 .004256598 .05140394 .018412888 .05022925 .05715055 .0346217 -.018386843 .02131401 .0020632744 .032035083 .03835907 -.006450824 .01666528 -.014609987 .001030043 -.009019227 -.008614245 .04747656 .06092658 .08535226 .03920091 .07294538 .064065285 .003373989 -.012116317 .019856393 .006086045 -.0025875715 -.004686992 .03857429 .026895154 .036779664 .01739457 .04512326 .04224322 -.016675556 -.008117751 -.043328 -.0019357967 -.04301436 -.04174399 .026236955 .002314379 .010788108 .018240506 .027298035 .033819042 -.009689504 -.01491542 -.048073 -.011641947 -.018526886 -.015360645 .023249205 .02948238 .0469608 -.004340494 .02835543 .033578184 .031916488 .015408477 .017759938 .04827602 .04342425 .04266597 .07536978 .03790414 .014969445 .024265673 .0778997 .08035056 -.0018794354 -.0021009217 .0033900384 .002394494 -.01664645 -.016978424 -.005467025 .0003376719 .0197266 .003729956 .030766623 .03186392 .018238133 .036849286 .07419464 -.001192073 .02325686 .02428326 .012335464 -.016614353 -.04484114 .012740913 .006434928 .007233497 .006886047 .005189908 -.01124161 .020688383 -.0039188075 -.00664993 -.020434516 .003822669 .0496711 .0043165535 -.03581518 -.036806885 .035818685 .0472013 .06106487 .03941397 .028168617 .026059203 .03895003 .011070145 -.01109704 .016698992 .05346313 .06301379 .02509149 .0045031537 -.03730426 .01975738 .0009746955 .009955659 .06650412 .03038306 -.013185513 .04387296 .07713311 .07902418 .018218843 .0437549 .037209928 .06901835 -.019192295 -.02232142 .0026259355 .05952464 .0288322 .016272025 -.0067412 -.01346295 .013701483 .033215962 -.009717938 .017736511 .02426706 .02666786 -.036178745 -.008684948 -.015541554 .0040135365 -.06837259 -.072900236 -.00313087 .001444785 .02455437 -.033988375 .012496928 .02013254 .07270218 .034385864 .06945988 .02201494 .09985597 .1046073 .003139996 -.005653358 -.07201187 .03828926 .0009970422 -.003513089 .02376839 .02484728 -.0012454006 .0377362 .01993028 .02768502 -.005218891 -.019412985 .006192786 -.013508608 -.08967321 -.07709932 .04229774 .05505051 .09863796 .06517753 .04383213 .04918788 -.1564174 -.014045422 .010561975 -.034217957 -.23597524 -.23912807 -.016179424 -.017168665 -.04480627 .02818553 -.00562699 -.0022510937 -.017784102 .015152313 .017994784 .02521525 -.04628441 -.04493151 -.036929812 .07113539 .0919229 -.003706862 -.08083104 -.07937597 .068319835 .016014604 .01928045 -.006747596 .13670556 .13471763 -.00007750135 .03752572 -.03046367 .01743007 -.01489979 -.017211588 -.03153246 .01904524 .02752929 -.02402005 -.05507625 -.05464735 -.04891965 -.006698142 -.020603295 -.00509893 -.10901488 -.11125132 end
Thanks in advance,
Sam
0 Response to Correlation values over varying periods in time-series data
Post a Comment