Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Rolling window correlations for all possible pairs of variables


From   <[email protected]>
To   <[email protected]>
Subject   RE: st: Rolling window correlations for all possible pairs of variables
Date   Mon, 13 Aug 2012 13:21:22 +0100

Dear Maarten
This works like a charm.
Many thanks!
Regards,
Coskun

 
________________________________

From: [email protected] on behalf of Maarten Buis
Sent: Mon 13/08/2012 12:40
To: [email protected]
Subject: Re: st: Rolling window correlations for all possible pairs of variables



On Mon, Aug 13, 2012 at 1:30 PM,  <[email protected]> wrote:
> This is very helpful and works well, however I receive an error message when a pair of variables do not have any overlapping observations. Say var1 has observations in period 1900-1960, whereas var2 has observations in 1970-2000. Thus as it is not possible to calculate the corr, the calculations simply stop. Is there any way to force the do-file keep calculating?

replace the block:

else {
    use `orig', clear
    rolling r(rho), window(10) saving(`temp', replace) : ///
        cor ``i'' ``j''
    use `temp', clear
    rename _stat_1 r_``i''_``j''
    merge 1:1 start using `tofill'
    assert _merge == 3
    drop _merge
    save `tofill', replace
}

with:

else {
    use `orig', clear
    capture rolling r(rho), window(10) saving(`temp', replace) : ///
        cor ``i'' ``j''
    if !_rc {
        use `temp', clear
        rename _stat_1 r_``i''_``j''
        merge 1:1 start using `tofill'
        assert _merge == 3
        drop _merge
        save `tofill', replace
    }
}

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl <http://www.maartenbuis.nl/> 
---------------------------------

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer

<<winmail.dat>>



© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index