Data Analysis- Final Project

Author

Niki

Niki’s Data Analysis- (Journey thus far - Final Project)

Research Question:

“Does the level of rule of law in a country influence the rate of sustainability reporting by companies a across the 40 countries in the 2022 KPMG sustainability survey?”

My research question aims to investigate the potential relationship between the level of rule of law and the rate of sustainability reporting across the 40 (primarily developing) countries in the 2022 KPMG sustainability survey. It explores whether countries with higher rule of law scores tend to have higher rates of sustainability reporting by companies, and vice versa. This topic will involve me analyzing the data from the 40 countries to determine if there is a significant association between these variables and to what extent rule of law might influence sustainability reporting practices globally.

Reading in the data:

options(repos = c(CRAN = "https://cran.rstudio.com/"))
install.packages("readxl")

The downloaded binary packages are in
    /var/folders/yd/c2zm5hrx3z9f72991hsqsbqh0000gn/T//RtmpwiHegW/downloaded_packages
library(readxl)
install.packages("here")

The downloaded binary packages are in
    /var/folders/yd/c2zm5hrx3z9f72991hsqsbqh0000gn/T//RtmpwiHegW/downloaded_packages
library(here) 
here() starts at /Users/nikhila/Desktop
# Set the file path to your desktop
path_to_sheet <- "/Users/nikhila/Desktop/Data (KPMG & rule of law) .xlsx"

# Read the Excel file
data <- read_excel(path_to_sheet)

Checking the Data & Initial Regression Analysis

head (data)
# A tibble: 6 × 3
  `Country ` `Rate of Sustainability Reporting ` Rule of law score (-2.5 to 2.…¹
  <chr>                                    <dbl> <chr>                          
1 Argentina                                 0.37 -0.48068231344223              
2 Australia                                 0.68 1.5100852251052901             
3 Austria                                   0.59 1.70585024356842               
4 Brazil                                    0.76 -0.25725093483924899           
5 Canada                                    0.74 1.5662201642990099             
6 Chile                                     0.58 0.69040066003799405            
# ℹ abbreviated name: ¹​`Rule of law score (-2.5 to 2.5)`
# Rename the columns to remove spaces at the end
names(data) <- c("Country", "Rate_of_Sustainability_Reporting", "Rule_of_law_score")

# Run the regression
model <- lm(Rate_of_Sustainability_Reporting ~ Rule_of_law_score, data = data)

# Print a summary of the regression results
summary(model)

Call:
lm(formula = Rate_of_Sustainability_Reporting ~ Rule_of_law_score, 
    data = data)

Residuals:
ALL 40 residuals are 0: no residual degrees of freedom!

Coefficients:
                                        Estimate Std. Error t value Pr(>|t|)
(Intercept)                                 0.79        NaN     NaN      NaN
Rule_of_law_score-0.25725093483924899      -0.03        NaN     NaN      NaN
Rule_of_law_score-0.36002513766288802      -0.61        NaN     NaN      NaN
Rule_of_law_score-0.42687553167343101      -0.27        NaN     NaN      NaN
Rule_of_law_score-0.458115965127945        -0.49        NaN     NaN      NaN
Rule_of_law_score-0.47439333796501199      -0.21        NaN     NaN      NaN
Rule_of_law_score-0.48068231344223         -0.42        NaN     NaN      NaN
Rule_of_law_score-0.51833748817443803      -0.14        NaN     NaN      NaN
Rule_of_law_score-0.55139106512069702      -0.19        NaN     NaN      NaN
Rule_of_law_score-0.67249220609664895       0.05        NaN     NaN      NaN
Rule_of_law_score-0.86664253473281905      -0.25        NaN     NaN      NaN
Rule_of_law_score-4.1443984955549198E-2    -0.60        NaN     NaN      NaN
Rule_of_law_score-5.69253154098988E-2      -0.03        NaN     NaN      NaN
Rule_of_law_score0.11470004171133          -0.10        NaN     NaN      NaN
Rule_of_law_score0.29062327742576599       -0.50        NaN     NaN      NaN
Rule_of_law_score0.32558470964431802       -0.26        NaN     NaN      NaN
Rule_of_law_score0.40415573120117199       -0.29        NaN     NaN      NaN
Rule_of_law_score0.42367401719093301       -0.10        NaN     NaN      NaN
Rule_of_law_score0.43060928583145103       -0.36        NaN     NaN      NaN
Rule_of_law_score0.43657729029655501       -0.52        NaN     NaN      NaN
Rule_of_law_score0.561897993087769          0.18        NaN     NaN      NaN
Rule_of_law_score0.57079851627349898       -0.65        NaN     NaN      NaN
Rule_of_law_score0.69040066003799405       -0.21        NaN     NaN      NaN
Rule_of_law_score0.79993212223053001       -0.29        NaN     NaN      NaN
Rule_of_law_score0.83664274215698198       -0.43        NaN     NaN      NaN
Rule_of_law_score0.94524872303009          -0.57        NaN     NaN      NaN
Rule_of_law_score1.1008057594299301        -0.25        NaN     NaN      NaN
Rule_of_law_score1.1597031354904199         0.09        NaN     NaN      NaN
Rule_of_law_score1.37168848514557           0.01        NaN     NaN      NaN
Rule_of_law_score1.4154912233352701         0.14        NaN     NaN      NaN
Rule_of_law_score1.5100852251052901        -0.11        NaN     NaN      NaN
Rule_of_law_score1.53315436840057          -0.10        NaN     NaN      NaN
Rule_of_law_score1.5582402944564799         0.15        NaN     NaN      NaN
Rule_of_law_score1.5662201642990099        -0.05        NaN     NaN      NaN
Rule_of_law_score1.70585024356842          -0.20        NaN     NaN      NaN
Rule_of_law_score1.7317972183227499        -0.20        NaN     NaN      NaN
Rule_of_law_score1.7518067359924301        -0.18        NaN     NaN      NaN
Rule_of_law_score1.7691470384597801        -0.40        NaN     NaN      NaN
Rule_of_law_score1.7792776823043801        -0.11        NaN     NaN      NaN
Rule_of_law_score6.7307785153389005E-2      0.07        NaN     NaN      NaN

Residual standard error: NaN on 0 degrees of freedom
  (170 observations deleted due to missingness)
Multiple R-squared:      1, Adjusted R-squared:    NaN 
F-statistic:   NaN on 39 and 0 DF,  p-value: NA

Table of the Results

# Load necessary library
library(knitr)

# Create a table
table_data <- data[, c("Country", "Rate_of_Sustainability_Reporting", "Rule_of_law_score")]
kable(table_data, caption = "Table of Rate of Sustainability and Rule of Law Score by Country")
Table of Rate of Sustainability and Rule of Law Score by Country
Country Rate_of_Sustainability_Reporting Rule_of_law_score
Argentina 0.37 -0.48068231344223
Australia  0.68 1.5100852251052901
Austria  0.59 1.70585024356842
Brazil  0.76 -0.25725093483924899
Canada  0.74 1.5662201642990099
Chile  0.58 0.69040066003799405
China  0.19 -4.1443984955549198E-2
Colombia  0.52 -0.42687553167343101
Costa Rica  0.27 0.43657729029655501
Cyprus  0.14 0.57079851627349898
Czech Republic  0.54 1.1008057594299301
Germany  0.69 1.53315436840057
Greece  0.53 0.32558470964431802
Hungary  0.69 0.42367401719093301
India  0.69 0.11470004171133
Israel  0.22 0.94524872303009
Japan  0.94 1.5582402944564799
Kazakhstan  0.58 -0.47439333796501199
Luxembourg  0.39 1.7691470384597801
Malaysia  0.97 0.561897993087769
Mexico  0.54 -0.86664253473281905
New Zealand  0.59 1.7317972183227499
Pakistan  0.84 -0.67249220609664895
Panama  0.18 -0.36002513766288802
Peru  0.60 -0.55139106512069702
Philippines  0.65 -0.51833748817443803
Poland  0.43 0.43060928583145103
Romania  0.50 0.40415573120117199
Saudi Arabia  0.29 0.29062327742576599
Singapore  0.68 1.7792776823043801
South Korea  0.88 1.1597031354904199
Spain  0.50 0.79993212223053001
Sri Lanka  0.76 -5.69253154098988E-2
Switzerland  0.61 1.7518067359924301
Thailand  0.86 6.7307785153389005E-2
Turkey  0.30 -0.458115965127945
UAE  0.36 0.83664274215698198
UK  0.93 1.4154912233352701
USA  0.80 1.37168848514557
Vietnam 0.79 -0.15844340622425099
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA NA
NA NA Data from database: Environment Social and Governance (ESG) Data
NA NA Last Updated: 04/02/2024

Examining the Rule of Law Score across Countries

library(ggplot2)
# Dot plot for Rule of Law Score by Country
ggplot(data, aes(x = Country, y = Rule_of_law_score)) +
  geom_point(color = "skyblue", size = 3) +
  labs(x = "Country", y = "Rule of Law Score", title = "Rule of Law Score by Country") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))  # Rotate x-axis labels for better readability

