Can anyone help me to construct a variable "PI" from values of variable x. Variable x represents a group of two time series rj and ri on equal dates(joined two dated lists with states).Variable x have about 2000 observations. Example of variable x:
f1 = FinancialData["PA:ACA", "Return", {{2007, 1, 1}, {2014, 10, 20}}];
cac40 = FinancialData["^FCHI","Return", {{2007, 1, 1}, {2014, 10, 20}}];
x=Select[GatherBy[Join[f1,cac40], First], Length@# == 2 &];
Form of variable x:
{{{{2014,10,1},0.01},{{2014,10,1},0.05}}},
{{{2014,10,2},0.02},{{2014,10,2},0.06}}}}.
Time series-variable rj in the above fromula represents the first dated list with states 0.01 and 0.02, and time series ri represents second dated list with states 0.05,0.06. In the case of the above example rj refer to values of f1 and ri refer to values of cac40. If for example rj had state-value of 0 on 1st October, variable r_(ј,t,τ), on 2nd October should be equal to r_(ј,t,τ)=(1+0.05)-1. If for example rj have 2 consecutive values of 0, on 1st and 2nd October, PI for 3rd October should capture the impact of first and second date as r_(ј,t,τ)=((1+0.05)*(1+0.06))-1.
Delta is a dummy variable that takes value 1 if the value of variable rj on current date or date before have value 0. If rj is different from 0, delta should be 0, such that the numerator of PI takes value 0. Variable w represents a weight and have a form of list of equal values for all x dates. For example 0.5 for all 2000 observations. It could be treated as a constant, say 1, or thrown from PI formula.
Summation of numerator and denominator of PI variable should be done for one business week-5 days(Mo,Tu,We,Th,Fr). Variables rj and ri are already paired values on equal business-trading day, so PI should represent a measure that would refer to one week.
PI
with? It would be easier to help if we could see what part of the formula you are having problems with. $\endgroup$ – Edmund Oct 27 '14 at 18:31Piecewise
and your r function usingPiecewise
andFoldList
. You can giveFoldList
a vector of the required length or the whole vector then something like thisFoldList[#1 (1+#2)&, 1, r[[1 ;; \[tau] -1]]]-1
will get you what you need for the product part. $\endgroup$ – Edmund Oct 28 '14 at 19:04\[Tau]
not\[tau]
$\endgroup$ – Edmund Oct 29 '14 at 1:11