peopleanalyst

library / libe17bb73cf1daee15

Using R in HR Analytics A practical guide to analysing people data

Martin Edwards, Kirsten Edwards .

In a sentence

A practical, hands-on guide to applying inferential and predictive statistical techniques to human resources data using the open-source R programming language.

Using R in HR Analytics bridges the gap between data science and human resources by teaching HR professionals, students, and management-information teams how to move beyond descriptive reporting toward rigorous predictive analytics. Built on the foundation of the authors' earlier SPSS-based text, this R edition walks readers through the entire analytic journey: understanding HR information systems and data types, importing and manipulating data in R, choosing the correct statistical test, and applying techniques such as chi-square, t-tests, ANOVA, multiple and logistic regression, factor and reliability analysis, and survival analysis. Through six detailed case studies — diversity, engagement, turnover, performance, recruitment/selection, and intervention monitoring — plus chapters on scenario modelling, advanced methods (mediation, moderation, multilevel models, machine learning), and ethics, the book equips readers to diagnose causal drivers of key HR outcomes, predict future behaviour, build evidence-based business cases, and persuade leadership with 'hard' evidence while remaining alert to the limitations and ethical responsibilities of working with people data.

The four lenses

  • Science
  • Statistics
  • Systems
  • Strategy

Tags

f1-strategy

The model

An inferred factor model expressing how organizational design levers and contextual conditions influence psychological and perceptual states and behavioural patterns, which in turn drive key HR outcome metrics such as engagement, turnover, performance and diversity representation. The book operationalizes this through statistical tests selected by variable type.

HR Intervention and Design Leversdesign lever

Deliberate organizational actions and programmes such as training courses, induction/onboarding days, work-life balance programmes, value-change events and supportive HR policies that management introduces to influence employee states and outcomes.

Contextual and Structural Conditionscontextual condition

Relatively stable contextual and structural features of the work environment including function/department, geographic location, team size, gender composition, group diversity composition and country, which form the backdrop against which states and behaviours occur.

Individual Attributes and Capabilitiescontextual condition

Demographic and capability characteristics of individuals such as gender, age, tenure, education, disability status, personality scores, competency ratings and aptitude test scores that are used as predictors of behavioural and outcome variables.

Psychological and Perceptual Statespsychological state

Employees' internal attitudes, perceptions and affective-cognitive states including engagement, job satisfaction, perceived organizational support, perceptions of justice, job strain, person-organization fit, organizational commitment and customer satisfaction perceptions, often measured by multi-item survey scales.

Behavioural and Discretionary Patternsbehavioral pattern

Observable employee behaviours and discretionary effort including organizational citizenship behaviour, intention to leave, discretionary effort, and value-consistent behaviour that lie between internal states and hard outcome metrics.

Key HR Outcome Metricsoutcome metric

The tangible, often archival or behavioural performance indicators the organization seeks to influence, including employee turnover/separation rate, individual and team performance (appraisal ratings, scan rates, sales, customer loyalty/reinvestment), sickness absence, length of service, recruitment outcomes and diversity representation levels.

How they connect

  • hr intervention design influences psychological perceptual states
  • hr intervention design predicts hr outcome metrics
  • individual attributes predicts hr outcome metrics
  • psychological perceptual states predicts behavioural patterns
  • psychological perceptual states predicts hr outcome metrics
  • behavioural patterns predicts hr outcome metrics
  • psychological perceptual states mediates hr outcome metrics
  • contextual conditions moderates hr outcome metrics
  • contextual conditions correlates individual attributes

The process

The book provides a comprehensive playbook for HR professionals to transition from descriptive reporting to predictive analytics using the R programming language. The overall process begins with the foundational step of gathering, cleaning, and structuring disparate HR data sources into a single, analyzable format within the R environment. Once the data is prepared, the practitioner follows a systematic method to select the appropriate statistical test based on the specific business question and the nature of the variables involved. For analyses involving survey data, a distinct process of construct validation using factor and reliability analysis is employed to ensure the integrity of the measures. The core of the playbook involves executing the chosen statistical analysis—be it regression, ANOVA, t-tests, or chi-square—to identify significant relationships and build predictive models. This step is about uncovering the 'why' behind HR metrics like turnover, performance, and engagement. The final, and most critical, phase of the playbook is translating these statistical models into tangible business value. This involves using the model outputs for scenario planning, building data-driven business cases for HR interventions, and making evidence-based predictions to support strategic decisions in areas like recruitment and talent management. Together, these processes form a cycle of inquiry, analysis, and application that empowers the HR function to become a more strategic and persuasive partner to the business.

