Assuming that you are using log returns, one approach (probably
not the best) is to convert the dates to julian days, find all of the
Sundays spanning the dates in the series, then do something along
the lines of:

tapply(the.log.returns, cut(julian.days, sundays), sum)


Patrick Burns


Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Ajay Shah wrote:

S-Plus has the function AggregateSeries() whose name is self
explanatory. For instance one can derive monthly series from daily
ones by specifying end-of-period, averages, sums, etc. I looked for
a similar function in the packages "its" and "tseries", but found
nothing. I also help.searched() for aggregate to no avail. Would
anybody be so kind to point me in the right direction?



I once needed a function which would convert daily stock prices into weekly returns. I know, the code is pretty bad (it is all loops and it's very slow), but my knowledge of R is weak and I really needed it, so I just used brute force. See EOF for the function. Gabor and Dirk and Brian Ripley and others on the list were very helpful to me in getting to the point where I could write this, though obviously they should not be blamed for my bad code! :-)

I would be very happy if listers could give me ideas on how to do this
better.

Daily to monthly is innately easier since months are 'more normal'
than weeks. I have perl code which does this, which supports 2 cases:
Reporting the last traded price (LTP) of the month versus reporting
the average of the month. If this is useful to you, ask me.

What are the specialised finance libraries available with S-Plus? Can
one marry R with commercial S libraries? I don't like having a
dependence on commercial code, but I might be willing to compromise
and buy libraries that work with R.

Thanks,




______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to