Announcement

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

  • Tabulate With Weights In Stata

    I have a variable "education" which is 3-level and ordinal and I have a binary variable "urban" which equals to '1' if the individual is in urban area or '0' if they are not. I also have sample weights in a variable "sampleWeights" to scale my data up to a full county level-these weight values are provided by the study investigators.

    I wish to do a chisq2 test to see if the education distribution is different for urban vs non-urban and do this at the county level using the weights.

    Now to do this without using 'sampleWeights' I can do this:
    Code:
     
     tabulate education urban, chi2 
    However I am wondering, how can I incorporate these weights which are 'pweights' ?

  • #2
    Code:
    svyset [pweight = my_weight_variable]
    svy: tab education urban
    (You will get the chi square automatically here.)

    Comment


    • #3
      Why doesn't the tabulate command allow weight when we want it to give chi2?

      Comment


      • #4
        But it does. Frequency weights are allowed. Analytic weights would make no sense, as the chi-square test requires integer inputs.

        Comment


        • #5
          Thank you Nick Cox.

          Comment


          • #6
            A short note for my question in #3
            a response from Senior DHS Stata Specialist, Tom Pullum: My rule is to always use pweight if it is accepted. Unfortunately there are some commands in Stata, such as tabulate and summarize, that will not accept pweight. Those commands will accept iweights, and for them I will use, say, iweight=v005/1000000. The division by 1,000,000 will give weights with an average value of 1. But if you want to use tabulate with an option such as chi2, you can't. Even if you use svyset and pweight, you cannot do tabulate and chi2. So far as I know, virtually all of the estimation commands will accept pweights. (There are some esoteric exceptions and I expect them to evolve to accept pweights in the future.)
            Link is here: https://userforum.dhsprogram.com/ind...13156&S=Google

            Comment

            Working...
            X