Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculate average of the (pairwise) sample cross-correlations

    Dear forum,
    since this is my first post here and since I am new to Stata, I hope my post fulfills the forum requirements. I want to calculate the pairwise correlations across the (abnormal) returns of 80 firms,
    for an event study test statistic and I need the average over all these pairwise correlations. I have read that I might achieve what I intend by using a loop, however I am unable to program
    such a loop unfortunately. In the last clumn i have stored a value I also need to construct the test statistic, but for the correlations that value is irrelevant.

    Below you can find an excerpt of my data. Any help would be highly appreciated!!
    Jonas


    input long Date float(resid_MarketModel_1 resid_MarketModel_2 resid_MarketModel_3 BMP_t)
    22715 .028857823 -.012030476 .011276288 -17.066809
    22718 .001680778 .015519869 .04662051 -17.066809
    22719 -.013552702 -.0013050697 -.010423742 -17.066809
    22720 .011290512 .0247944 .022345623 -17.066809
    22721 -.017967667 .0013580762 -.02512785 -17.066809
    22722 -.009187383 -.011011245 -.0087083 -17.066809
    22725 .003578504 -.0034927686 -.00557095 -17.066809
    22726 -.005407726 .010930496 .006511768 -17.066809
    22727 -.013838122 -.01001027 -.015077838 -17.066809
    22728 -.00786587 -.006517837 -.007176251 -17.066809
    22729 .0239404 .003767889 .027022535 -17.066809
    22732 -.011907137 -.014157334 -.02665999 -17.066809
    22733 .005552202 -.008957997 -.009840348 -17.066809
    22734 -.023531053 .00018480085 -.02001087 -17.066809
    22735 .0040255897 -.017226135 -.009717827 -17.066809
    22736 -.014861178 -.010953325 -.007508885 -17.066809
    22739 -.012034866 -.003144226 -.01649329 -17.066809
    22740 -.0007985968 -.001498356 .007198072 -17.066809
    22741 -.0037047905 -.006126278 -.0025296016 -17.066809

  • #2
    In case someone is struggling with this too:

    alpha resid_*, std det // average pairwise cross correlations
    gen pwcorr_mean = r(rho)

    does the trick.

    Comment

    Working...
    X