problem for wtd.quantile()

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

problem for wtd.quantile()

Jing Yang
Dear R-users,

I don't know if there is a problem in wtd.quantile (from library "Hmisc"):
--------------------------------
x <- c(1,2,3,4,5)
w <- c(0.5,0.4,0.3,0.2,0.1)
wtd.quantile(x,weights=w)
-------------------------------
The output is:
  0%  25%  50%  75% 100%
3.00 3.25 3.50 3.75 4.00

The version of R I am using is: 2.1.0

Best,Jing


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: problem for wtd.quantile()

Liaw, Andy
Perhaps you're looking for this?

> ?wtd.quantile
> wtd.quantile(x,weights=w, normwt=TRUE)
  0%  25%  50%  75% 100%
   1    2    2    3    5

Andy

From: Jing Yang

>
> Dear R-users,
>
> I don't know if there is a problem in wtd.quantile (from
> library "Hmisc"):
> --------------------------------
> x <- c(1,2,3,4,5)
> w <- c(0.5,0.4,0.3,0.2,0.1)
> wtd.quantile(x,weights=w)
> -------------------------------
> The output is:
>   0%  25%  50%  75% 100%
> 3.00 3.25 3.50 3.75 4.00
>
> The version of R I am using is: 2.1.0
>
> Best,Jing
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: problem for wtd.quantile()

RKoenker
Certainly an improvement, but probably not what is really
wanted... I get:

 > rq(x ~ 1, weights=w,tau = c(.01,.25,.5,.75,.99))
Call:
rq(formula = x ~ 1, tau = c(0.01, 0.25, 0.5, 0.75, 0.99), weights = w)

Coefficients:
             tau= 0.01 tau= 0.25 tau= 0.50 tau= 0.75 tau= 0.99
(Intercept)         1         1         2         3         5

Degrees of freedom: 5 total; 4 residual

The first observation x=1 has weight .33  so it should be the
.25 quantile, unless there is some interpolation going on....

url:    www.econ.uiuc.edu/~roger            Roger Koenker
email    [hidden email]            Department of Economics
vox:     217-333-4558                University of Illinois
fax:       217-244-6678                Champaign, IL 61820


On Mar 16, 2006, at 7:34 AM, Liaw, Andy wrote:

> Perhaps you're looking for this?
>
>> ?wtd.quantile
>> wtd.quantile(x,weights=w, normwt=TRUE)
>   0%  25%  50%  75% 100%
>    1    2    2    3    5
>
> Andy
>
> From: Jing Yang
>>
>> Dear R-users,
>>
>> I don't know if there is a problem in wtd.quantile (from
>> library "Hmisc"):
>> --------------------------------
>> x <- c(1,2,3,4,5)
>> w <- c(0.5,0.4,0.3,0.2,0.1)
>> wtd.quantile(x,weights=w)
>> -------------------------------
>> The output is:
>>   0%  25%  50%  75% 100%
>> 3.00 3.25 3.50 3.75 4.00
>>
>> The version of R I am using is: 2.1.0
>>
>> Best,Jing
>>
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting- 
> guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: problem for wtd.quantile()

Jing Yang
In reply to this post by Jing Yang
Actually, I am looking for this result:
  0%  25%  50%  75% 100%
   1    1    2    3    5
-----------------------
y <- c(1,1,1,1,1,2,2,2,2,3,3,3,4,4,5)
quantile(y)
-----------------------

Since x with weights w is equivalant to y.

======= At 2006-03-16, 14:34:14 you wrote: =======

>Perhaps you're looking for this?
>
>> ?wtd.quantile
>> wtd.quantile(x,weights=w, normwt=TRUE)
>  0%  25%  50%  75% 100%
>   1    2    2    3    5
>
>Andy
>
>From: Jing Yang
>>
>> Dear R-users,
>>
>> I don't know if there is a problem in wtd.quantile (from
>> library "Hmisc"):
>> --------------------------------
>> x <- c(1,2,3,4,5)
>> w <- c(0.5,0.4,0.3,0.2,0.1)
>> wtd.quantile(x,weights=w)
>> -------------------------------
>> The output is:
>>   0%  25%  50%  75% 100%
>> 3.00 3.25 3.50 3.75 4.00
>>
>> The version of R I am using is: 2.1.0
>>
>> Best,Jing
>>
>>
>
>
>------------------------------------------------------------------------------
>Notice:  This e-mail message, together with any attachments...{{dropped}}

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: problem for wtd.quantile()

Liaw, Andy
In reply to this post by Jing Yang
I don't know why using the fractional weights and normwt=TRUE gives that
answer, but:

