Suppose I have an X vector (for simplicity containing 3 age categories and a male dummy) and a group dummy ("foreign"). I would like to test the following:
Here's a minimal working example that prepares a fake dataset and preforms the first type of tests mentioned above (but without correcting for multiple hypotheses):
Thanks for any comments on this.
- whether the mean of each x variable is different for the foreign=0 and foreign=1 people.
- a joint test on whether the mean at least one of the x variables is different for the foreign=0 and foreign=1 people.
Here's a minimal working example that prepares a fake dataset and preforms the first type of tests mentioned above (but without correcting for multiple hypotheses):
Code:
set more off
sysuse auto, clear
// Create fake discrete variables
* Age group
gen age_group = rep78
recode age_group 4=1 5=2 .=1
assert inlist(age_group, 1, 2, 3)
* Male
gen male = gear_ratio
recode male 0/2.5=0 2.5/.=1
assert inlist(male, 0, 1)
// T-tests "X = foreign" (not corrected for multiple testing)
ttest male, by(foreign) unequal
tab age_group, gen(age_group_)
foreach c in age_group_1 age_group_2 age_group_3 {
ttest `c', by(foreign) unequal
}

Comment