Members of the Forum -
here's a problem I have - I think I know the correct answer but can't think
of a nice way to
demonstrate it. I had the idea of running simulations of all three
possibilities for random values
but this doesn't give me any easy explanation of why I'd prefer one method
to the other.
The problem is: I have two return series - one is monthly returns, the other
is quarterly - and
I want to find the correlation between the two series. I thought of three
ways to do this:
1) I could reduce the monthly series and run the correlation between the
quarterly and every third monthly;
2) I could linearly interpolate the quarterlies to get pseudo-monthlies;
3) I could compound the monthlies to make them quarterly.
Some code follows to try these three ways for a random series. I'm using
<:+:?y$0 to generate
random returns between -100% and 100% but that shouldn't affect the
argument.
So, please figure which way you think is the best and demonstrate why. Code
follows my sig.
Thanks,
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
NB.* compareCorrVariants.ijs: compare different ways of correlating
quarterly vs.
NB. monthly series.
NB.* compareCorrQvsM: compare 3 variants: reducing monthly, interpolating
NB. quarterly, or compounding monthly -> quarterly.
compareCorrQvsM=: 3 : 0
qtrly=. <:+:?y$0
moly=. <:+:?0$~3*y
cc=. 3{.corrCoeff qtrly,.moly#~1,2~:/\<.((#moly)%~#qtrly)*i.#moly
cc=. (corrCoeff (,2 linterpolate"0 qtrly),.moly) 1}cc
cc=. (corrCoeff qtrly,._3 aggrets\moly) 2}cc
NB.EG compareCorrQvsM 33
)
NB.* aggrets: aggregate returns->compound return over entire period.
aggrets=: 13 : '<:*/>:y'
NB.* linterpolate: linear interpolation between 2 points->x points replacing
NB. first of the two.
linterpolate=: 13 : '({.y)+(i.>:x)*(-~/y)%>:x'
corrCoeff=: 3 : 0
NB.* corrCoeff: coefficients of linear correlation between 2 columns of y.
avgdif=. y.-"(1 1)mean y.
(+/*/"1 avgdif)%%:*/+/*:avgdif
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm