Announcement

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

  • Creating a survey weight with survwgt

    Dear Forum,
    I want to create weights for survey data (using the characteristics of gender, age and ethnicity) and was just wondering if I was using the survwgt package (and its raking function) correctly? Any comments on the code below would be most gratefully received. Best and thanks,
    Thomas


    gen Weight = 1

    // generate totals for the weights using demographic data

    gen GenderTotal=.
    replace GenderTotal = 0.49 if Gender == 1
    replace GenderTotal = 0.51 if Gender == 2

    gen AgeTotal=.
    replace AgeTotal = 0.12 if Age_group == 1
    replace AgeTotal = 0.17 if Age_group == 2
    replace AgeTotal = 0.17 if Age_group == 3
    replace AgeTotal = 0.16 if Age_group == 4
    replace AgeTotal = 0.38 if Age_group == 5

    gen EthnicityTotal=.
    replace EthnicityTotal = 0.63 if Ethnicity == 1
    replace EthnicityTotal = 0.12 if Ethnicity == 2
    replace EthnicityTotal = 0.06 if Ethnicity == 3
    replace EthnicityTotal = 0.11 if Ethnicity == 4
    replace EthnicityTotal = 0.08 if Ethnicity == 5

    // rake the weights using the Stata survwgt package

    survwgt rake Weight , by(Gender Age_group Ethnicity) totvars(GenderTotal AgeTotal EthnicityTotal) generate(rakedweight)

  • #2
    Would be so so grateful for help with this, if anybody is feeling generous

    Comment


    • #3
      I think you can compare your result with other command, thus verifing if it is correct. The -ipfweight- command below is from SSC.
      Code:
      ipfweight Gender Age_group Ethnicity, values(0.49 0.51 0.12 0.17 0.17 0.16 0.38 0.63 0.12 0.06 0.11 0.08) gen(ipfweight) maxiter(20)
      corr rakedweight ipfweight
      
      . corr rakedweight ipfweight
      (obs=200)
      
                   | rakedw~t ipfwei~t
      -------------+------------------
       rakedweight |   1.0000
         ipfweight |   1.0000   1.0000

      Comment


      • #4
        Thanks so much! I appreciate it immensely :-)

        Comment

        Working...
        X