Portion of Employees who Stayed or Left by Department

chisq.test(hr1$Department, hr1$Employee_Status)
## 
##  Pearson's Chi-squared test
## 
## data:  hr1$Department and hr1$Employee_Status
## X-squared = 86.825, df = 9, p-value = 7.042e-15

Interpreting the results in technical term: Since the p-value is below 0.05, we can conclude that there is a considerable relationship between department and employee status, which allows us to reject the idea of the null hypothesis. However, the percentage of employees leaving may vary by department, indicating the possibility of a stronger correlation between specific departments and employee turnover.

Non-Technical terms: Depending on the department where employees stay could relate to them leaving or staying at the company.

Chi-sqare Test Visual: Departments

prop_data <- hr1 %>%
  group_by(Department) %>%
  summarise(
    Stayed = sum(Employee_Status == "Stayed") / n(),
    Left = sum(Employee_Status == "Left") / n()
  )

# Create stacked bar chart
plot_ly(prop_data) %>%
  add_bars(x = ~Department, y = ~Stayed, name = "Stayed", 
           marker = list(color = "#1f77b4")) %>%
  add_bars(x = ~Department, y = ~Left, name = "Left", 
           marker = list(color = "#ff7f0e")) %>%
  layout(
    barmode = "stack",
    xaxis = list(title = "Department"),
    yaxis = list(title = "Proportion", tickformat = ",.0%"),
    title = "Proportion of Employees Who Stayed or Left by Department"
    
  )

Portion of Employees who Left or Stayed from Work accident

chisq.test(hr1$Work_accident, hr1$Employee_Status)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  hr1$Work_accident and hr1$Employee_Status
## X-squared = 357.56, df = 1, p-value < 2.2e-16

Interpreting results in technical terms: terms: Since the p-value is under 0.05, we can reject the null hypothesis. This indicates that there is a significant relationship between work accidents and employee status, meaning employees who experience a work accident are more likely to leave the company.

Non-Technical Interpretation:There is a significant statistical correlation between being involved in a work accident and the probability of an employee leaving the company.

Chi-sqare Test Visual: Work Accident

prop_data <- hr1 %>%
  group_by(Work_accident) %>%
  summarise(
    Stayed = sum(Employee_Status == "Stayed") / n(),
    Left = sum(Employee_Status == "Left") / n()
  )

plot_ly(prop_data) %>%
  add_bars(x = ~Work_accident, y = ~Stayed, name = "Stayed",
           marker = list(color = "#1f77b4")) %>%
  add_bars(x = ~Work_accident, y = ~Left, name = "Left",
           marker = list(color = "#ff7f0e")) %>%
  layout(
    barmode = "stack",
    xaxis = list(title = "Work Accident"),
    yaxis = list(title = "Proportion", tickformat = ",.0%"),
    title = "Proportion of Employees Who Stayed or Left by Work Accident"
  )

Portion of employees who stayed and Left by Salary

chisq.test(hr1$salary, hr1$Employee_Status)
## 
##  Pearson's Chi-squared test
## 
## data:  hr1$salary and hr1$Employee_Status
## X-squared = 381.23, df = 2, p-value < 2.2e-16

Interpreting in Technical terms: Since the p-value is under 0.05, we can reject the null hypothesis, which states that salary and employee status are independent of each other (No relationship). By rejecting the null hypothesis, we know that there is a strong statistical relationship between employees’ status and salary. This implies that salary can influence an employee’s decision to stay with or leave the company.

Non-Technical Interpretation: Salary can impact whether an employee decides to stay or leave the company.

Chi-sqare Test Visual: Salary

prop_data <- hr1 %>%
  group_by(salary) %>%
  summarise(
    Stayed = sum(Employee_Status == "Stayed") / n(),
    Left = sum(Employee_Status == "Left") / n()
  )


plot_ly(prop_data) %>%
  add_bars(x = ~salary, y = ~Stayed, name = "Stayed",
           marker = list(color = "#1f77b4")) %>%
  add_bars(x = ~salary, y = ~Left, name = "Left",
           marker = list(color = "#ff7f0e")) %>%
  layout(
    barmode = "stack",
    xaxis = list(title = "Salary"),
    yaxis = list(title = "Proportion", tickformat = ",.0%"),
    title = "Proportion of Employees Who Stayed or Left by Salary"
  )

Portion of employees who stayed and Left due to Promotion

chisq.test(hr1$promotion_last_5years, hr1$Employee_Status)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  hr1$promotion_last_5years and hr1$Employee_Status
## X-squared = 56.262, df = 1, p-value = 6.344e-14

Interpreting in Technical terms:Since the Chi Square Test produces a very small p-value, we can reject the null hypothesis. This means there is a strong significant relationship between project involvement over the last 5 years and employee status. Especially, employees who have not been assigned to any projects in the last 5 years are more likely to leave then stay.

Non-Technical: Employees who do not receive projects within the last 5 years are more likely to leave the company compared to those who have had projects.

Chi-sqare Test Visual: Project

prop_data <- hr1 %>%
  group_by(promotion_last_5years) %>%
  summarise(
    Stayed = sum(Employee_Status == "Stayed") / n(),
    Left = sum(Employee_Status == "Left") / n()
  )


plot_ly(prop_data) %>%
  add_bars(x = ~promotion_last_5years, y = ~Stayed, name = "Stayed",
           marker = list(color = "#1f77b4")) %>%
  add_bars(x = ~promotion_last_5years, y = ~Left, name = "Left",
           marker = list(color = "#ff7f0e")) %>%
  layout(
    barmode = "stack",
    xaxis = list(title = "Promotions in the Last 5 Years"),
    yaxis = list(title = "Proportion", tickformat = ",.0%"),
    title = "Proportion of Employees Who Stayed or Left Based on Promotions in the Last 5 Years"
  )