0
$\begingroup$

I have a large set of weighted data. I have loaded it into a survey design and would now like to run t-tests on sub-populations.

example:

DF<-cbind(ID, WEIGHT, GENDER, INCOME)

     ID WEIGHT GENDER RELOCATE INCOME
[1,]  1   4380      1        1     35
[2,]  2   5000      1        1     20
[3,]  3      0      0        1     55
[4,]  4   5640      1        0     60
[5,]  5   6120      0        1     25

example.survey<-svydesign(ids=~0, data=DF, weights=WEIGHT)

I am able to call the mean income for the entire sample by:

svymean(INCOME, example.survey)

       mean    SE
[1,] 35.227 9.043

However, I want to compare the means for a subpopulation of this sample so that I can maintain the proper weights.

Can you confirm that this is the proper syntax to run a t-test comparing the mean INCOME based on GENDER for those who relocated (RELOCATE==1)?

svyttest(INCOME~GENDER+RELOCATE==1, example.survey)

data:  INCOME ~ GENDER + RELOCATE == 1
t = 0.9841, df = 2, p-value = 0.4288
alternative hypothesis: true difference in mean is not equal to 0
sample estimates:
difference in mean 
          14.78145 
$\endgroup$
2
$\begingroup$

you want

svyttest( INCOME ~ GENDER , subset( example.survey , RELOCATE == 1 ) )
| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.