Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I've subsetted and plotted my unweighted data, but I don't see how to make use of my weighting variable "FactBx$expwgt"

#####################################################
plot( density(FactB1$BAV_DIST),  
#### xlim=range( c(FactB1$BAV_DIST, FactB2$BAV_DIST, FactB3$BAV_DIST) ), 
     xlim = c(0, 10),
     main = "Density Plots",
     xlab = "miles",
     col = 2  )

lines(density(FactB2$BAV_DIST), col=3)
lines(density(FactB3$BAV_DIST), col=4)      
lines(density(FactB6$BAV_DIST), col=5)  

TextVect <- c("Walk","Bicycle","Auto{Dropped}","Auto{Parked}")
ColorVect <- c(2,3,4,5)             
LineVect <- c(0,1,2,3)          

mtext(TextVect, side = 1, line = LineVect, col = ColorVect)
###########################################################

I've been using the survey package to do weighted summaries, but I don't see how to do weighted density plots.

share|improve this question
The density function has a "weights = " parameter; would this be what you want? – jbowman Feb 3 '12 at 23:07

1 Answer

The density function takes a 'weights' parameter. It expects the weights to sum to 1. If you give a vector of weights that don't sum to 1 the estimated density won't be a true density but the shape of the estimate will still be the same.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.