Data Preparation for Analysis in R

To consolidate, clean, and structure HR data from various sources (e.g., HRIS, surveys, spreadsheets) into a single, analyzable dataframe within the R environment.

When to use: At the beginning of any HR analytics project, before any statistical analysis can be performed.

  1. Step 1Identify and locate all relevant data sources.

    Entry: A business question has been defined that requires data analysis.

    Exit: All potential data sources have been identified and accessed.

    In: Business question · Out: List of required data sources

  2. Step 2Set up the R and RStudio environment.

    Entry: Data sources have been located.

    Exit: The R environment is ready for data import.

    Out: Configured R environment

  3. Step 3Import data from source files into R dataframes.

    Entry: R environment is set up.

    Exit: All source data is loaded into separate R dataframes.

    In: Source data files (e.g., .xlsx, .csv) · Out: R dataframes

  4. Step 4Clean and recode variables for analysis.

    Entry: Data is imported into R.

    Exit: Variables are in a consistent and analyzable format.

    • How to handle missing data (e.g., omit, impute).
    • Which variables need to be recoded or transformed.

    In: Raw R dataframes · Out: Cleaned and recoded R dataframes

  5. Step 5Merge multiple dataframes into a single dataset.

    Entry: All dataframes are cleaned and contain a common identifier.

    Exit: A single, comprehensive dataframe for analysis is created.

    In: Cleaned R dataframes, Unique identifier key · Out: Merged R dataframe

  6. Step 6Save the prepared dataframe.

    Entry: Data has been successfully merged.

    Exit: The prepared data is saved as a new file.

    In: Merged R dataframe · Out: Cleaned data file (e.g., .csv)

Select Statistical Analysis Method

To systematically determine the most appropriate statistical test to answer a specific business question based on the types of data being analyzed.

When to use: After data has been prepared but before any primary analysis is conducted.

  1. Step 1Clearly define the research question or hypothesis.

    Entry: A prepared dataset is available.

    Exit: A specific, answerable research question is formulated.

    In: Business problem · Out: Research question/hypothesis

  2. Step 2Identify the dependent (DV) and independent (IV) variables.

    Entry: Research question is formulated.

    Exit: DV and IV(s) are clearly identified.

    In: Research question · Out: List of DV and IVs

  3. Step 3Determine the data type of each variable.

    Entry: DV and IVs are identified.

    Exit: All relevant variables have been classified by data type.

    In: List of DV and IVs, Data dictionary · Out: Classified list of variables

  4. Step 4Select the appropriate statistical test using a decision framework.

    Entry: All variables are classified by data type.

    Exit: The correct statistical test has been chosen.

    • If DV is categorical and IVs are mixed -> Logistic Regression
    • If DV is continuous and IV is categorical with 3+ groups -> One-Way ANOVA
    • If DV is continuous and IVs are continuous/mixed -> Multiple Linear Regression

    In: Classified list of variables · Out: Name of the selected statistical test

Validate Survey Constructs

To statistically verify that a set of survey questions (indicators) accurately and consistently measures the intended underlying concept (latent construct), such as 'employee engagement' or 'job satisfaction'.

When to use: After collecting survey data and before using composite scores from multi-item scales in predictive models.

  1. Step 1Isolate the set of survey items intended to measure a single construct.

    Entry: Raw survey data is available in a prepared R dataframe.

    Exit: A dataframe containing only the items for the target construct is created.

    In: Prepared survey data · Out: Subsetted dataframe of survey items

  2. Step 2Determine the optimal number of underlying factors.

    Entry: Survey item data is isolated.

    Exit: A recommended number of factors is identified.

    In: Subsetted dataframe of survey items · Out: Optimal number of factors

  3. Step 3Perform an Exploratory Factor Analysis (EFA) or Principal Component Analysis (PCA).

    Entry: Optimal number of factors is determined.

    Exit: Factor loading matrix is generated.

    • Choose an appropriate rotation method (e.g., 'oblimin' if factors are expected to be correlated).

    In: Subsetted dataframe of survey items, Optimal number of factors · Out: Factor analysis output with factor loadings

  4. Step 4Evaluate the factor loadings.

    Entry: Factor analysis is complete.

    Exit: A decision is made on which items belong to which construct.

    In: Factor loading matrix · Out: Validated grouping of items per construct

  5. Step 5Conduct a reliability analysis for each validated construct.

    Entry: Items have been grouped into constructs.

    Exit: Cronbach's alpha is calculated for each construct.

    In: Validated grouping of items per construct · Out: Cronbach's alpha value

  6. Step 6Assess the internal consistency of the scale.

    Entry: Cronbach's alpha is calculated.

    Exit: The reliability of the survey scale is confirmed or rejected.

    • If alpha is low, consider removing items that the analysis suggests are reducing reliability.

    In: Cronbach's alpha value · Out: A validated and reliable multi-item scale

