search for: historicalinceptiond

Displaying 1 result from an estimated 1 matches for "historicalinceptiond".

2007 Mar 16
1
cumsum over varying column lengths
...Now I would like compute for each column in historicalReturns, the cumulative return 'returnsFromInception' for the equity starting from the startOffset date. Is there a better way than as follows: n <- NROW(historicalReturns) returnsFromInception <- matrix(nrow = 1, ncol = NCOL(historicalInceptionDates)) for (i in 1 : NCOL(historicalReturns)) { cumReturn <- cumsum(historicalReturns[startOffset[1, i] : n, i]) returnsFromInception[1, i] <- cumReturn[length(cumReturn)] } This works for me, but seems rather inelegant, and I don't like having to use a matrix for returnsFromInc...