> wtd.quantile(x, 5:1)
  0%  25%  50%  75% 100%
   1    1    2    3    5

Andy

From: Jing Yang

>
> Actually, I am looking for this result:
>   0%  25%  50%  75% 100%
>    1    1    2    3    5
> -----------------------
> y <- c(1,1,1,1,1,2,2,2,2,3,3,3,4,4,5)
> quantile(y)
> -----------------------
>
> Since x with weights w is equivalant to y.
>
> ======= At 2006-03-16, 14:34:14 you wrote: =======
>
> >Perhaps you're looking for this?
> >
> >> ?wtd.quantile
> >> wtd.quantile(x,weights=w, normwt=TRUE)
> >  0%  25%  50%  75% 100%
> >   1    2    2    3    5
> >
> >Andy
> >
> >From: Jing Yang
> >>
> >> Dear R-users,
> >>
> >> I don't know if there is a problem in wtd.quantile (from
> >> library "Hmisc"):
> >> --------------------------------
> >> x <- c(1,2,3,4,5)
> >> w <- c(0.5,0.4,0.3,0.2,0.1)
> >> wtd.quantile(x,weights=w)
> >> -------------------------------
> >> The output is:
> >>   0%  25%  50%  75% 100%
> >> 3.00 3.25 3.50 3.75 4.00
> >>
> >> The version of R I am using is: 2.1.0
> >>
> >> Best,Jing
> >>
> >>
> >
> >
> >-------------------------------------------------------------
> ----------
> >-------
> >Notice:  This e-mail message, together with any attachments,
> contains information of Merck & Co., Inc. (One Merck Drive,
> Whitehouse Station, New Jersey, USA 08889), and/or its
> affiliates (which may be known outside the United States as
> Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
> Banyu) that may be confidential, proprietary copyrighted
> and/or legally privileged. It is intended solely for the use
> of the individual or entity named on this message.  If you
> are not the intended recipient, and have received this
> message in error, please notify us immediately by reply
> e-mail and then delete it from your system.
> >-------------------------------------------------------------
> -----------------
>
>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: problem for wtd.quantile()

Jing Yang
In reply to this post by Jing Yang
Thanks. But that's interesting.
======= At 2006-03-16, 15:15:49 you wrote: =======

>I don't know why using the fractional weights and normwt=TRUE gives that
>answer, but:
>
>> wtd.quantile(x, 5:1)
>  0%  25%  50%  75% 100%
>   1    1    2    3    5
>
>Andy
>
>From: Jing Yang
>>
>> Actually, I am looking for this result:
>>   0%  25%  50%  75% 100%
>>    1    1    2    3    5
>> -----------------------
>> y <- c(1,1,1,1,1,2,2,2,2,3,3,3,4,4,5)
>> quantile(y)
>> -----------------------
>>
>> Since x with weights w is equivalant to y.
>>
>> ======= At 2006-03-16, 14:34:14 you wrote: =======
>>
>> >Perhaps you're looking for this?
>> >
>> >> ?wtd.quantile
>> >> wtd.quantile(x,weights=w, normwt=TRUE)
>> >  0%  25%  50%  75% 100%
>> >   1    2    2    3    5
>> >
>> >Andy
>> >
>> >From: Jing Yang
>> >>
>> >> Dear R-users,
>> >>
>> >> I don't know if there is a problem in wtd.quantile (from
>> >> library "Hmisc"):
>> >> --------------------------------
>> >> x <- c(1,2,3,4,5)
>> >> w <- c(0.5,0.4,0.3,0.2,0.1)
>> >> wtd.quantile(x,weights=w)
>> >> -------------------------------
>> >> The output is:
>> >>   0%  25%  50%  75% 100%
>> >> 3.00 3.25 3.50 3.75 4.00
>> >>
>> >> The version of R I am using is: 2.1.0
>> >>
>> >> Best,Jing
>> >>
>> >>
>> >
>> >
>> >-------------------------------------------------------------
>> ----------
>> >-------
>> >Notice:  This e-mail message, together with any attachments,
>> contains information of Merck & Co., Inc. (One Merck Drive,
>> Whitehouse Station, New Jersey, USA 08889), and/or its
>> affiliates (which may be known outside the United States as
>> Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
>> Banyu) that may be confidential, proprietary copyrighted
>> and/or legally privileged. It is intended solely for the use
>> of the individual or entity named on this message.  If you
>> are not the intended recipient, and have received this
>> message in error, please notify us immediately by reply
>> e-mail and then delete it from your system.
>> >-------------------------------------------------------------
>> -----------------
>>
>>
>>
>>
>
>
>------------------------------------------------------------------------------
>Notice:  This e-mail message, together with any attachments...{{dropped}}

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