[R] Relative subscripting
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Dec 1 09:43:22 CET 2004
I've not seen anyone mention that this is really a time-series problem of
lagging variables, and something like
tmp <- ts.intersect(as.ts(return), lag(marketcap, -1))
tmp[,1]*tmp[,2]
is a lot more intuitive, easier to generalize and keeps the timebase
information around.
On Wed, 1 Dec 2004 Ted.Harding at nessie.mcc.ac.uk wrote:
> On 01-Dec-04 Uwe Ligges wrote:
>> (Ted Harding) wrote:
>>> [...]
>>> Let
>>>
>>> N<-length(return)
>>> new.var <- return[2:N]*marketcap[1:(N-1)]
>>
>> Ted, I aggree to all of your points, but we can simplify by negative
>> indices (and hence circumvent your note 1):
>> return[-1] * marketcap[-N]
>>
>> Uwe Ligges
>
> Neat footwork, Uwe!
> (Why didn;t I think of that? No, don't answer ... )
> Ted.
>
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
> Fax-to-email: +44 (0)870 094 0861 [NB: New number!]
> Date: 01-Dec-04 Time: 08:00:22
> ------------------------------ XFMail ------------------------------
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list