Re: [R] Percentiles/Quantiles with Weighting

2009-02-18 Thread Thomas Lumley
On Tue, 17 Feb 2009, Brigid Mooney wrote: Thanks for pointing me to the quantreg package as a resource. I was hoping to ask be able to address one quick follow-up question... I get slightly different variants between using the rq funciton with formula = mydata ~ 1 as I would if I ran the same

Re: [R] Percentiles/Quantiles with Weighting

2009-02-17 Thread Stavros Macrakis
Here is one kind of weighted quantile function. The basic idea is very simple: wquantile <- function( v, w, p ) { v <- v[order(v)] w <- w[order(v)] v [ which.max( cumsum(w) / sum(w) >= p ) ] } With some more error-checking and general clean-up, it looks like this: # Simple weigh

Re: [R] Percentiles/Quantiles with Weighting

2009-02-17 Thread roger koenker
url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.eduDepartment of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Feb 17, 2009, at 1:58 PM, Brigid Mooney wrote: Than

Re: [R] Percentiles/Quantiles with Weighting

2009-02-17 Thread Brigid Mooney
Thanks for pointing me to the quantreg package as a resource. I was hoping to ask be able to address one quick follow-up question... I get slightly different variants between using the rq funciton with formula = mydata ~ 1 as I would if I ran the same data using the quantile function. Example:

Re: [R] Percentiles/Quantiles with Weighting

2009-02-17 Thread David Winsemius
I do know that Harrell's Quantile function in the Hmisc package will allow quantile estimates from models. Whether it is general enough to extend to time series, I have no experience and cannot say. -- David Winsemius On Feb 17, 2009, at 11:57 AM, Brigid Mooney wrote: Hi All, I am lookin

[R] Percentiles/Quantiles with Weighting

2009-02-17 Thread Brigid Mooney
Hi All, I am looking at applications of percentiles to time sequenced data. I had just been using the quantile function to get percentiles over various periods, but am more interested in if there is an accepted (and/or R-implemented) method to apply weighting to the data so as to weigh recent dat