HR Analysis Using R

HR Analysis Using R

Project Overview:

This project explores the factors influencing employee attrition using the dataset HR-Employee-Attrition.csv. The goal was to identify patterns and statistical relationships between demographic, work-related, and income variables, and to assess their impact on attrition.

Objectives:

  • Understand the relationships between key HR variables such as Age, Monthly Income, Total Working Years, and Education.
  • Investigate differences between employees who left (Attrition = Yes) and those who stayed.
  • Build simple predictive models to estimate Monthly Income based on demographic and work history factors.

Data Import & Exploration

The dataset was loaded into R using:

Article content

To gain an initial understanding of relationships between continuous variables, a correlation matrix was computed:

Article content
Article content

Key Insight:

  • Monthly Income had a strong positive correlation with Age and Total Working Years.
  • Education level showed weaker correlation with income compared to experience-based factors.


Data Visualization:

Scatterplot Matrix

Article content

This visualization revealed:

  • Monthly Income increased noticeably with Total Working Years.
  • Age and Total Working Years were strongly related, indicating natural career progression trends.

Article content

Boxplot: Age vs. Attrition


Article content

Observation:

  • Employees who left tended to be younger on average.


Article content

Statistical Testing

T-Test: Age and Attrition


Article content

Result:

  • The difference in mean age between employees who left and those who stayed was statistically significant (p-value < 0.05).
  • Suggests that younger employees were more likely to leave.


Article content

T-Test: Employee Number and Attrition


Article content

While EmployeeNumber is an ID field and not inherently meaningful, the test was run to confirm no systematic bias in ID assignment related to attrition. No significant difference was found.


Article content

Regression Modeling

Model 1: Monthly Income ~ Age


Article content

  • Positive relationship: Monthly Income tended to increase with Age.
  • However, Age alone explained only a moderate portion of income variance.


Article content

Model 2: Monthly Income ~ Age + Total Working Years


Article content

  • Adding Total Working Years significantly improved model fit (higher R²).
  • This confirms that experience is a stronger predictor of income than age alone.


Article content

Key Insights & Conclusions

  1. Younger employees were more likely to leave the company.
  2. Total Working Years had the strongest relationship with Monthly Income.
  3. Age and Total Working Years were correlated, but experience provided more explanatory power for salary prediction.
  4. Education had less impact on income compared to tenure-related factors in this dataset.


Thank you for taking the time to review my work. If you have any questions, please don’t hesitate to reach out. I would also greatly appreciate it if you could share any relevant job opportunities, or connect me with others who may be looking for a data analytics professional.

To view or add a comment, sign in

More articles by Kerwin Ramirez

Explore content categories