[datatable-help] rolling quantiles using data.table

Matthew Dowle mdowle at mdowle.plus.com
Tue Aug 28 11:49:16 CEST 2012


Hi. Welcome.

I'm not aware of anything in R for fully efficient rolling
median/quantile; it's an interesting case. If it find it, or build it,
please let us know.

http://stackoverflow.com/questions/11676476/r-data-table-sliding-window

in which my comment links to :

http://stackoverflow.com/questions/1309263/rolling-median-algorithm-in-c

Matthew


> Hello,
>
> I am new to data.tables so apologies if this is a very basic question.
>
> I have heard that data.tables significantly improves computational times
> when working with large amounts  data, and so would like to see if
> data.table is able to help in speeding up the rollapply function.
>
> if we have some univariate data
>
> xts.obj <- xts(rnorm(1e6), order.by=as.POSIXct(Sys.time()-1e6:1),
> tz="GMT")
> colnames(xts.obj) <- "rtns"
>
> a simple rolling quantile with width of 100 and a p of 0.75 takes a
> surprisingly long time...
>
> i.e. the line of code
>
> xts.obj$quant.75 <- rollapply(xts.obj$rtns,width=100, FUN='quantile',
> p=0.75)
>
> seems to take forever...
>
> is there anything that data.table can do to speed things up? i.e. is there
> a generic roll function that can be applied?
>
> perhaps a routine to convert an xts object to a data.table object to carry
> out the function in a speeded up manner and then reconvert back to xts at
> the end?
>
> thanks in advance
>
> hlm
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>




More information about the datatable-help mailing list