Conduct Statistical Analysis in R

To execute a chosen statistical test on prepared data using R, interpret the output to assess significance and effect, and draw a conclusion to answer the research question.

When to use: After data has been prepared and an appropriate statistical method has been selected.

  1. Step 1Load the prepared data and required R packages.

    Entry: A clean dataset and a selected statistical test are ready.

    Exit: R environment is prepared for analysis.

    In: Cleaned data file, Name of selected statistical test · Out: Loaded R dataframe

  2. Step 2Write and execute the R code for the statistical test.

    Entry: R environment is prepared.

    Exit: The statistical test has been run and output is generated in the R console.

    In: Loaded R dataframe, Formula specifying DV and IVs · Out: Statistical model output

  3. Step 3Interpret the primary output for statistical significance.

    Entry: Statistical output is generated.

    Exit: A determination of statistical significance is made.

    • Is p < 0.05?

    In: Statistical model output · Out: Significance determination

  4. Step 4Examine model fit and effect size statistics.

    Entry: Significance has been determined.

    Exit: The practical importance and direction of the findings are understood.

    In: Statistical model output · Out: Interpretation of effect size and direction

  5. Step 5Check for violations of statistical assumptions.

    Entry: Primary analysis is complete.

    Exit: The robustness of the statistical results is confirmed.

    • Is Levene's test significant? If yes, use Welch's test.
    • Is Mauchly's test for sphericity significant? If yes, use Greenhouse-Geisser correction.

    In: Statistical model output · Out: Confirmation of assumption validity

  6. Step 6Conduct post-hoc tests if necessary.

    Entry: A significant ANOVA result with 3+ groups is found.

    Exit: Specific group differences are identified.

    In: Significant ANOVA output · Out: Post-hoc test results

  7. Step 7Formulate a conclusion in plain language.

    Entry: All statistical interpretation is complete.

    Exit: An actionable insight is generated.

    In: Full set of interpreted statistical results · Out: Plain-language summary of findings

Translate Analytic Models into Business Applications

To convert the statistical outputs from predictive models (primarily regression) into actionable business insights, quantifiable scenarios, and evidence-based recommendations for decision-making.

When to use: When a predictive model is finalized and the goal is to demonstrate its business value or use it for decision support.

  1. Step 1Extract the final, unstandardized regression equation from the model output.

    Entry: A significant predictive regression model has been finalized.

    Exit: The full regression equation is written out.

    In: Final regression model output · Out: Unstandardized regression equation

  2. Step 2Establish a baseline prediction.

    Entry: Regression equation is available.

    Exit: A baseline predicted value for the outcome variable is calculated.

    In: Regression equation, Descriptive statistics (means) of IVs · Out: Baseline predicted outcome

  3. Step 3Model 'what-if' scenarios by adjusting key variables.

    Entry: Baseline prediction is established.

    Exit: One or more hypothetical scenarios are defined.

    In: Regression equation, Identified significant drivers · Out: Defined 'what-if' scenarios

  4. Step 4Calculate the new predicted outcome for each scenario.

    Entry: Scenarios are defined.

    Exit: A new predicted outcome value is calculated for each scenario.

    In: Regression equation, Scenario values for IVs · Out: Scenario-based predicted outcomes

  5. Step 5Quantify the business impact of the change.

    Entry: Baseline and scenario predictions are calculated.

    Exit: The potential ROI or business impact of an intervention is quantified.

    In: Baseline predicted outcome, Scenario-based predicted outcomes, Relevant business metrics (e.g., average cost of turnover, revenue per employee) · Out: Quantified business impact (e.g., '$X in potential cost savings')

  6. Step 6Generate predictions for new individual cases.

    Entry: A finalized model and data for new individuals are available.

    Exit: Predicted outcomes (e.g., expected performance, probability of leaving) are generated for new cases.

    In: Finalized regression model, Data for new individuals · Out: Individual-level predictions

