tedzzx
2008-Nov-11 02:57 UTC
[R] Manipulation in timeSeries object:how to use the function "applySeries" by daily?
Hi all I have some tick-by-tick data and I have calculated the intraday returns. I want to sum up the intraday squared returns to calculate the daily volatility(or daily variance). I know that the s-plus FinMerics has the function aggregateSeries function that can be apply to daily data: aggregateSeries(x, Fun, by="daily"), but the counterpart function in R:applySeries can not be apply to daily data. This function has the argument by=c("monthly", "quartly"). Can we find some way to mimic the aggregateSeries function in s-plus? Thanks in advance Ted -- View this message in context: http://www.nabble.com/Manipulation-in-timeSeries-object%3Ahow-to-use-the-function-%22applySeries%22-by-daily--tp20432658p20432658.html Sent from the R help mailing list archive at Nabble.com.
stephen sefick
2008-Nov-11 15:00 UTC
[R] Manipulation in timeSeries object:how to use the function "applySeries" by daily?
take a look at aggregate.zoo in the zoo package good luck Stephen On Mon, Nov 10, 2008 at 9:57 PM, tedzzx <zengzhenxing at gmail.com> wrote:> > Hi all > I have some tick-by-tick data and I have calculated the intraday returns. I > want to sum up the intraday squared returns to calculate the daily > volatility(or daily variance). I know that the s-plus FinMerics has the > function aggregateSeries function that can be apply to daily data: > aggregateSeries(x, Fun, by="daily"), but the counterpart function in > R:applySeries can not be apply to daily data. This function has the argument > by=c("monthly", "quartly"). > Can we find some way to mimic the aggregateSeries function in s-plus? > > Thanks in advance > > Ted > -- > View this message in context: http://www.nabble.com/Manipulation-in-timeSeries-object%3Ahow-to-use-the-function-%22applySeries%22-by-daily--tp20432658p20432658.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
Jeff Ryan
2008-Nov-11 17:04 UTC
[R] Manipulation in timeSeries object:how to use the function "applySeries" by daily?
Take a look at xts, a time series class that extends zoo and is compatible (forward and backwards) with all major time-series classes, including timeSeries from Rmetrics. It has a few functions that may be of interest: ?endpoints ?period.apply It may also be useful to use the Fortran-based aggregation by time functions to turn your series into an OHLC series. See ?to.period quantmod also has a ?periodReturn function that may be of interest. Some examples of all the above can be found at http://www.quantmod.com http://www.quantmod.com HTH Jeff tedzzx wrote:> > Hi all > I have some tick-by-tick data and I have calculated the intraday returns. > I want to sum up the intraday squared returns to calculate the daily > volatility(or daily variance). I know that the s-plus FinMerics has the > function aggregateSeries function that can be apply to daily data: > aggregateSeries(x, Fun, by="daily"), but the counterpart function in > R:applySeries can not be apply to daily data. This function has the > argument by=c("monthly", "quartly"). > Can we find some way to mimic the aggregateSeries function in s-plus? > > Thanks in advance > > Ted >-- View this message in context: http://www.nabble.com/Manipulation-in-timeSeries-object%3Ahow-to-use-the-function-%22applySeries%22-by-daily--tp20432658p20443829.html Sent from the R help mailing list archive at Nabble.com.