1. Satisfaction Level by Attrition
t.test(hr$satisfaction_level ~ hr$left)
##
## Welch Two Sample t-test
##
## data: hr$satisfaction_level by hr$left
## t = 46.636, df = 5167, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## 0.2171815 0.2362417
## sample estimates:
## mean in group 0 mean in group 1
## 0.6668096 0.4400980
P-value interpretation: The p-value is very small
(> 2.2 x 10⁻¹⁶), therefore the difference between means of
satisfaction level by attrition status is statistically
significant.
T-test interpretation: The difference in mean
satisfaction level between employees who stayed (mean = 0.667) and those
who left (mean = 0.440) is significant, with a difference of at least
0.22.
Non-technical interpretation: Employees who left
the company were less satisfied than those who stayed.
plot_data <- hr %>% mutate(Attrition = factor(left, labels = c("Stayed", "Left")))
plot_ly(plot_data,
x = ~Attrition,
y = ~satisfaction_level,
boxmean = TRUE,
type = 'box') %>%
layout(title = "Employees Who Left Were Less Satisfied",
yaxis = list(title = "Satisfaction Level"))
2. Last Evaluation Score by Attrition
t.test(hr$last_evaluation ~ hr$left)
##
## Welch Two Sample t-test
##
## data: hr$last_evaluation by hr$left
## t = -0.72534, df = 5154.9, p-value = 0.4683
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -0.009772224 0.004493874
## sample estimates:
## mean in group 0 mean in group 1
## 0.7154734 0.7181126
P-value interpretation: The p-value is 0.4683,
which indicates that the difference between means of last evaluation
scores by attrition status is not statistically significant.
T-test interpretation: The difference in mean
evaluation scores between employees who stayed (mean = 0.715) and those
who left (mean = 0.718) is very small and not statistically
significant.
3. Average Monthly Hours by Attrition
t.test(hr$average_montly_hours ~ hr$left)
##
## Welch Two Sample t-test
##
## data: hr$average_montly_hours by hr$left
## t = -7.5323, df = 4875.1, p-value = 5.907e-14
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -10.534631 -6.183384
## sample estimates:
## mean in group 0 mean in group 1
## 199.0602 207.4192
P-value interpretation: The p-value is very small
(5.91 × 10⁻¹⁴) indicating that the difference between means of average
monthly hours by attrition status is statistically significant.
T-test interpretation: The difference in mean
monthly hours between employees who stayed (mean = 199.06) and those who
left (mean = 207.42) is significant, with a difference of at least
6.18.
Non-technical interpretation: Employees who left
the company worked more hours per month than those who stayed.
plot_ly(plot_data,
x = ~Attrition,
y = ~average_montly_hours,
boxmean = TRUE,
type = 'box') %>%
layout(title = "Employees Who Left Worked Longer Hours",
yaxis = list(title = "Average Monthly Hours"))
4. Time Spent at Company by Attrition
t.test(hr$time_spend_company ~ hr$left)
##
## Welch Two Sample t-test
##
## data: hr$time_spend_company by hr$left
## t = -22.631, df = 9625.6, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -0.5394767 -0.4534706
## sample estimates:
## mean in group 0 mean in group 1
## 3.380032 3.876505
P-value interpretation: The p-value is less than
2.2 × 10⁻¹⁶, which indicates that the difference between means of time
spent at the company by attrition status is statistically
significant.
T-test interpretation: The difference in mean time
spent at the company between employees who stayed (mean = 3.38 years)
and those who left (mean = 3.88 years) is significant, with a difference
of at least 0.45.
Non-technical interpretation: Employees who left
the company had spent more time there than those who stayed.
plot_ly(plot_data,
x = ~Attrition,
y = ~time_spend_company,
boxmean = TRUE,
type = 'box') %>%
layout(title = "Employees Who Left Had Spent More Time At Company",
yaxis = list(title = "Time Spent at Company"))