A candidate measure

Using R in HR Analytics A practical guide to analysing people data — derived measurement candidates

HR Intervention and Design Levers

Training participation flag; Induction attendance flag; Onboarding buddy assignment; Pre/post intervention period indicator

self-report suitability: low

Contextual and Structural Conditions

Function/department code; Country/location code; Team headcount; Percentage male; Percentage underrepresented group; Number of team leads

self-report suitability: low

Individual Attributes and Capabilities

Gender, age, tenure, education, disability status; Personality percentile scores (OCEAN); Numerical and verbal aptitude scores; Competency ratings (1-5)

self-report suitability: medium

Psychological and Perceptual States

Multi-item Likert scale composites; Percentage of team answering favourably; Engagement index; Customer satisfaction scores

self-report suitability: high

Behavioural and Discretionary Patterns

OCB/discretionary effort scale; Value commitment composite; Intention to leave scale

self-report suitability: high

Key HR Outcome Metrics

Leaver/stayer flag and separation percentage; Performance appraisal rating; Items scanned per minute; Sales/reinvestment figures; Sickness absence days; Years of service; Recruitment stage flags; Diversity percentages

self-report suitability: low

Run the assessment

The story

The reader An HR professional, student, or management-information analyst who wants to become a credible, data-literate, high-performing contributor able to predict and influence key people outcomes.

External problem

They process vast amounts of people-related data but lack the statistical skills to move beyond descriptive reports to predictive, causal insight.

Internal problem

They feel intimidated by statistics, fear being asked 'So what?' in the boardroom, and worry their analysis will be dismissed as coincidence.

Philosophical problem

It is just plain wrong for HR decisions about people to rest on gut instinct and bias when rigorous, evidence-based analytic methods are available and affordable.

The plan

  1. Understand your organization's data sources, systems and data types.
  2. Learn R and how to import, manipulate and merge people data.
  3. Use the analysis-strategy reference to select the correct statistical test.
  4. Work through the six case studies applying tests to real-style HR data.
  5. Translate significant findings into predictive scenarios and business cases.
  6. Reflect on ethics, limitations and advanced techniques as you grow.

Success

  • The reader becomes a Master of the HR Metric, able to diagnose drivers of performance, turnover, engagement and diversity.
  • Their HR function becomes more credible and persuasive, presenting robust 'hard' evidence to leadership.
  • They build evidence-based business cases and 'what if' scenario models that help the organization invest wisely and prosper.

At stake

  • The HR function remains stuck producing the same descriptive reports in a Groundhog Day cycle, never trusted or prioritized.
  • Decisions continue to be made on gut instinct and bias, leading to misdiagnosed problems and wasted investment in interventions that do not work.
  • Costly turnover, low performance, discrimination and lost opportunities go undetected and unaddressed.

