Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generating and Applying Frequency Weights

    Hi all,

    I am entirely new to Stata. I have a survey of 400 respondents that has oversampled females (it's 59-41 female to male). I need the ratio to be 52% female to 48% male. I am having difficulty finding ways to weight the data based on 52-48 female to male and then apply this weight throughout the data set. How do I apply weight to gender values in stata and apply across the survey?

    I appreciate any help! I know this is a simple question, but I'm very new to this.

    Thanks all!

    Evan

  • #2
    If I understand your question correctly, what you want is survey raking, a form of post-stratification. The package ipfraking might help you and it seems to handle complex designs (I haven't used it). But your case is as simple as it gets: matching the marginal proportions of a single variable to known population values.

    This should do the trick, assuming you have a dummy variable for female:

    Code:
    * Safe way to get sample proportions
    scalar nobs = _N
    bysort female: gen sample_prop = _N/nobs
    
    * Input population proportions
    gen pop_prop = .
    replace pop_prop = .52 if female
    replace pop_prop = .48 if !female
    
    * Generate weight
    gen weight =  pop_prop/ sample_prop
    
    * Compare:
    table female
    table female [pw=weight]
    Weverthon Machado
    weverthonmachado.github.io

    Comment

    Working...
    X