Examining the Rates of Sustainability Reporting across Countries

# Scatter plot of Rate of Sustainability Reporting by Country
ggplot(data, aes(x = reorder(Country, Rate_of_Sustainability_Reporting), y = Rate_of_Sustainability_Reporting)) +
  geom_point() +
  labs(x = "Country", y = "Rate of Sustainability Reporting", title = "Rate of Sustainability Reporting by Country") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for better readability
Warning: Removed 170 rows containing missing values or values outside the scale range
(`geom_point()`).

Graphing the Relationship between the Rates of Sustainability Reporting and Rule of Law across the Countries

# Bar plot with color-coded bars
ggplot(data, aes(x = as.factor(Rule_of_law_score), y = Rate_of_Sustainability_Reporting, fill = Country)) +
  geom_bar(stat = "summary", fun = "mean") +
  labs(x = "Rule of Law Score", y = "Average Rate of Sustainability Reporting", title = "Average Reporting by Rule of Law Score") +
  scale_fill_discrete(name = "Country") +  # Customize legend title
  theme_minimal()
Warning: Removed 170 rows containing non-finite outside the scale range
(`stat_summary()`).

# Load necessary libraries
library(ggplot2)

# Plot the scatter plot with regression line and color-coded points
ggplot(data, aes(x = Rule_of_law_score, y = Rate_of_Sustainability_Reporting, color = Country)) +
  geom_point() +  # Add points for each country
  geom_smooth(method = "lm", se = FALSE) +  # Add a regression line
  labs(x = "Rule of Law Score", y = "Rate of Sustainability Reporting", title = "Relationship between Reporting and Rule of Law") +
  theme_minimal() +
  scale_color_discrete(name = "Country")  # Customize the legend title
`geom_smooth()` using formula = 'y ~ x'
Warning: Removed 170 rows containing non-finite outside the scale range
(`stat_smooth()`).
Warning: Removed 170 rows containing missing values or values outside the scale range
(`geom_point()`).