The employeenumeric dataset has 474 rows and 5 columns.
The data includes the variables Gender, Current Salary, Years of Education, Minority Classification, and Date of Birth.
# Filter for individuals with 15 years of education
employeenumeric_15edu <- employeenumeric[employeenumeric$`Years of Education` == 15, ]
The dimensions of the new data set are 116 rows by 5 columns.
# attach the data frame to call variables within it directly
attach(employeenumeric_15edu)
# t test
t.test(`Current Salary`[Gender == "m"], `Current Salary`[Gender == "f"])
##
## Welch Two Sample t-test
##
## data: `Current Salary`[Gender == "m"] and `Current Salary`[Gender == "f"]
## t = 5.0443, df = 102.38, p-value = 1.977e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 3930.779 9024.884
## sample estimates:
## mean of x mean of y
## 33527.83 27050.00
The null hypothesis is that there is no relationship between salary and gender.
Higher education generally associated with higher salaries. By filtering for people of the same education level, it can help isolate the other factors (gender, minority status) that might be influencing salary differences.
The t-statistic for the difference in salaries between men and women with 15 years of education is 5.0443.
The p-value is 1.977e-06.
The limits of the 95% CI are 3930.779 and 9024.884.
The 95% CI does not include the value 0.
The mean salary for men with 15 years of education is 33,527.83; for women it is 27,050.00.
Based on the results of my t-test, I reject the null hypothesis that there is no relationship between gender and salary. There is a statistically significant difference in average salary between men and women in the sample.
# t test using another formula
t.test(`Current Salary` ~ `Minority Classification`, data = employeenumeric_15edu)
##
## Welch Two Sample t-test
##
## data: Current Salary by Minority Classification
## t = 2.4432, df = 59.458, p-value = 0.01755
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## 664.4916 6673.2519
## sample estimates:
## mean in group 0 mean in group 1
## 32507.33 28838.46
The t-statistic for the difference in salaries between minority and non-minority respondents with 15 years of education is 2.4432.
The p-value is 0.017755.
The limits of the 95% CI are 664.4916 and 6673.2519.
The 95% CI does not contain the value 0.
The mean salaries for minorities are 28,838.46; for non-minorities it is 32,507.33.
Based on the results of my t-test, I reject the null hypothesis that there is no relationship between minority status and salary. There is a statistically significant difference in average salary between minorities and non-minorities in the sample.
# filter for men with 15 years of education
men_only <- employeenumeric_15edu[employeenumeric_15edu$Gender == "m", ]
# run t test
t.test(`Current Salary` ~ `Minority Classification`, data = men_only)
##
## Welch Two Sample t-test
##
## data: Current Salary by Minority Classification
## t = 2.4005, df = 40.643, p-value = 0.02104
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## 702.7293 8164.9289
## sample estimates:
## mean in group 0 mean in group 1
## 34489.38 30055.56
With a p-value of 0.02104, there is a statistically significant difference in average salary between minority and non-minority men in the sample.
# filter for women with 15 years of education
women_only <- employeenumeric_15edu[employeenumeric_15edu$Gender == "f", ]
# run t test
t.test(`Current Salary` ~ `Minority Classification`, data = women_only)
##
## Welch Two Sample t-test
##
## data: Current Salary by Minority Classification
## t = 0.62398, df = 11.646, p-value = 0.5447
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -3139.546 5647.546
## sample estimates:
## mean in group 0 mean in group 1
## 27354 26100
With a p-value of 0.5447, there is NO statistically significant difference in average salary between minority and non-minority men in the sample.
| Mean Salaries | Male | Female |
|---|---|---|
| Non-Minority | 34489.38 | 27354 |
| Minority | 30055.56 | 26100 |
interaction.plot(Gender, `Minority Classification`, `Current Salary`)
This plot shows how sex and minority status influence mean salaries among people with 15 years of education. It indicates that salaries among women, regardless of minority status, are lower on average (and more homogenous) than men’s salaries, including minority men. The slope of the lines also reveals how non-minority men experience much greater increases in salary than minority men.