[R-SIG-Finance] merge zoo with many entries per date with lagged self using ticker

Gabor Grothendieck ggrothendieck at gmail.com
Sun Nov 14 22:04:59 CET 2010


On Sun, Nov 14, 2010 at 3:18 PM, richard.c.herron at gmail.com
<richard.c.herron at gmail.com> wrote:
> On Sun, Nov 14, 2010 at 13:09, Gabor Grothendieck <ggrothendieck at gmail.com>
>>
>> Normally in zoo you would represent your data in wide form rather than
>> long form in which case there is no problem:
>>
>> > library(zoo)
>> > f <- function(x) as.yearmon(as.character(x), "%Y%m")
>> > z <- read.zoo(temp, split = "symbol", FUN = f)
>> > lag(z, 0:1)
>>         a.lag0 b.lag0 c.lag0 a.lag1 b.lag1 c.lag1
>> Aug 2008      1      2      3      4      5      6
>> Sep 2008      4      5      6      7      8      9
>> Oct 2008      7      8      9     10     11     12
>> Nov 2008     10     11     12     NA     NA     NA
>>
>> --
>> Statistics & Software Consulting
>> GKX Group, GKX Associates Inc.
>> tel: 1-877-GKX-GROUP
>> email: ggrothendieck at gmail.com
>
> Thanks, Gabor!
> I knew about zoo's preference for single row per date, but I didn't know
> read.zoo() converted to wide or the lag(x, 0:1) trick.
> Seeing this has me questioning my ideas on portfolio sorting. Is there a
> good reference on forming portfolios along a given parameter (kind of like
> Jegadeesh-Titman momentum portfolios, but sorted along a parameter other
> than return)? The search terms I'm using in rseek.org aren't yielding much.
> Thanks!

This is not R specific and am not sure if its what you are after but
here is one paper:
http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1108361
Also you might look at the PerformanceAnalytics package.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-SIG-Finance mailing list