[R] density plot for weighted data

Thomas Lumley tlumley at uw.edu
Tue Aug 2 22:18:44 CEST 2011


On Wed, Aug 3, 2011 at 5:11 AM, r student <studentofr at gmail.com> wrote:
> Like below?
>
> plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP)))
>

Yes

If you are doing lots of analyses with weighted data you might want to
look at the survey package.  It also has a density estimator, in
svysmooth(), which works very much the same way as density() for
weighted data, but doesn't complain about rescaling the weights.

    -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland



More information about the R-help mailing list