Re: [R] Weighted box or violin plots in Lattice?

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Mon, 09 May 2011 10:05:30 +0530

On Mon, May 9, 2011 at 2:20 AM, Thomas Lumley <tlumley_at_uw.edu> wrote:
> On Mon, May 9, 2011 at 6:35 AM, Deepayan Sarkar
> <deepayan.sarkar_at_gmail.com> wrote:
>> On Sat, May 7, 2011 at 1:55 AM, Raphael Mazor <raphaelm_at_sccwrp.org> wrote:
>>> Is it possible to create weighted boxplots or violin plots in lattice?
>>>
>>> It seems that you can specify weights for panel.histogram() and
>>> panel.densityplot(), but not for panel.bwplot or panel.violin().
>>
>> Not for panel.histogram() either.
>>
>> It's not immediately obvious how you would get weighted boxplots.
>
> The way the survey world does it is to get weighted quantiles and work
> from them, as in survey:::svyboxplot().  The only tricky decision is
> what to do with outliers, since I haven't been able to think of any
> good way of indicating weights on them.

So I guess with bwplot() one would have to write a version of boxplot.stats() that uses weighted quantiles, and then write a modified panel function.

A crude approximation (if the weights don't vary too much) may be to scale and round the weights to integers, and then repeat each data point; e.g., newx <- rep(x, w), etc.

-Deepayan



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. Received on Mon 09 May 2011 - 04:38:14 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 09 May 2011 - 12:40:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive