[R] Weighting factor

Thomas Lumley tlumley at u.washington.edu
Tue Sep 27 20:00:38 CEST 2005

On Tue, 27 Sep 2005, Ferran Carrascosa wrote:

> Hi everyone,
> I would like some package of R or any help to solve the next problem
> with a weighting fatcors:
> Giving a data matrix with dichotomous (2 or more) variables in columns
> and individuals in rows, and also a theorical distribution of the
> dichotomous variables I would like a row weight (one per individual)
> that transform the real distribution of variables to the theorical
> distribution.

You should be able to do this with postStratify() in the survey package 
(if you have joint distributions for the variables) or calibrate() if you 
have only marginal distributions.

You would need to create a survey design object, use postStratify() or 
calibrate() on it, then use weights() to extract the weights.


More information about the R-help mailing list