The data used in this report is from the Professional Worker Career Experience Survey, which contains 756 responses.
In this report I will infer whether gender differences in mean life satisfaction are evident among working professionals.
First, I downloaded the csv file in R studio. Then I loaded the required necessary R packages. Next, I read in the csv file, took a glimpse of the data and ran a table.
## Loading required package: dplyr
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
##
## Loading required package: ggvis
## Loading required package: magrittr
glimpse(wrpf)
## Observations: 756
## Variables:
## $ gender (int) 1, 1, 0, 0, 0, 0, 1, NA, 0, 0, 1, 0, 1, 0, 1, 1, NA, 0...
## $ lifesat (int) 20, 18, 25, 7, 23, 25, 22, NA, 21, 29, 26, 26, 18, 28,...
wrpf1 <- tbl_df (wrpf)
wrpf1
## Source: local data frame [756 x 2]
##
## gender lifesat
## 1 1 20
## 2 1 18
## 3 0 25
## 4 0 7
## 5 0 23
## 6 0 25
## 7 1 22
## 8 NA NA
## 9 0 21
## 10 0 29
## .. ... ...
Next, I filtered by gender and lifesat with values greater than or equal to zero. Then I summarised the gender mean and lifesat mean, removing all missing values coded NA.
wrpf1 %>% filter(gender >= 0, lifesat >=0) %>%
summarize(tot_n=n(),mean_gend = mean(gender, na.rm=TRUE),mean_lifesat=mean(lifesat, na.rm=TRUE))
## Source: local data frame [1 x 3]
##
## tot_n mean_gend mean_lifesat
## 1 675 0.4103704 21.48444
I selected the t-test for my test statistic and set the alpha to equal 0.05. The null hypothesis is that there is no difference between gender and mean life satisfaction. The alternative is that there is a difference between gender and mean life satisfaction.
t.test(lifesat ~ gender, wrpf, var.equal=TRUE)
##
## Two Sample t-test
##
## data: lifesat by gender
## t = -1.349, df = 673, p-value = 0.1778
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -1.4704615 0.2727582
## sample estimates:
## mean in group 0 mean in group 1
## 21.23869 21.83755
The t-test did not show a signficant difference in mean of the two groups, The lifesat mean for males was 21.24, while the lifesat mean for females was 21.84, 95% CIs [0.273, 1.47], respectfully. Therefore, I would fail to reject the null hypothesis because the p-value is greater than alpha.