Chapter by chapter

  1. ch01HR information systems and data

    This chapter explores the integration of HR information systems with advanced data analytics, emphasizing the transformative role of AI and big data in modern human resource practices.

    • Leveraging HR information systems effectively can transform HR into a strategic partner within organizations.
    • Artificial intelligence and large language models signify the future of HR efficiency; those who prepare now will reap substantial benefits.
    • Understanding R and other analytical tools is crucial for modern HR professionals who wish to harness data effectively.
    • Enhanced data integration leads to improved reporting, which is essential for informed decision-making in HR.
  2. ch02Analysis strategies

    This chapter outlines an array of analysis strategies in human resources, detailing how to transit from simplistic descriptive reports to nuanced predictive analytics.

  3. ch03Case study 1: Diversity analytics

    This chapter explores advanced methods of analyzing diversity and inclusion (D&I) within organizations, highlighting the application of statistical techniques to measure and interpret diversity metrics effectively.

  4. ch04Case Study 6: Monitoring the Impact of Interventions

    This chapter emphasizes the significance of evaluating the effectiveness of various organizational interventions through robust data analysis, particularly within HR settings.

  5. ch05p01HR analytics: What is it and why is it important? (part 1/2)

    The emergence of predictive HR analytics has shifted from potential novelty to essential practice, helping organizations leverage human capital for better business outcomes.

  6. ch05p02HR analytics: What is it and why is it important? (part 2/2)

    This chapter delves into the various types of HR data variables and the statistical methods necessary for analyzing them, emphasizing the importance of understanding data types for effective HR analytics.

  7. ch06Case study 1: Diversity and Inclusion

    This chapter presents the case for a strategic focus on diversity and inclusion (D&I) in organizations, arguing that thoughtful management of diversity leads not only to social justice but also to tangible business benefits.

    • Diversity is essential for organizational success, not just ethically but also operationally, as it enhances team performance and innovation.
    • A descriptive approach to D&I is insufficient; predictive analytics can uncover significant insights and drive policy change.
    • Chi-square tests provide a robust framework to identify and quantify disparity in gender and ethnic representation across job grades.
    • Organizations must move from mere compliance with D&I initiatives to embedding them in their strategic framework.
  8. ch07Case study 2: Employee attitude surveys – engagement and workforce perceptions

    Employee attitude surveys are essential tools for understanding and improving employee engagement, yet defining and measuring engagement can be complex and nuanced.

    • Employee engagement is multifaceted and lacks a singular agreed-upon definition; clarity is essential for effective measurement.
    • Surveys should utilize multiple items targeting specific engagement attributes to capture the nuances of employee sentiment.
    • Validity and reliability testing are key to ensuring that engagement measures reflect true employee experiences and perceptions.
    • Employee surveys must be treated as dynamic tools that demand timely responses to foster trust and credibility.
  9. ch08Case study 3: Predicting employee turnover

    This chapter delves into voluntary employee turnover, highlighting its implications for organizations and detailing a predictive analysis framework to understand and address the underlying causes.

    • Employee turnover can incur significant costs, projected at up to 200% of an individual's salary depending on factors like skill level and role complexity.
    • Understanding and analyzing turnover through descriptive and predictive statistical methods offers valuable insights that can inform HR interventions.
    • Regular turnover reporting without statistical significance testing may lead to misdiagnosis of underlying organizational issues, masking deeper causes.
    • Logistic regression models reveal that specific factors, including employee gender and appraisal ratings, significantly influence turnover likelihood.
  10. ch09Case Study 3: Predicting Employee Turnover

    This chapter examines the application of statistical analysis in predicting employee turnover, highlighting gender disparities in retention rates and the implications for organizational practices.

  11. ch10Case study 4: Predicting employee performance

    This chapter explores the critical role of HR analytics in predicting employee performance to enhance organizational effectiveness amid economic volatility.

  12. ch12p02Case Study 5: Recruitment and Selection Analytics (part 2/2)

    This chapter examines the impact of recruitment strategies on employee value commitment over time, utilizing statistical analysis to derive actionable insights from HR data.

    • Employee value commitment increases significantly over time when strategically embedded in the organizational culture.
    • Differences in value commitment across departments highlight the need for tailored approaches to recruitment and selection.
    • Statistical methods like repeated measures ANOVA and GLM provide essential frameworks for analyzing complex HR data effectively.
    • Events occurring during data collection phases can significantly influence employee engagement metrics and should not be overlooked.

Questions this book answers

What is predictive HR analytics and why is it important?
How do you prepare and analyse HR data using R?
Which statistical test should be used for which type of HR data and research question?
How can analytics diagnose the causal drivers of diversity, engagement, turnover and performance?
How can predictive models be translated into tangible business applications and financial cases?

Glossary

HR Intervention and Design Levers
Deliberate organizational programmes and actions designed to change employee states, behaviours or outcomes, such as training, induction, work-life balance programmes and value-change events.
Contextual and Structural Conditions
Stable structural and contextual features of the work environment that form the backdrop for employee states and outcomes and that can moderate relationships.
Individual Attributes and Capabilities
Demographic and capability characteristics of individual employees used as predictors of behavioural and outcome variables.
Psychological and Perceptual States
Employees' internal attitudes, perceptions and affective-cognitive states that mediate between design/context and behavioural/outcome variables.
Behavioural and Discretionary Patterns
Observable employee behaviours and discretionary effort that lie between internal psychological states and hard outcome metrics.
Key HR Outcome Metrics
The tangible performance and people indicators the organization seeks to understand, predict and influence.

Tools these methods power