Perform the t-test (.5 point)
t.test(satisfaction_level ~ left, data = hr)
##
## Welch Two Sample t-test
##
## data: satisfaction_level by 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
Interpret the results in technical terms (.5 point)
- The p-value is very small therefore the difference between
satisfaction_level and left is significant
Interpret the results in non-technical terms (1 point)
- Employees that stayed had higher satisfaction levels than those who
left
Create a plot that helps visualize the t-test (.5 point)
plot_ly(hr, x = ~as.factor(ifelse(left == 0 , 'Stayed' , 'Left')), y = ~satisfaction_level, type = "box",
color = ~as.factor(ifelse(left == 0 , 'Stayed' , 'Left')),
colors = c('coral','skyblue')) %>%
layout(title = "Employees that stayed had higher satisfaction levels than those who left",
xaxis = list(title = "Employee Attrition"),
yaxis = list(title = "Satisfaction Level"))
Perform the t-test (.5 point)
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
Interpret the results in technical terms (.5 point)
- The p-value is not small therefore the difference between last
evaluation and left is not significant
Interpret the results in non-technical terms (1 point)
- Last evalution scores did not cause employees to leave or stay
Create a plot that helps visualize the t-test (.5 point)
plot_ly(hr, x = ~as.factor(ifelse(left == 0 , 'Stayed' , 'Left')), y = ~last_evaluation, type = "box",
color = ~as.factor(ifelse(left == 0 , 'Stayed' , 'Left')),
colors = c('coral','skyblue')) %>%
layout(title = "Last evalution did not cause Employees to leave or stay",
xaxis = list(title = "Employee Attrition"),
yaxis = list(title = "Last Evaluation Score"))
Note: I wanted to experiment with two charts (above) without mutating the left column data and two charts (below) having mutated the left column.
hr1 <- hr %>%
mutate(Employee_Attrition = ifelse(left == 0 , 'Stayed' , 'Left'))
Perform the t-test (.5 point)
t.test(hr1$average_montly_hours ~ hr1$left)
##
## Welch Two Sample t-test
##
## data: hr1$average_montly_hours by hr1$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
Interpret the results in technical terms (.5 point)
- The p-value is very small therefore the difference between average
monthly hours and left is significant
Interpret the results in non-technical terms (1 point)
- Employees that left worked more average monthly hours (at least 6 more
hours)
Create a plot that helps visualize the t-test (.5 point)
plot_ly(hr1, x = ~Employee_Attrition, y = ~average_montly_hours, type = "box",
color = ~Employee_Attrition,
colors = c('coral','skyblue')) %>%
layout(title = "Employees that left worked more average monthly
hours (at least 6 more hours)",
xaxis = list(title = "Employee Attrition"),
yaxis = list(title = "Average Monthly Hours"))
Perform the t-test (.5 point)
t.test(hr1$number_project ~ hr1$left)
##
## Welch Two Sample t-test
##
## data: hr1$number_project by hr1$left
## t = -2.1663, df = 4236.5, p-value = 0.03034
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
## -0.131136535 -0.006540119
## sample estimates:
## mean in group 0 mean in group 1
## 3.786664 3.855503
Interpret the results in technical terms (.5 point)
- The p-value is not small therefore the difference between number of
projects and left is not significant
Interpret the results in non-technical terms (1 point)
- The number of projects employees work does not cause them to
leave
Create a plot that helps visualize the t-test (.5 point)
plot_ly(hr1, x = ~Employee_Attrition, y = ~number_project, type = "box",
color = ~Employee_Attrition,
colors = c('coral','skyblue')) %>%
layout(title = "The number of projects employees work does not cause them to leave",
xaxis = list(title = "Employee Attrition"),
yaxis = list(title = "Number of Projects"))