# Course: BUAN 5210
# Title: CEO Compensation EDA
# Purpose: Final Project StoryTelling
# Date: Dec 7th, 2017
# Author: Afsar Ali
# Clear working environment
rm(list=ls(all=TRUE))
# The tidyverse package contains ggplot2, tibble, tidyr, readr, purr, and dplyr among others
library(tidyverse)
# The gridExtra package contains grid.arrange function used to combine plots
library(gridExtra)
# The GGally package contains ggpairs which is a custom correlation graph for ggplot2
library(GGally)
# Load gridExtra so can plot more than one graph with grid.arrange
library(gridExtra)
#load other packages
library(psych)
#Load and Review data
dat <- read.csv("ECON5100_project_data.csv", header = TRUE)
#Make a subset of relevent data
dat1 <- select(dat, "AT","NI", "CH", "DLTT", "PRCH_C", "PRCL_C", "TDC2", "SALARY", "BONUS", "OTHCOMP", "AGE", "GENDER")
dat1<- mutate (dat1, ageg = cut(AGE, 6)) #grouping age by 6
datm <- dat1 %>% filter(GENDER =="MALE") #male only
datf <- dat1 %>% filter(GENDER =="FEMALE") #female only
#attach the file for use
attach(dat1)
The focus of this analysis is to determine compensation of Chief Executive Officers (CEOs) in US publicly traded companies by age and gender. The data set is consisted of 114 factors (columns) and 8300 data points (rows). Following are the initial exploratory data analysis.
Let’s explore Salary and Gender Distribution by Age
grid.arrange(
ggplot(dat, aes(x = AGE, y = SALARY, color = GENDER)) +
geom_point() +
stat_density2d() +
ggtitle("Mostly Middle aged Men", sub = "Small number of Female observations"),
ggplot(dat, aes(x = AGE, y = SALARY, color = GENDER)) +
geom_point() +
stat_density2d(aes(fill =..density..), geom = "raster", contour = FALSE) +
ggtitle("Mostly Middle aged Men", sub = "Heat map, light color indicates more observations"),
ncol = 2
)
Let’s look closely to find deeper insight
ggplot(dat1, aes(ageg, TDC2, fill= GENDER)) +
geom_boxplot() +
theme(axis.text.x = element_text(angle=65, vjust=0.6)) +
labs(fill = "Gender") +
# Add and improve titles and labels
ggtitle("Average female compensation seems lower than men") +
ylab("Average Compensation by Thousands") +
xlab("Age Group") +
scale_x_discrete(labels=c("Under 40", "40 to 51", "51 to 62", "62 to 73", "73 to 84", "84 +", "NA")) +
ylim(-5000, 30000)
Let’s look at the difference in compensation by Gender
Why are older females observed to have higher compensation?
grid.arrange(
#Male Data
datf %>%
group_by(ageg) %>%
summarise(Avg_Com = mean(TDC2)) %>%
ggplot(aes(x = ageg, y = Avg_Com, )) +
geom_bar(stat="identity", position = "dodge", color = "black") +
labs(fill = "Gender") +
# Add and improve titles and labels
ggtitle("Older female higher compensation") +
ylab("Average Compensation by Thousands") +
xlab("Female Age Group") +
scale_x_discrete(labels=c("Under 40", "40 to 51", "51 to 62", "62 to 73", "73 to 84", "84 +", "NA")) +
ylim(0, 6000) +
theme_classic() +
theme(axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),),
#Female Data
datm %>%
group_by(ageg) %>%
summarise(Avg_Com = mean(TDC2)) %>%
ggplot(aes(x = ageg, y = Avg_Com, )) +
geom_bar(stat="identity", position = "dodge", color = "black") +
labs(fill = "Gender") +
# Add and improve titles and labels
ggtitle("Middle-age males higher compensation") +
ylab("Average Compensation by Thousands") +
xlab("Male Age Group") +
scale_x_discrete(labels=c("Under 40", "40 to 51", "51 to 62", "62 to 73", "73 to 84", "84 +", "NA")) +
ylim(0, 6000) +
theme_classic() +
theme( axis.ticks.x = element_blank(),
axis.title.y = element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank()),
# panel.background = element_blank()),
ncol = 2
)
Let’s compare total compensation side by side
+ There are no female executives over 84 + Female age group has larger growth from 62-73 to 73-84
# Average profit by region and category
dat1 %>%
group_by(ageg, GENDER) %>%
summarise(Avg_Com = mean(TDC2)) %>%
ggplot(aes(x = ageg, y = Avg_Com, fill = reorder(GENDER, desc(Avg_Com)))) +
geom_bar(stat="identity", position = "dodge", color = "black") +
geom_hline(yintercept = 0, color = "black") +
labs(fill = "Gender") +
# Add and improve titles and labels
ggtitle("Middle age female age groups has a high compensation") +
ylab("Average Compensation by Thousands") +
xlab("Age Group") +
scale_x_discrete(labels=c("Under 40", "40 to 51", "51 to 62", "62 to 73", "73 to 84", "84 +", "NA")) +
scale_fill_manual(values = c("blue", "grey70"))+
theme_classic() +
theme(axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),)
grid.arrange(
#Male Data
datf %>%
group_by(ageg) %>%
summarise(Avg_Com = mean(BONUS)) %>%
ggplot(aes(x = ageg, y = Avg_Com, )) +
geom_bar(stat="identity", position = "dodge", color = "black") +
# Add and improve titles and labels
ggtitle("Female 73 to 84 gets a large Bonus") +
ylab("Average Bonus by Thousands") +
xlab("Female Age Group") +
scale_x_discrete(labels=c("Under 40", "40 to 51", "51 to 62", "62 to 73", "73 to 84", "84 +", "NA")) +
ylim(0, 2000) +
theme_classic() +
theme(axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),),
#Female Data
datm %>%
group_by(ageg) %>%
summarise(Avg_Com = mean(BONUS)) %>%
ggplot(aes(x = ageg, y = Avg_Com, )) +
geom_bar(stat="identity", position = "dodge", color = "black") +
# Add and improve titles and labels
ggtitle("Male Bonus similar accross age group") +
ylab("Average Compensation by Thousands") +
xlab("Male Age Group") +
scale_x_discrete(labels=c("Under 40", "40 to 51", "51 to 62", "62 to 73", "73 to 84", "84 +", "NA")) +
ylim(0, 2000) +
theme_classic() +
theme( axis.ticks.x = element_blank(),
axis.title.y = element_blank(),
axis.text.y = element_blank(),
axis.ticks.y = element_blank()),
# panel.background = element_blank()),
ncol = 2
)
Analysis of Chief Executive Officers (CEOs) compensation seems to show us that Males and Females has different average compensation distribution. Older females having higher average compensation and Males having a normal distribution, due to higher bonus observed for older females