[R] weighting observations
Thomas Lumley
thomas at biostat.washington.edu
Thu Oct 19 17:31:52 CEST 2000
On Thu, 19 Oct 2000, Federico Spinazzi wrote:
> Dear R users,
>
> I wonder how to weight observationswhen computing statistics and creating
> tables (e.g. of counts)
> I'm used to the SPSS paradigm (WEIGHT by foo.) where any subsequent command
> will weight any variable ...
>
> Suppose that I want to compute a table of weighted counts: is the right
> R-approach to write a little custom function or it could be better to write
> a new class (data.frame.weightable) or, finally, there is already a
> 'standard' way to do this ?
There isn't. There was some discussion on this a few weeks ago -- it
takes some care, since there are at least three different concepts called
"weights" in common statistical use (Stata distinguishes them nicely, most
other packages don't).
Functions that handle probability weights and frequency weights (I think
the latter is what you want) are on my To Do list, but they are a long way
off so it would be great if someone else were to handle them.
My preference would be for a function that accepted a weight= argument,
since you might need more than one set of weights in a data frame
(admittedly in somewhat unusual circumstances), and you might want to
ignore the weights sometimes. You could have it both ways: have, say,
attr(,"weights") on the data frame be the name of the column of weights
and have the function use this by default if it is present.
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list