Announcement

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

  • Calculating weighted means by country and year

    I use the accumulated dataset from the European Social Survey (ESS) for the waves 1 to 5 and appended the data from wave 6. I'm trying to calculate means for the variable trstprl (Trust in country's parliament). My goal is to get weighted means for every country in my dataset for every wave. The ESS dataset contains two weight-variables, dweight and pweight.
    dweight is labelled as design weight (Quoting from the instruction on the weighting variables: "The main purpose of the design weights is to correct for the fact that in some countries respondents have different probabilities to be part of the sample due to the sampling design used"), the other one is pweight ("The main purpose of the design weights is to correct for the fact that in some countries respondents have different probabilities to be part of the sample due to the sampling design used")

    I looked at another post in this forum that was already of great help. According to that example, I constructed a loop. So to calculate weighted means I constructed a loop where the means are calculated by using dweight that looks as follows:

    gen trst = .
    forvalues i = 1/6 {
    levelsof cntry, local(levels)
    foreach j of local levels {
    sum trstprl [pweight = dweight] if cntry == "`j'" && essround == `i', detail
    replace trst = r(mean) if cntry == "`j'" && essround == `i'
    }
    }

    When executing this loop I always get the following error message:
    pweight not allowed
    r(101)

    If I use weight instead of pweight in the loop it executes without error message . However, Stata then assumes analytic weights which are, if I am not mistaken, not correct for this purpose.
    Any suggestions?

    I am using Stata 12.1 on a MacBook operating on Mac OS X 10.9.2 (Mavericks).

  • #2
    I think that the ESS dweights are what Stata would call pweights. The pweights in ESS are population weights that would be used if you were analyzing data from more than one country combined.

    Why not use mean instead of summ?

    Comment


    • #3
      Sorry, that was meant to be a link to this:
      http://www.europeansocialsurvey.org/...hting_data.pdf

      Comment


      • #4
        Thank you very much for your suggestion.
        I am using the expression pweight = dweight in the loop to weigh the data. Hence, I use the ESS' dweight variable and assign it as pweight in Stata. I agree with you that ESS dweight is to be used as Stata's pweight (the variable names in ESS that are similar to Stata's commands are a bit confusing...). But Stata won't allow me to use pweight in this loop. The combination of sum with [pweight = ...] doesn't seem to work in this case.
        According to your advice, I now use mean and made a new loop that looks like this: gen trst = .
        forvalues i = 1/6 {
        levelsof cntry, local(levels)
        foreach j of local levels {
        capture mean trstprl [pw = dweight] if cntry == "`j'" && essround == `i'
        capture mat b = e(b)
        capture replace trst = b[1,1] if cntry == "`j'" && essround == `i'
        }
        }
        Because I don't have data for every country and wave I had to add the capture command so the loops doesn't stop executing.
        Anyway, thanks for your help.

        Comment


        • #5
          Hi Roman,
          I dont think you will have anyproblems using simple aweights or fweights in your data. The calculation of the simple mean would be the same regardless of which "weighting" strategy you use. The choice of either one is relevant when you are trying to make inferences on the data (aka estimating standard deviations, regressions, etc).
          Hope this helps.
          Fernando

          Comment


          • #6
            Thank you very much Fernando for your suggestion.
            I wanna compare the calculated means across different institutions and between different countries and hence calculate standard deviations as well to in fact draw inference. That's why I wanna pay attention right from the beginning to use the right command and also correct weights.

            Comment


            • #7
              Fernando noted -
              Originally posted by FernandoRios View Post
              Hi Roman,
              I dont think you will have anyproblems using simple aweights or fweights in your data. The calculation of the simple mean would be the same regardless of which "weighting" strategy you use. The choice of either one is relevant when you are trying to make inferences on the data (aka estimating standard deviations, regressions, etc).
              Hope this helps.
              Fernando

              What if you were not doing a simple mean but a multivariate analysis? Could you still use the aweights since stata doesn't allow the pweight?

              Secondly, I've seen a few posts noting issues with using ESS dweight as a pweight - Roman's post here as well as this one from 2006: st: Weighted Tables, David Lublin (Thu Feb 23 10:40:27 2006). Is there a consensus on what to do about Stata refusing to let you use dweight as a pweight?

              Kind regards and thanks for all your helpful posts!

              Comment

              Working...
              X