Announcement

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

  • Is it possible to do a weighted t-test with a compact display of the results?

    Dear all,

    I am trying to compare the averages of a large number of variables. I use the t-test command to look at their significance. Unfortunately, the t-test does not allow to indicate weights, which would be necessary in my case.
    As I am trying to compare a large number of variable averages with each other which would make a compact display of the averages as well as the t-test result necessary.

    I am currently using this code, there are many more variables in my var list, this is a shortened version for the example. I am quite happy with the way it is displayed, however I am not able it add my survey weights here. Is there a way to do that that I am not aware of?

    foreach var of varlist var1 var2 {
    asdoc ttest var3, by(`var'), rowappend save(try)


    I have considered simply using the reg command, which might be difficult given that the numbers I am working with in some of the variables are rather small sometimes. I am also not sure how those results could be displayed in a concise manner.

    Manny thanks for any help,
    Elinor

  • #2
    I have considered simply using the reg command, which might be difficult given that the numbers I am working with in some of the variables are rather small sometimes.
    -ttest var1, by(var2)- is equivalent in all respects to -regress var1 i.var2-. So I don't understand what your concern is. If your sample size is too small to do a meaningful regression, then it is also too small for a meaningful application of the t-test. And the same may be said of any reservation you might have about the suitability of regression: it will always apply in equal force to the t-test.

    Since -regress- has the added flexibility to allow weights, you should use it. Also, with survey data, it is not sufficient to just apply the survey weights. You must also account for sampling units and stratification if those were part of the survey design in order to get correct standard errors, confidence intervals, and test statistics. So -svyset- your data properly, and then use the -svy:- prefix with your -regress- command to get valid results.

    Comment

    Working...
    X