Case study: Multiple Linear Regression
What drives employee performance? An exploration of underlying factors via multiple regression model with R

Background
For any business, employee performance is always one of the keys to success. It has been a topic that attracts attention in both academia and the business world. It is important for leaders and business owners to understand the why and underlying factors that drive employee performance. By doing so, we can then cultivate a work environment which empower employees to perform at their best and unleash their potential. To begin with data exploration, we always start from a question, it can be...
-
What are the factors that drive employee performance?
-
How can we improve employee performance?
-
Are employee engagement and satisfaction related to performance?
-
And more...
From there, we can then look for relevant data from different sources to answer the questions of interest. With more and more companies embark on people analytics journey, we can answer these questions with people data and build a statistical model to try to explain the possible underlying factors that drive employee performance.
Illustration
In the below example, I will be using R to build a multiple regression model to explore the factors that drive employee performance based on the HR dataset from Dr. Carla Patalano here. The dataset contains a total of 36 columns of data (i.e. Gender, Department, Performance) with 311 rows of unique values, each representing an employee's data.
Linear Regression is used as employee performance data is on sort of a continuous scale, meanwhile it is likely that potential variables (i.e. engagement, satisfaction) and employee performance are approximately in a linear relationship.
To begin with, we first load our data in R and have a quick exploration of the current dataset,
#Data Exploration
HRdata <- read.csv(file.choose())
summary(HRdata)
str(HRdata)

Based on the summary and the structure of the dataset, there isn't any missing data, which shouldn't be a surprise as it is a fictional dataset. For simpler illustration purpose, I created another data frame with some of the variables that may worth exploration from the original dataset, which includes numerical data (i.e., employee performance score, engagement level, satisfaction level, no. of absences) and categorical data (i.e., line manager name, Recruitment source, department, sex, race).
#Create a new dataframe
HRdata_new <- HRdata[,c("PerfScoreID","Department","RecruitmentSource","EngagementSurvey","EmpSatisfaction","Absences","ManagerName","Sex","RaceDesc")]
Categorical data are stored in factor vector first to make it easier to perform grouping and manipulation later if needed.
#Categorical data store as factor vector
HRdata_new$Department <- as.factor(HRdata_new$Department)
HRdata_new$RecruitmentSource <- as.factor(HRdata_new$RecruitmentSource)
HRdata_new$ManagerName <- as.factor(HRdata_new$ManagerName)
HRdata_new$Sex <- as.factor(HRdata_new$Sex)
HRdata_new$RaceDesc <- as.factor(HRdata_new$RaceDesc)
Before modeling, I would like to quickly explore if there are any interesting patterns among the data first. A correlation matrix is plotted to explore the relationship among the numerical variables.
#Correlation Matrix to explore Performance Rating and continuous data
library(corrplot)
nums <- unlist(lapply(HRdata_new, is.numeric))
HRdata_numeric <- HRdata_new[,nums]
data.cor=cor(HRdata_numeric)
corrplot(data.cor, tl.col="black", tl.cex=0.8, tl.srt=70)

Based on the correlation matrix, there are positive correlations among employee performance, engagement, and satisfaction. Very likely the engagement and satisfaction level can explain some variance of employee performance to a certain extent. Though we have to be aware that collinearity maybe present in the data especially between satisfaction and engagement level.
After exploring the relationship among the numeric variables and employee performance, I would like to see if there are any patterns worth investigating for the categorical data. Jitter plot is chosen to quickly visualize the data spread across the categories.
#Jitter plot for exploration
library(ggplot2)
ggplot(data = HRdata_new, aes(x=Department, y=PerfScoreID)) +
geom_jitter(aes(color=Department))
ggplot(data = HRdata_new, aes(x=RecruitmentSource, y=PerfScoreID)) +
geom_jitter(aes(color=RecruitmentSource))
ggplot(data = HRdata_new, aes(x=RaceDesc, y=PerfScoreID)) +
geom_jitter(aes(color=RaceDesc))
ggplot(data = HRdata_new, aes(x=Sex, y=PerfScoreID)) +
geom_jitter(aes(color=Sex))




From the recruitment source data plot, employees from referral seem to have better employee performance. Apart from that, the data spread pattern is quite similar across the categories. Meanwhile for a class with small sample size, it is hard to draw a solid conclusion from there.
After exploring the patterns, dummy variables are created for categorical data to proceed with the modeling. I picked the department and recruitment source to move forward, sex and race are excluded in the later modeling as I don't want demographics to be taken into consideration when modeling employee performance.
#Create dummy variables and new dataframe
library(dummies)
dummy_department <-dummies::dummy("Department", data=HRdata_new)
dummy_source <-dummies::dummy("RecruitmentSource", data=HRdata_new)
HRdata_final <-data.frame(
Performance = HRdata_new$PerfScoreID,
Engagement = HRdata_new$EngagementSurvey,
Satisfaction = HRdata_new$EmpSatisfaction,
Absences = HRdata_new$Absences,
dummy_department,
dummy_source
)
From there, we can start building our first model, to begin with, we can regress employee's performance against everything else.
#Exploration of all variables in same model
HRmodel1 <-lm(data=HRdata_final, formula = Performance~.)
summary(HRmodel1)

From the model, we can see engagement level, satisfaction level are significant predictors of employee's performance, in which the more engaged and satisfied employees tend to have higher performance. Recruitment source from employee referral is also marginally significant where employees recruited from referral tend to perform better. From here, we can build the second model with only these 3 variables.
#Second Model
HRmodel2 <-lm(data=HRdata_final, formula = Performance~Engagement+Satisfaction+RecruitmentSourceEmployee.Referral)
summary(HRmodel2)

Based on the adjusted R-square, around 34% variance of employee performance can be explained by engagement level, satisfaction level, and employee referral as a recruitment source. We can always create some interaction term to see if that further improves the model. But let's say the current model looks good for now, we can then perform some quick tests to check the model assumptions.
#Assumptions (Linearity, Collinerity, residuals)
predicted_values<-HRmodel2$fitted.values
true_values<-HRdata_final$Performance
plot(predicted_values, true_values)
qqnorm(HRmodel2$residuals)
library(mctest)
mctest::imcdiag(HRmodel2, method = "VIF")



Multicollinearity is not detected in the model; assumptions of linear relationship and normally distributed errors look acceptable and we are good to go. Here are few thoughts after the modeling based on the sample data,
-
The relationship of engagement, satisfaction, and employee performance worth further exploration. While we can claim satisfied and engaged employees perform better, we can also say that high performers are more engaged and satisfied based on the correlation. Data analysis with time series data can help us further explore if current engagement level and satisfaction level can predict the later employee performance
-
The current model explains around 34% variance of employee performance, it seems there are other underlying factors that may drive employee performance, if we have other relevant data (i.e. personality, network data), we maybe able to build a more robust model
-
Are performance data valid and reliable? How do we measure employee's performance? These are the questions worth thinking about as the current modeling is based on the assumption that the performance data is valid and reliable
Again, all the above is just a quick illustration of how to explore people data and understand the underlying factors of employee performance via multiple linear regression modeling with R. With a better understanding of the "why" and leveraging the power of people analytics, we can build a better workplace which empowers people to perform at their best.