Announcement

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

  • estat after mean - and the role of svy

    Dear stata users,

    I recently encountered a problem with quite a simple command. I wanted to calculate the means and standard deviations over a categorial variable. Additionally, I use weighted data, so I use svy.
    My command looks like this:

    svy: mean var1, over(var2)
    estat sd


    so far so good. however, I discovered that I am getting different SD values once I alter the command into the following:

    svy: mean var1 if var2 == 0
    estat sd
    svy: mean var1 if var2 == 1
    estat sd


    It gives me the same means but more or less different SD values. However, this does not occur if I run the mean command without svy
    Hence, I suspect the interaction of estat and svy may not run properly.
    Of course, I'd like to know why this occurs. Further I would like to know which results may be more precise/ more reliable.

    Thanks for your interest in this problem.

    Jakob

  • #2
    Jakob,

    Try the following:

    Code:
    svy, subpop(if var2==0): mean var1
    estat sd
    svy, subpop(if var2==1): mean var1
    estat sd
    svy, subpop(var2): mean var1           // Should be the same as the previous command
    estat sd
    For reasons that are explained in the svy documentation, using the subpop option is required to allow svy to correctly compute the variance for the desired sub-population.

    Regards,
    Joe

    Comment


    • #3
      Thank you Joe of reminding me have a look into the svy documentation!

      Apparently I can use subpop() and over() interchangeably. At least it leads to the same results of both mean and variance. However, I should not use if qualifiers which would estimate different variances.

      Regards,
      Jakob

      Comment

      Working...
      X