# library
library(psych)
## Warning: package 'psych' was built under R version 4.3.2
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
library(rstatix)
## Warning: package 'rstatix' was built under R version 4.3.2
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(hrbrthemes)
## Warning: package 'hrbrthemes' was built under R version 4.3.3
library(viridis)
## Warning: package 'viridis' was built under R version 4.3.3
## Loading required package: viridisLite
data1 <- read.csv("data1.csv", header = TRUE)
#str(data1)
Company <- c(data1$rowname)
Alt <- c(data1$Alt)
EBIT <- c(data1$EBIT)
NWC <- c(data1$NWC)
Sale <- c(data1$Sale)
equity <- c(data1$equity)
RE <- c(data1$RE)
class.df<- data.frame(Alt,EBIT,NWC,Sale,equity,RE)
View(class.df)
summary(data1)
## rowname Alt EBIT NWC
## Length:640 Min. :-9.610 Min. :-0.3800 Min. :-0.3400
## Class :character 1st Qu.: 3.200 1st Qu.: 0.0600 1st Qu.: 0.0600
## Mode :character Median : 5.485 Median : 0.1100 Median : 0.1700
## Mean : 7.438 Mean : 0.1142 Mean : 0.1997
## 3rd Qu.: 8.602 3rd Qu.: 0.1600 3rd Qu.: 0.3225
## Max. :58.580 Max. : 0.5400 Max. : 1.2200
## Sale equity RE
## Min. :0.1400 Min. :0.0000 Min. :-10.4700
## 1st Qu.:0.4700 1st Qu.:0.0400 1st Qu.: 0.0000
## Median :0.6150 Median :0.1100 Median : 0.1750
## Mean :0.6965 Mean :0.1569 Mean : 0.4215
## 3rd Qu.:0.7900 3rd Qu.:0.2000 3rd Qu.: 0.4725
## Max. :2.2700 Max. :1.5300 Max. : 47.0600
colSums(is.na(data1))
## rowname Alt EBIT NWC Sale equity RE
## 0 0 0 0 0 0 0
There is no NA value in the data set
boxplot(class.df[, c(1)], main = 'Multiple Box plots')
boxplot(class.df[,c(1,2,3,4,5,6)], main='Multiple Box plots')
### Identify the outliner
identify_outliers(data1, Alt)
identify_outliers(data1, EBIT)
identify_outliers(data1, NWC)
identify_outliers(data1, Sale)
identify_outliers(data1, equity)
identify_outliers(data1, RE)
# Function to replace outliers by mode in a column
replace_outliers_by_mode <- function(x) {
# Calculate mode
mode_val <- as.numeric(names(sort(table(x), decreasing = TRUE)[1]))
# Replace outliers with mode
x[which(x %in% boxplot.stats(x)$out)] <- mode_val
return(x)
}
# Function to replace outliers by mode in multiple columns of a dataframe
replace_outliers_by_mode_multiple_columns <- function(df) {
# Apply the replace_outliers_by_mode function to each column
replaced_df <- lapply(df, replace_outliers_by_mode)
# Convert the list back to a dataframe
replaced_df <- as.data.frame(replaced_df)
return(replaced_df)
}
# Example data
data <- data.frame(
Alt = data1$Alt,
EBIT = c(data1$EBIT),
NWC = c(data1$NWC),
Sale = c(data1$Sale),
equity = c(data1$equity),
RE = c(data1$RE)
)
# Replace outliers by mode in each column
replaced_data <- replace_outliers_by_mode_multiple_columns(data)
# View the modified data
print(replaced_data)
## Alt EBIT NWC Sale equity RE
## 1 5.40 0.11 0.16 0.79 0.06 0.45
## 2 7.49 0.04 0.06 0.56 0.00 0.56
## 3 8.56 0.10 0.14 0.38 0.04 0.64
## 4 8.23 0.15 0.07 0.42 0.06 0.59
## 5 5.28 0.15 0.34 0.49 0.06 0.13
## 6 0.00 0.24 0.21 0.49 0.05 -0.56
## 7 7.63 0.09 0.05 0.69 0.08 0.95
## 8 0.00 0.30 0.03 0.56 0.00 0.00
## 9 10.20 0.09 0.45 0.72 0.01 0.00
## 10 11.52 0.11 0.41 0.34 0.00 0.38
## 11 6.49 0.17 0.13 0.77 0.16 0.32
## 12 4.19 0.03 0.34 0.41 0.25 0.12
## 13 3.52 0.16 0.40 0.60 0.08 -0.27
## 14 5.18 0.07 0.65 0.56 0.00 -0.34
## 15 3.92 0.16 0.33 0.44 0.06 -0.01
## 16 3.75 0.19 0.36 0.45 0.16 0.15
## 17 12.93 0.23 0.17 0.89 0.05 0.40
## 18 0.00 0.12 0.23 0.56 0.00 0.00
## 19 0.00 0.23 0.27 1.23 0.00 0.22
## 20 10.73 0.12 0.31 0.79 0.00 0.59
## 21 10.28 -0.05 0.16 0.66 0.31 1.00
## 22 2.59 0.15 -0.06 0.50 0.05 0.23
## 23 6.42 -0.03 -0.14 0.54 0.00 0.08
## 24 2.90 0.11 0.28 0.31 0.15 -0.15
## 25 3.79 -0.04 0.34 0.32 0.11 0.35
## 26 0.00 0.04 0.20 0.85 0.00 0.00
## 27 3.21 0.23 0.02 0.55 0.30 0.25
## 28 4.84 0.06 0.38 0.79 0.21 1.00
## 29 5.24 0.14 0.67 0.61 0.08 0.35
## 30 12.97 0.15 0.66 0.82 0.02 1.01
## 31 6.41 0.16 0.37 1.06 0.05 0.48
## 32 2.88 0.04 0.27 0.56 0.40 0.13
## 33 2.82 0.08 0.03 0.56 0.15 -0.35
## 34 3.73 0.17 0.18 0.96 0.21 0.00
## 35 6.30 0.09 0.68 0.53 0.06 0.43
## 36 5.34 0.19 0.38 0.58 0.14 0.37
## 37 5.04 0.06 0.26 0.47 0.11 0.33
## 38 0.00 0.12 0.31 0.71 0.00 0.15
## 39 4.75 0.05 0.02 0.50 0.07 0.06
## 40 3.20 0.04 0.03 0.56 0.23 0.16
## 41 3.75 0.06 0.31 0.73 0.18 -0.01
## 42 8.25 0.09 0.24 0.48 0.04 -0.07
## 43 3.06 0.13 0.22 0.69 0.09 0.31
## 44 4.92 0.08 0.40 0.57 0.16 0.45
## 45 2.43 0.06 0.20 0.82 0.23 0.00
## 46 2.54 0.11 0.45 0.83 0.27 -0.34
## 47 5.77 0.16 0.34 0.42 0.13 0.29
## 48 0.00 0.07 0.08 0.40 0.07 -0.07
## 49 3.33 0.01 0.10 0.62 0.14 -0.37
## 50 10.63 0.15 0.35 0.55 0.00 0.52
## 51 0.00 0.04 0.38 1.25 0.00 0.00
## 52 0.00 0.25 0.23 0.42 0.14 0.30
## 53 4.73 0.15 0.49 0.43 0.01 0.28
## 54 4.27 0.11 0.40 0.56 0.21 -0.19
## 55 0.00 0.02 0.13 0.77 0.00 0.13
## 56 5.59 0.02 0.12 0.84 0.18 0.39
## 57 3.56 0.12 0.11 0.59 0.16 0.12
## 58 0.00 -0.03 0.37 0.65 0.00 0.16
## 59 7.34 0.15 0.19 0.62 0.11 0.23
## 60 9.67 0.14 0.24 0.75 0.08 0.00
## 61 14.29 0.11 0.44 0.87 0.00 0.29
## 62 0.00 0.08 0.41 0.53 0.22 0.00
## 63 5.38 0.04 0.36 0.98 0.11 0.44
## 64 0.00 0.14 -0.04 0.30 0.00 0.25
## 65 4.22 0.11 0.13 0.80 0.10 0.30
## 66 8.26 0.04 0.09 0.56 0.00 0.66
## 67 9.55 0.10 0.14 0.41 0.04 0.59
## 68 8.50 0.14 0.07 0.49 0.05 0.60
## 69 4.58 0.15 0.38 0.51 0.06 0.11
## 70 6.19 0.24 0.12 0.53 0.07 -0.41
## 71 5.35 0.02 0.04 0.63 0.24 0.85
## 72 -0.43 0.26 0.20 0.56 0.00 0.00
## 73 14.64 0.09 0.46 0.72 0.01 0.09
## 74 13.04 -0.07 0.02 0.35 0.00 0.54
## 75 5.99 0.14 0.24 0.75 0.17 0.33
## 76 7.38 0.02 0.17 0.65 0.11 0.12
## 77 3.01 0.10 0.42 0.49 0.13 -0.12
## 78 5.62 0.11 0.67 0.56 0.00 -0.27
## 79 5.17 0.16 0.40 0.50 0.05 -0.05
## 80 3.50 0.21 0.33 0.43 0.18 0.13
## 81 9.30 0.24 0.19 0.95 0.04 0.53
## 82 2.08 0.11 0.22 0.56 0.11 0.00
## 83 0.00 0.27 0.28 1.17 0.01 0.31
## 84 7.75 0.11 0.35 0.83 0.00 0.59
## 85 11.07 0.11 0.13 0.68 0.23 1.04
## 86 3.98 0.13 -0.08 0.56 0.04 0.29
## 87 5.56 -0.01 -0.08 0.56 0.00 0.06
## 88 2.81 -0.09 0.20 0.30 0.13 -0.05
## 89 3.08 0.11 0.30 0.32 0.22 0.43
## 90 1.64 0.08 0.22 0.39 0.00 0.00
## 91 2.63 0.25 0.03 0.48 0.18 0.27
## 92 5.01 0.02 0.26 0.74 0.24 0.00
## 93 4.96 0.14 0.60 0.54 0.14 0.32
## 94 10.24 0.13 0.64 0.84 0.02 1.17
## 95 6.17 0.13 0.43 1.00 0.11 0.56
## 96 2.85 0.16 0.25 0.56 0.00 0.14
## 97 1.75 0.06 0.14 0.56 0.18 -0.34
## 98 3.74 0.08 -0.05 0.81 0.20 0.03
## 99 3.36 0.10 0.67 0.58 0.36 0.48
## 100 4.25 0.28 0.39 0.56 0.20 0.39
## 101 4.38 0.05 0.19 0.45 0.18 0.32
## 102 0.00 0.11 0.36 0.77 0.00 0.23
## 103 4.42 0.05 -0.02 0.54 0.10 0.10
## 104 2.23 0.02 0.10 0.68 0.36 0.39
## 105 2.48 0.10 0.33 0.67 0.41 0.11
## 106 8.41 0.08 0.21 0.56 0.03 -0.17
## 107 2.40 0.13 0.22 0.65 0.13 0.00
## 108 6.73 0.08 0.39 0.65 0.12 0.53
## 109 3.78 0.07 0.17 0.23 0.32 -0.19
## 110 2.26 0.12 0.42 0.90 0.35 -0.25
## 111 4.03 0.11 0.31 0.34 0.22 0.23
## 112 0.00 0.04 0.04 0.47 0.03 -0.19
## 113 2.53 0.01 0.07 0.57 0.19 -0.29
## 114 4.91 0.12 0.25 0.50 0.14 0.61
## 115 7.21 0.10 0.35 0.25 0.00 0.00
## 116 0.00 0.15 0.16 0.35 0.17 0.33
## 117 4.66 0.14 0.52 0.44 0.03 0.31
## 118 3.36 0.09 0.48 0.56 0.27 -0.27
## 119 0.00 0.01 0.09 0.88 0.00 0.21
## 120 5.53 0.06 0.02 0.84 0.18 0.51
## 121 3.64 0.10 0.09 0.59 0.17 0.21
## 122 0.00 0.11 0.30 0.64 0.00 0.29
## 123 6.66 0.08 0.09 0.62 0.13 0.32
## 124 11.03 0.12 0.19 0.80 0.07 0.00
## 125 0.00 0.12 0.29 0.44 0.01 0.18
## 126 0.00 0.08 0.43 0.45 0.19 0.00
## 127 4.63 0.01 0.33 0.96 0.14 0.55
## 128 2.91 0.11 0.03 0.72 0.00 0.31
## 129 3.77 0.11 0.13 0.67 0.14 0.29
## 130 7.65 0.12 -0.01 0.56 0.00 0.65
## 131 9.56 0.10 0.16 0.46 0.04 0.57
## 132 8.02 0.14 0.07 0.43 0.09 0.56
## 133 3.58 0.15 0.38 0.45 0.14 0.09
## 134 7.56 0.23 0.15 0.53 0.07 -0.38
## 135 7.03 -0.02 -0.01 0.74 0.10 0.96
## 136 -0.59 0.26 0.20 0.56 0.00 0.00
## 137 13.18 0.10 0.44 0.72 0.01 0.11
## 138 13.50 -0.06 0.32 0.35 0.00 0.56
## 139 6.61 0.14 0.24 0.75 0.17 0.33
## 140 3.12 0.00 0.17 0.26 0.20 0.04
## 141 6.48 0.13 0.44 0.73 0.05 -0.14
## 142 5.66 0.10 0.50 0.56 0.00 -0.26
## 143 4.26 0.16 0.40 0.52 0.03 -0.05
## 144 3.54 0.05 0.16 0.40 0.19 0.13
## 145 9.29 0.24 0.19 0.95 0.04 0.56
## 146 0.90 0.11 0.22 0.56 0.11 0.00
## 147 15.53 0.27 0.28 1.17 0.01 0.33
## 148 8.59 0.01 0.17 0.87 0.00 0.57
## 149 11.94 0.11 0.13 0.72 0.15 1.12
## 150 2.82 0.13 -0.08 0.56 0.04 0.31
## 151 4.08 0.01 0.01 0.56 0.00 0.06
## 152 2.05 -0.09 0.20 0.31 0.20 -0.02
## 153 2.92 0.11 0.30 0.32 0.22 0.46
## 154 1.87 0.12 0.24 0.38 0.44 0.00
## 155 2.80 0.19 0.09 0.56 0.27 1.11
## 156 5.60 0.00 0.25 0.74 0.24 0.00
## 157 4.55 0.19 0.58 0.54 0.14 0.32
## 158 11.66 0.13 0.64 1.10 0.03 0.00
## 159 5.79 0.11 0.42 1.00 0.11 0.59
## 160 2.74 -0.01 0.08 0.56 0.00 0.14
## 161 2.30 0.12 0.18 0.56 0.18 -0.45
## 162 4.10 0.08 -0.05 0.77 0.19 0.16
## 163 3.89 0.10 0.67 0.60 0.27 0.00
## 164 3.98 0.29 0.46 0.48 0.34 0.33
## 165 4.66 0.05 0.19 0.39 0.25 0.28
## 166 0.00 0.15 0.32 0.77 0.00 0.23
## 167 3.84 0.06 0.00 0.45 0.14 0.04
## 168 2.77 0.05 0.08 0.68 0.36 0.41
## 169 1.90 0.10 0.33 0.45 0.00 0.20
## 170 6.03 0.10 0.10 0.56 0.03 -0.20
## 171 2.04 0.13 0.22 0.55 0.35 0.01
## 172 14.63 0.09 0.55 0.68 0.10 0.54
## 173 2.66 0.07 0.17 0.23 0.32 -0.18
## 174 2.69 0.13 0.53 0.90 0.35 -0.24
## 175 3.79 0.12 0.30 0.33 0.26 0.24
## 176 0.00 0.05 0.08 0.48 0.04 -0.18
## 177 2.22 0.04 0.25 0.49 0.15 -0.26
## 178 5.29 0.11 0.32 0.45 0.13 0.60
## 179 3.81 0.10 0.35 0.40 0.15 -0.06
## 180 0.00 0.29 -0.15 0.35 0.17 0.35
## 181 5.12 0.14 0.52 0.46 0.02 0.33
## 182 2.25 0.06 0.49 0.56 0.00 -0.33
## 183 0.00 0.01 0.09 0.85 0.00 0.38
## 184 6.49 0.05 0.03 0.85 0.25 0.56
## 185 4.82 0.10 0.09 0.64 0.18 0.38
## 186 0.00 0.11 0.30 0.64 0.00 0.24
## 187 7.31 0.08 0.09 0.64 0.08 0.33
## 188 14.40 0.01 0.17 0.80 0.07 0.00
## 189 9.50 0.12 0.29 0.44 0.01 0.19
## 190 0.00 0.03 0.28 0.45 0.19 0.00
## 191 2.42 0.01 0.33 0.40 0.00 0.28
## 192 4.23 0.14 0.02 0.72 0.00 0.30
## 193 3.78 0.12 0.14 0.61 0.15 0.26
## 194 8.37 0.10 -0.11 0.56 0.00 0.35
## 195 12.41 0.09 0.14 0.50 0.02 0.56
## 196 6.34 0.10 0.09 0.24 0.23 0.23
## 197 3.21 0.14 0.25 0.42 0.08 -0.02
## 198 6.96 0.20 0.15 0.54 0.06 -0.29
## 199 7.27 0.02 -0.04 0.76 0.09 0.79
## 200 -0.08 0.29 0.16 0.56 0.14 0.00
## 201 0.00 0.09 0.27 0.65 0.01 0.15
## 202 0.00 -0.05 0.59 0.35 0.00 0.64
## 203 7.12 0.12 0.11 0.74 0.15 0.33
## 204 4.24 0.01 0.22 0.32 0.17 0.00
## 205 7.56 0.12 0.44 0.87 0.10 -0.04
## 206 5.59 0.20 0.09 0.56 0.39 -0.24
## 207 5.10 0.16 0.41 0.48 0.04 -0.04
## 208 3.67 0.11 0.12 0.37 0.21 0.15
## 209 11.12 0.23 0.19 0.95 0.03 0.63
## 210 -0.45 0.11 0.30 0.56 0.00 0.00
## 211 0.00 0.30 0.34 1.25 0.01 0.37
## 212 7.29 0.07 0.21 0.84 0.00 0.48
## 213 12.01 0.09 0.28 0.74 0.14 1.17
## 214 3.85 0.13 0.09 0.43 0.06 0.41
## 215 4.61 0.01 -0.03 0.60 0.00 0.03
## 216 1.24 0.11 0.16 0.22 0.44 -0.04
## 217 3.45 0.11 0.47 0.34 0.17 0.50
## 218 0.91 0.15 0.04 0.47 0.00 0.05
## 219 2.78 0.16 0.04 0.56 0.22 -0.11
## 220 5.31 0.11 -0.05 0.68 0.22 0.00
## 221 4.78 0.23 0.60 0.52 0.15 0.33
## 222 15.96 0.14 0.09 0.56 0.01 0.00
## 223 6.52 0.09 0.42 1.03 0.08 0.61
## 224 2.53 0.04 0.12 0.56 0.37 0.15
## 225 2.30 0.12 0.12 0.52 0.20 -0.39
## 226 3.50 0.10 0.07 0.54 0.24 0.16
## 227 4.79 0.11 0.09 0.63 0.20 0.05
## 228 6.32 0.27 0.41 0.66 0.12 0.40
## 229 5.36 0.05 0.13 0.44 0.17 0.21
## 230 0.00 0.20 0.34 0.76 0.00 0.20
## 231 4.12 0.06 -0.10 0.39 0.18 0.01
## 232 2.69 0.01 0.00 0.71 0.32 0.20
## 233 3.66 -0.08 0.44 0.58 0.30 0.15
## 234 7.63 0.10 0.09 0.68 0.04 -0.27
## 235 2.66 0.13 0.28 0.58 0.19 0.00
## 236 0.00 0.16 0.49 0.70 0.04 0.44
## 237 2.54 0.04 0.25 0.38 0.28 -0.14
## 238 2.12 0.05 0.05 0.56 0.00 -0.10
## 239 3.58 0.04 0.09 0.28 0.31 0.18
## 240 0.00 0.05 0.01 0.51 0.04 -0.21
## 241 3.28 -0.01 0.02 0.49 0.11 -0.28
## 242 3.67 0.04 0.15 0.34 0.29 0.47
## 243 4.46 -0.02 0.45 0.46 0.11 -0.07
## 244 0.00 0.11 0.17 0.26 0.33 0.29
## 245 6.45 0.14 0.09 0.50 0.01 0.36
## 246 2.27 0.04 0.17 1.16 0.44 -0.47
## 247 0.00 0.02 -0.03 0.80 0.00 0.49
## 248 7.67 0.04 0.03 0.77 0.14 0.62
## 249 5.15 0.07 0.01 0.63 0.15 0.45
## 250 0.00 0.11 0.46 0.63 0.07 0.17
## 251 8.41 -0.01 0.07 0.64 0.08 0.31
## 252 0.00 0.17 0.29 0.81 0.05 0.00
## 253 12.89 0.12 0.14 0.56 0.00 0.24
## 254 0.00 0.07 0.36 0.49 0.24 0.00
## 255 3.62 0.02 0.45 0.64 0.00 0.30
## 256 4.35 0.14 -0.06 0.77 0.00 0.30
## 257 0.00 0.14 0.13 0.73 0.11 0.27
## 258 8.08 0.11 0.00 0.56 0.00 0.29
## 259 12.86 0.11 0.09 0.48 0.03 0.51
## 260 8.23 0.10 0.06 0.30 0.20 0.24
## 261 2.72 0.17 0.19 0.50 0.06 -0.23
## 262 5.83 0.24 0.09 0.50 0.16 -0.18
## 263 6.68 0.03 -0.01 0.95 0.17 1.04
## 264 2.70 0.11 0.17 0.56 0.07 0.00
## 265 14.57 0.11 0.52 0.70 0.00 0.14
## 266 14.87 -0.02 0.13 0.40 0.00 0.63
## 267 6.01 0.18 0.12 0.82 0.15 0.31
## 268 6.73 0.01 0.16 0.42 0.19 0.00
## 269 7.79 0.14 0.41 0.87 0.04 0.06
## 270 5.83 0.29 0.60 0.56 0.27 -0.23
## 271 6.26 0.18 0.39 0.48 0.02 -0.02
## 272 3.57 0.17 0.26 0.45 0.13 0.19
## 273 8.77 0.23 0.18 1.02 0.02 0.66
## 274 0.42 0.07 0.17 0.93 0.22 0.00
## 275 0.00 0.11 0.30 1.14 0.00 0.28
## 276 7.67 0.12 0.23 0.83 0.00 0.47
## 277 12.49 0.06 0.24 0.75 0.12 0.00
## 278 3.07 0.04 -0.02 0.32 0.10 0.35
## 279 5.32 0.02 -0.06 0.59 0.00 0.01
## 280 1.89 -0.01 0.07 0.16 0.31 -0.05
## 281 3.02 0.10 0.26 0.41 0.25 0.61
## 282 1.09 0.15 0.20 0.56 0.00 -0.13
## 283 2.91 0.19 0.08 0.56 0.16 -0.07
## 284 4.61 0.11 0.07 0.65 0.39 0.00
## 285 4.68 0.27 0.55 0.55 0.12 0.32
## 286 0.00 0.09 0.35 1.17 0.01 0.00
## 287 2.88 0.10 0.37 0.64 0.20 0.27
## 288 2.63 0.10 0.27 0.56 0.00 0.14
## 289 2.00 0.16 0.05 0.50 0.23 -0.35
## 290 3.44 0.09 -0.04 0.67 0.16 0.18
## 291 4.84 0.14 0.42 0.72 0.14 0.15
## 292 5.91 0.27 0.47 0.89 0.09 0.50
## 293 4.53 0.06 0.23 0.48 0.14 0.18
## 294 0.00 0.25 0.50 0.73 0.00 0.15
## 295 4.43 0.06 0.01 0.43 0.12 0.07
## 296 3.08 0.03 0.05 0.78 0.28 0.12
## 297 5.13 0.01 0.40 0.70 0.08 0.24
## 298 6.92 0.11 0.10 0.67 0.02 -0.26
## 299 2.80 0.15 0.19 0.59 0.11 0.00
## 300 0.00 0.26 0.50 0.86 0.01 0.54
## 301 3.07 0.11 0.18 0.44 0.34 -0.18
## 302 2.74 0.09 0.04 0.77 0.40 -0.07
## 303 3.13 0.02 0.09 0.29 0.32 0.20
## 304 0.00 0.06 0.05 0.38 0.10 -0.14
## 305 4.61 -0.01 0.04 0.53 0.05 -0.28
## 306 2.74 -0.06 0.23 0.69 0.19 0.92
## 307 4.10 0.18 0.46 0.47 0.11 -0.07
## 308 0.00 0.30 -0.10 0.34 0.18 0.30
## 309 5.57 0.15 0.33 0.51 0.04 0.35
## 310 2.28 0.11 0.19 1.19 0.30 -0.51
## 311 14.24 0.14 0.06 0.80 0.00 0.63
## 312 6.71 0.05 -0.02 0.76 0.10 0.50
## 313 4.77 0.09 0.02 0.69 0.13 0.50
## 314 5.24 0.00 0.10 0.78 0.07 0.09
## 315 5.92 0.13 0.14 0.54 0.25 0.20
## 316 14.93 0.11 0.16 0.92 0.06 0.00
## 317 13.62 0.13 0.09 0.52 0.00 0.24
## 318 -4.44 0.12 0.21 0.63 0.10 0.00
## 319 3.53 0.08 0.23 0.71 0.00 0.30
## 320 5.87 0.13 -0.01 0.97 0.19 0.29
## 321 4.94 0.14 0.11 0.77 0.11 0.21
## 322 9.06 0.12 -0.15 0.56 0.00 0.27
## 323 14.23 0.11 0.12 0.54 0.03 0.57
## 324 7.16 0.05 0.00 0.28 0.14 0.27
## 325 4.29 0.15 0.19 0.54 0.06 -0.44
## 326 4.98 0.21 0.15 0.41 0.19 -0.11
## 327 7.41 0.02 0.05 0.77 0.10 1.10
## 328 9.18 0.11 0.17 1.12 0.01 0.00
## 329 12.38 0.15 0.16 0.58 0.01 0.21
## 330 0.00 -0.01 0.24 0.31 0.03 0.48
## 331 6.93 0.16 0.07 0.76 0.12 0.27
## 332 4.62 0.04 0.22 0.33 0.27 0.05
## 333 12.94 0.15 0.37 0.70 0.02 0.10
## 334 6.51 0.29 0.69 0.56 0.17 -0.23
## 335 6.78 0.15 0.29 0.43 0.03 0.02
## 336 3.67 0.17 0.24 0.53 0.10 0.01
## 337 8.84 0.15 0.12 1.04 0.05 0.65
## 338 5.51 0.08 0.22 0.88 0.04 -0.41
## 339 0.00 0.11 0.37 1.02 0.02 0.23
## 340 6.17 0.00 0.18 0.66 0.00 0.38
## 341 13.32 0.05 0.19 0.81 0.09 0.00
## 342 3.19 0.05 -0.12 0.41 0.10 0.31
## 343 6.51 0.02 -0.02 0.56 0.00 -0.08
## 344 2.19 0.01 0.01 0.15 0.31 0.02
## 345 2.79 0.10 0.37 0.40 0.38 0.55
## 346 0.91 0.16 -0.08 0.56 0.00 -0.11
## 347 2.95 0.19 0.17 0.56 0.20 -0.01
## 348 4.90 -0.01 -0.14 0.38 0.00 1.01
## 349 5.49 0.15 0.28 0.53 0.11 0.31
## 350 0.00 0.19 0.69 1.08 0.01 0.00
## 351 4.37 0.12 0.26 0.59 0.23 0.23
## 352 2.84 0.05 0.04 0.56 0.00 0.14
## 353 2.04 0.15 0.15 0.50 0.23 -0.38
## 354 5.64 0.07 0.08 0.65 0.09 0.18
## 355 5.19 0.11 0.58 0.51 0.18 0.12
## 356 7.27 0.20 0.38 0.80 0.17 0.69
## 357 3.55 0.05 0.14 0.29 0.00 0.08
## 358 0.00 0.18 0.30 0.66 0.00 0.15
## 359 5.73 0.08 0.00 0.44 0.08 0.05
## 360 3.71 0.02 -0.08 0.74 0.21 0.04
## 361 5.16 -0.02 0.30 0.48 0.12 0.50
## 362 11.95 0.10 0.10 0.57 0.02 -0.19
## 363 2.87 0.11 0.18 0.70 0.10 -0.02
## 364 0.00 0.21 0.52 0.88 0.02 0.66
## 365 4.15 0.05 0.14 0.44 0.21 -0.12
## 366 3.35 0.08 0.02 0.65 0.37 0.04
## 367 3.07 0.23 0.24 0.36 0.33 0.17
## 368 0.00 0.06 0.01 0.44 0.07 -0.12
## 369 4.64 0.01 -0.04 0.47 0.09 -0.22
## 370 4.82 0.11 0.33 0.74 0.18 0.02
## 371 7.10 0.20 0.40 0.53 0.11 -0.08
## 372 0.00 0.30 0.26 0.26 0.15 0.30
## 373 8.64 0.13 0.48 0.52 0.01 0.40
## 374 2.96 0.04 -0.01 1.17 0.34 -0.53
## 375 0.00 0.15 -0.04 0.70 0.00 0.77
## 376 9.59 0.05 -0.01 0.69 0.08 0.47
## 377 5.31 0.07 -0.02 0.68 0.13 0.62
## 378 8.04 0.14 0.42 0.82 0.04 0.10
## 379 6.02 0.03 0.07 0.54 0.25 0.18
## 380 0.00 0.15 0.21 0.80 0.05 0.00
## 381 0.00 0.15 0.07 0.50 0.00 0.27
## 382 0.00 0.14 0.20 0.66 0.08 0.00
## 383 2.94 0.09 0.34 0.63 0.00 0.33
## 384 7.98 0.18 -0.02 0.95 0.10 0.26
## 385 6.96 0.13 0.22 0.85 0.06 0.00
## 386 8.45 0.10 -0.16 1.20 0.02 0.07
## 387 0.00 0.11 0.12 0.53 0.02 0.07
## 388 7.44 0.03 0.00 0.26 0.12 0.14
## 389 6.52 0.13 0.26 0.53 0.06 0.00
## 390 4.33 0.18 0.14 0.41 0.16 0.00
## 391 8.31 0.06 0.05 0.77 0.10 0.01
## 392 0.00 0.11 0.13 1.09 0.01 0.20
## 393 12.92 0.14 0.19 0.49 0.00 0.00
## 394 0.00 -0.02 0.27 0.28 0.03 0.00
## 395 7.54 0.15 0.15 0.70 0.10 -0.07
## 396 4.84 0.06 0.18 0.31 0.29 0.01
## 397 0.00 0.18 0.36 0.68 0.01 0.30
## 398 5.72 0.16 0.69 0.56 0.22 0.00
## 399 6.65 0.12 0.20 0.31 0.04 0.14
## 400 3.88 0.15 0.16 0.52 0.08 0.11
## 401 9.17 0.08 0.11 0.98 0.04 -0.02
## 402 0.00 0.08 0.15 0.65 0.02 0.00
## 403 0.00 0.30 0.41 0.98 0.01 0.70
## 404 5.35 0.01 0.18 0.50 0.10 0.00
## 405 13.99 0.04 0.12 0.81 0.08 0.65
## 406 3.75 0.07 -0.09 0.38 0.05 0.00
## 407 6.99 0.01 0.02 0.64 0.00 0.00
## 408 0.84 0.02 0.09 0.32 0.40 0.89
## 409 2.73 0.15 0.42 0.37 0.32 0.03
## 410 0.57 0.17 0.11 0.50 0.00 0.30
## 411 2.63 0.20 0.12 0.56 0.32 0.00
## 412 4.82 0.06 -0.09 0.35 0.00 -0.01
## 413 4.40 0.16 0.33 0.51 0.19 -0.11
## 414 14.11 0.15 0.65 0.70 0.04 0.09
## 415 3.58 0.12 0.30 0.56 0.20 0.00
## 416 2.67 0.05 0.07 0.56 0.00 0.05
## 417 1.82 0.16 0.17 0.47 0.32 -0.05
## 418 6.21 0.07 0.21 0.58 0.10 0.62
## 419 6.26 0.13 0.58 0.63 0.12 0.00
## 420 7.77 0.17 0.37 0.69 0.14 0.17
## 421 4.37 0.02 0.14 0.30 0.00 -0.01
## 422 0.00 0.20 0.40 0.70 0.00 0.00
## 423 7.50 0.08 0.05 0.47 0.05 0.00
## 424 3.70 -0.01 -0.04 0.68 0.20 -0.03
## 425 5.19 0.04 0.30 0.40 0.14 0.12
## 426 0.00 0.03 0.11 0.52 0.02 -0.32
## 427 2.85 0.08 0.17 0.72 0.19 -0.25
## 428 0.00 0.18 0.53 0.63 0.02 0.00
## 429 3.94 0.04 0.17 0.43 0.18 0.10
## 430 3.21 0.07 0.05 0.61 0.27 0.00
## 431 2.72 0.18 0.28 0.34 0.00 -0.02
## 432 0.00 0.06 0.00 0.38 0.14 -0.02
## 433 5.79 0.05 0.06 0.43 0.13 0.00
## 434 5.80 0.11 0.32 0.66 0.13 0.28
## 435 6.94 0.25 0.47 0.49 0.18 0.00
## 436 0.00 0.20 0.41 0.20 0.22 0.13
## 437 10.25 0.14 0.53 0.46 0.02 0.54
## 438 2.60 0.04 0.03 1.18 0.35 0.00
## 439 0.00 0.12 -0.11 0.66 0.01 0.15
## 440 9.20 0.03 0.01 0.67 0.08 0.00
## 441 4.96 0.05 -0.03 0.63 0.15 0.16
## 442 11.42 0.16 0.33 0.85 0.02 0.35
## 443 5.82 0.02 0.12 0.47 0.19 0.15
## 444 0.00 0.06 0.21 0.75 0.05 -0.22
## 445 0.00 0.13 0.08 0.43 0.00 0.00
## 446 0.00 0.13 0.09 0.72 0.07 0.00
## 447 2.87 0.13 0.23 0.65 0.00 0.06
## 448 9.60 0.18 0.07 0.83 0.07 0.00
## 449 8.19 0.11 0.10 1.04 0.06 0.04
## 450 10.40 0.14 -0.18 1.17 0.02 0.29
## 451 0.00 0.09 0.19 0.58 0.02 0.72
## 452 6.49 0.05 -0.03 0.14 0.08 0.14
## 453 6.57 0.14 0.24 0.52 0.03 -0.32
## 454 4.55 0.18 0.09 0.43 0.15 0.01
## 455 10.79 0.08 0.07 0.89 0.05 1.05
## 456 0.00 0.11 0.10 0.56 0.00 -0.57
## 457 0.00 0.13 0.13 0.51 0.00 0.31
## 458 15.85 -0.03 -0.05 0.30 0.03 0.53
## 459 7.90 0.12 0.18 0.74 0.10 0.23
## 460 6.58 0.13 0.25 0.36 0.18 0.00
## 461 0.00 0.21 0.29 0.68 0.01 0.40
## 462 5.61 0.16 0.42 0.56 0.26 0.00
## 463 7.14 0.16 0.21 0.32 0.03 0.03
## 464 4.77 0.17 0.10 0.51 0.05 -0.03
## 465 8.52 0.08 0.04 1.04 0.04 0.62
## 466 0.00 0.10 0.14 0.66 0.04 -0.09
## 467 0.00 0.11 0.45 1.07 0.01 0.29
## 468 6.25 0.05 0.19 0.52 0.06 0.39
## 469 12.74 0.04 0.12 0.84 0.12 0.00
## 470 4.95 0.12 -0.10 0.39 0.04 0.31
## 471 12.32 0.01 0.06 0.56 0.02 0.02
## 472 1.70 0.02 0.03 0.40 0.30 -0.52
## 473 2.60 0.29 0.35 0.47 0.25 0.54
## 474 0.89 0.21 0.06 0.48 0.00 -0.15
## 475 2.84 0.31 0.03 0.56 0.27 0.00
## 476 4.42 0.09 -0.09 0.43 0.00 0.00
## 477 3.98 0.24 0.35 0.47 0.18 0.32
## 478 0.00 0.16 0.65 0.62 0.02 0.70
## 479 4.93 0.12 0.24 0.64 0.12 0.27
## 480 2.75 0.11 0.14 0.56 0.41 0.12
## 481 2.03 0.18 0.17 0.53 0.16 -0.31
## 482 8.45 0.04 0.03 0.64 0.06 0.33
## 483 8.68 0.17 0.57 0.67 0.07 0.06
## 484 10.34 0.19 0.26 0.92 0.06 0.72
## 485 5.23 0.07 0.09 0.33 0.21 0.21
## 486 0.00 0.27 0.38 0.76 0.00 0.14
## 487 10.05 0.08 0.05 0.50 0.04 0.10
## 488 4.37 0.02 -0.03 0.67 0.13 0.10
## 489 6.28 0.08 0.33 0.47 0.09 0.57
## 490 13.88 0.11 0.12 0.55 0.02 -0.03
## 491 3.15 0.08 0.14 0.61 0.17 0.00
## 492 0.00 0.28 0.51 0.58 0.02 0.52
## 493 4.28 0.13 0.23 0.53 0.18 -0.14
## 494 5.00 0.03 0.05 0.70 0.11 0.12
## 495 2.30 0.24 0.20 0.31 0.39 -0.10
## 496 3.53 0.08 0.04 0.42 0.09 -0.11
## 497 5.53 0.14 -0.09 0.40 0.12 -0.01
## 498 6.67 0.14 0.32 0.81 0.11 0.13
## 499 6.43 0.11 0.46 0.56 0.08 0.00
## 500 0.00 0.16 0.16 0.20 0.16 0.33
## 501 12.57 0.15 0.43 0.48 0.01 0.43
## 502 2.93 0.06 -0.02 1.23 0.26 -0.57
## 503 8.99 0.16 -0.02 0.59 0.09 0.56
## 504 10.74 0.06 0.01 0.61 0.06 0.00
## 505 5.91 0.05 -0.03 0.70 0.10 0.48
## 506 13.93 0.10 0.49 0.97 0.01 -0.06
## 507 6.96 0.12 0.13 0.52 0.07 0.23
## 508 0.00 0.11 0.23 0.74 0.05 0.00
## 509 0.00 0.14 0.11 0.34 0.06 0.19
## 510 0.00 0.11 0.27 0.67 0.06 0.00
## 511 3.18 0.11 0.22 0.65 0.41 0.26
## 512 10.81 0.11 -0.01 0.91 0.04 0.36
## 513 6.27 0.11 0.10 1.12 0.06 0.00
## 514 8.12 0.12 -0.17 0.56 0.02 0.07
## 515 13.22 0.07 0.09 0.65 0.03 0.22
## 516 7.38 0.05 -0.03 0.24 0.09 0.08
## 517 3.61 0.14 0.24 0.51 0.06 -0.54
## 518 3.82 0.20 0.09 0.43 0.15 0.00
## 519 8.45 0.10 0.06 0.96 0.08 0.01
## 520 15.34 0.11 0.10 0.56 0.00 0.18
## 521 15.22 0.15 0.12 0.51 0.00 0.97
## 522 11.79 -0.02 -0.15 0.30 0.03 0.00
## 523 6.99 0.12 0.18 0.74 0.10 -0.17
## 524 7.04 0.16 0.24 0.45 0.20 0.02
## 525 0.00 0.23 0.20 0.68 0.01 0.46
## 526 4.44 0.23 0.55 0.56 0.26 0.00
## 527 3.19 0.16 0.21 0.28 0.06 0.08
## 528 4.22 0.22 0.05 0.55 0.06 0.15
## 529 7.47 0.08 0.01 1.04 0.04 0.02
## 530 14.63 0.10 0.14 0.66 0.04 0.00
## 531 14.44 0.11 0.45 1.07 0.01 0.97
## 532 4.33 0.09 0.16 0.51 0.08 0.00
## 533 15.03 0.04 0.12 0.96 0.18 0.78
## 534 8.26 0.12 -0.10 0.39 0.04 0.00
## 535 5.60 0.01 0.01 0.56 0.02 0.00
## 536 1.99 0.02 0.03 0.40 0.24 1.08
## 537 2.70 0.29 0.35 0.47 0.25 0.04
## 538 0.85 0.22 0.03 0.50 0.00 0.28
## 539 2.68 0.11 -0.05 0.56 0.00 0.00
## 540 5.20 0.07 -0.14 0.43 0.00 -0.01
## 541 2.95 0.29 0.34 0.47 0.18 -0.09
## 542 11.85 0.16 0.65 0.46 0.06 -0.10
## 543 5.23 0.10 0.11 0.64 0.12 0.00
## 544 2.62 0.19 0.16 0.56 0.00 0.07
## 545 2.10 0.18 0.17 0.53 0.16 0.07
## 546 7.76 0.04 0.03 0.67 0.06 0.00
## 547 5.83 0.17 0.57 0.73 0.15 0.00
## 548 7.65 0.17 0.23 1.00 0.08 0.16
## 549 5.90 0.07 0.09 0.42 0.19 0.02
## 550 0.00 0.29 0.32 0.76 0.00 0.47
## 551 7.79 0.12 0.03 0.54 0.04 0.00
## 552 4.13 0.01 -0.05 0.67 0.13 0.00
## 553 4.26 0.08 0.33 0.46 0.12 0.13
## 554 7.35 0.13 0.13 0.55 0.02 -0.25
## 555 2.53 0.08 0.14 0.63 0.18 -0.43
## 556 15.26 0.31 0.45 0.61 0.02 0.00
## 557 3.42 0.13 0.23 0.53 0.18 0.13
## 558 5.60 0.07 0.05 0.70 0.11 0.00
## 559 1.92 0.11 0.18 0.39 0.41 -0.01
## 560 2.13 0.07 0.01 0.45 0.08 0.03
## 561 6.00 0.14 -0.12 0.41 0.13 0.00
## 562 5.99 0.16 0.35 0.90 0.12 0.30
## 563 4.71 0.11 0.46 0.62 0.16 -0.09
## 564 0.00 0.09 0.05 0.20 0.16 0.14
## 565 10.83 0.15 0.43 0.54 0.01 0.55
## 566 1.87 0.11 0.07 0.56 0.39 0.00
## 567 6.48 0.16 -0.02 0.62 0.18 0.26
## 568 5.18 0.07 0.01 0.38 0.22 0.00
## 569 5.48 0.05 -0.03 0.78 0.13 0.22
## 570 9.83 0.10 0.49 0.97 0.01 0.50
## 571 5.77 0.12 0.13 0.51 0.13 0.20
## 572 14.16 0.15 0.21 0.74 0.05 -0.26
## 573 6.55 0.14 0.11 0.34 0.06 0.00
## 574 -4.47 0.12 0.20 0.67 0.06 0.00
## 575 3.20 0.11 0.22 0.72 0.00 0.08
## 576 7.99 0.11 0.11 0.91 0.04 0.00
## 577 8.34 0.13 0.12 1.09 0.05 0.00
## 578 9.44 0.09 -0.18 1.25 0.02 0.07
## 579 0.00 0.07 0.09 0.65 0.01 0.25
## 580 8.33 0.06 -0.02 0.25 0.09 0.09
## 581 4.63 0.17 0.25 0.53 0.06 -0.15
## 582 4.66 0.17 0.10 0.44 0.24 0.00
## 583 10.38 0.07 -0.06 0.86 0.05 0.01
## 584 13.11 0.11 -0.05 0.35 0.03 0.05
## 585 0.00 0.15 0.12 0.65 0.00 -0.45
## 586 15.68 0.03 -0.12 0.31 0.04 0.00
## 587 8.34 0.01 0.10 0.82 0.11 -0.29
## 588 10.72 0.03 0.22 0.49 0.11 0.01
## 589 0.00 0.21 0.19 0.69 0.02 0.48
## 590 5.55 0.10 0.40 0.56 0.25 0.00
## 591 4.84 0.17 0.22 0.32 0.09 0.09
## 592 4.15 -0.05 0.04 0.56 0.04 0.18
## 593 8.80 0.09 0.07 1.09 0.05 0.03
## 594 6.88 0.08 0.14 0.76 0.04 1.16
## 595 13.84 0.11 0.41 1.20 0.01 1.14
## 596 5.73 -0.05 0.10 0.54 0.03 0.00
## 597 0.00 0.06 0.16 0.96 0.09 0.86
## 598 5.82 0.15 -0.11 0.32 0.01 0.00
## 599 5.20 0.01 0.01 0.71 0.03 0.00
## 600 2.40 0.03 0.05 0.21 0.00 0.55
## 601 2.64 0.02 0.13 0.48 0.30 0.04
## 602 1.07 0.22 0.10 0.51 0.00 0.29
## 603 2.48 0.11 0.00 0.56 0.41 0.00
## 604 5.71 0.10 -0.07 0.48 0.42 -0.02
## 605 2.90 0.28 0.33 0.35 0.39 -0.08
## 606 16.31 0.23 0.63 0.52 0.05 -0.07
## 607 6.56 0.10 -0.02 0.75 0.12 0.00
## 608 3.18 0.22 0.18 0.56 0.24 0.09
## 609 2.18 0.21 0.07 0.57 0.17 0.13
## 610 7.21 0.05 -0.01 0.63 0.10 0.00
## 611 7.05 0.26 0.56 0.75 0.09 0.00
## 612 10.34 0.13 0.26 0.93 0.06 0.17
## 613 7.19 0.05 0.08 0.52 0.14 0.04
## 614 0.00 0.25 0.38 0.87 0.00 0.78
## 615 10.44 0.12 0.04 0.51 0.03 0.00
## 616 4.58 0.04 -0.05 0.71 0.15 -0.03
## 617 3.98 0.00 0.33 0.24 0.18 0.15
## 618 11.30 0.11 0.16 0.54 0.03 -0.20
## 619 2.94 0.09 0.13 0.65 0.20 -0.55
## 620 0.00 0.28 0.48 0.65 0.02 0.00
## 621 4.34 0.20 0.31 0.57 0.28 0.16
## 622 6.39 0.08 0.02 0.70 0.13 1.07
## 623 2.14 0.15 0.25 0.37 0.33 -0.01
## 624 4.77 0.07 0.01 0.48 0.03 0.05
## 625 5.73 0.08 -0.10 0.33 0.11 0.00
## 626 6.00 0.16 0.32 0.70 0.13 0.36
## 627 4.14 0.24 0.43 0.53 0.21 -0.20
## 628 12.67 0.11 0.06 0.20 0.15 0.15
## 629 14.71 0.14 0.50 0.57 0.01 0.52
## 630 0.35 0.19 0.00 0.98 0.00 0.00
## 631 8.46 0.07 -0.06 0.57 0.10 0.36
## 632 6.15 0.08 0.10 0.38 0.22 0.00
## 633 5.65 0.06 -0.04 0.74 0.12 0.25
## 634 12.35 0.15 0.53 0.90 0.01 0.62
## 635 5.71 0.16 0.16 0.51 0.13 0.33
## 636 13.44 -0.09 0.26 0.74 0.06 -0.26
## 637 9.06 0.13 0.05 0.39 0.08 0.00
## 638 0.00 0.10 0.12 0.82 0.08 0.00
## 639 2.30 0.16 0.12 0.50 0.00 0.10
## 640 5.97 0.11 0.12 0.77 0.17 0.00
identify_outliers(replaced_data, Alt)
identify_outliers(replaced_data, EBIT)
identify_outliers(replaced_data, NWC)
identify_outliers(replaced_data, Sale)
identify_outliers(replaced_data, equity)
identify_outliers(replaced_data, RE)
boxplot(replaced_data[,c(1,2,3,4,5,6)], main='Multiple Box plots')
p.Alt <- ggplot(mapping = aes(x = replaced_data$Alt)) +
geom_histogram(binwidth = 5, fill = "#69b3a2", color = "#e9ecef", alpha = 0.9) +
xlab("Alt") + # Title for x-axis
ylab("Frequency") + # Title for y-axis
theme(
plot.title = element_text(size = 15)
)
print(p.Alt)
#### EBIT variable
p <- ggplot(mapping = aes(x = replaced_data$EBIT)) +
geom_histogram(binwidth = 0.05, fill = "#69b3a2", color = "#e9ecef", alpha = 0.9) +
xlab("EBIT") + # Title for x-axis
ylab("Frequency") + # Title for y-axis
theme(
plot.title = element_text(size = 15)
)
print(p)
#### NWC variable
p <- ggplot(mapping = aes(x = replaced_data$NWC)) +
geom_histogram(binwidth = 0.05, fill = "#69b3a2", color = "#e9ecef", alpha = 0.9) +
xlab("NWC") + # Title for x-axis
ylab("Frequency") + # Title for y-axis
theme(
plot.title = element_text(size = 15)
)
print(p)
#### Sale variable
p <- ggplot(mapping = aes(x = replaced_data$Sale)) +
geom_histogram(binwidth = 0.05, fill = "#69b3a2", color = "#e9ecef", alpha = 0.9) +
xlab("Sale") + # Title for x-axis
ylab("Frequency") + # Title for y-axis
theme(
plot.title = element_text(size = 15)
)
print(p)
p <- ggplot(mapping = aes(x = replaced_data$equity)) +
geom_histogram(binwidth = 0.05, fill = "#69b3a2", color = "#e9ecef", alpha = 0.9) +
xlab("Equity") + # Title for x-axis
ylab("Frequency") + # Title for y-axis
theme(
plot.title = element_text(size = 15)
)
print(p)
#### Equity variable
p <- ggplot(mapping = aes(x = replaced_data$RE)) +
geom_histogram(binwidth = 0.15, fill = "#69b3a2", color = "#e9ecef", alpha = 0.9) +
xlab("RE") + # Title for x-axis
ylab("Frequency") + # Title for y-axis
theme(
plot.title = element_text(size = 15)
)
print(p)
p5 <- ggplot(replaced_data, aes(x = EBIT, y = Alt))
p5 + geom_line(aes(color = EBIT))
p5 <- ggplot(replaced_data, aes(x = NWC, y = Alt))
p5 + geom_line(aes(color = NWC))
p5 <- ggplot(replaced_data, aes(x = Sale, y = Alt))
p5 + geom_line(aes(color = Sale))
p5 <- ggplot(replaced_data, aes(x = equity, y = Alt))
p5 + geom_line(aes(color = equity))
p5 <- ggplot(replaced_data, aes(x = RE, y = Alt))
p5 + geom_line(aes(color = RE))
### Scatterplot and correlation
To make things easier, we will extract the two variables we are using into their own variable form.
# with linear trend
p2 <- ggplot(replaced_data, aes(x=EBIT, y=Alt)) +
geom_point() +
geom_smooth(method=lm , color="red", se=FALSE) +
theme_ipsum()
p2
## `geom_smooth()` using formula = 'y ~ x'
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## not found in Windows font database
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
# scatter plot
p3 <- ggplot(replaced_data, aes(x=NWC, y=Alt)) +
geom_point() +
geom_smooth(method=lm , color="red", se=FALSE) +
theme_ipsum()
p3
## `geom_smooth()` using formula = 'y ~ x'
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
# scatter plot
p4 <- ggplot(replaced_data, aes(x=Sale, y=Alt)) +
geom_point() +
geom_smooth(method=lm , color="red", se=FALSE) +
theme_ipsum()
p4
## `geom_smooth()` using formula = 'y ~ x'
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
# scatter plot
p5 <- ggplot(replaced_data, aes(x=equity, y=Alt)) +
geom_point() +
geom_smooth(method=lm , color="red", se=FALSE) +
theme_ipsum()
p5
## `geom_smooth()` using formula = 'y ~ x'
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
# scatter plot
p7 <- ggplot(replaced_data, aes(x=RE, y=Alt)) +
geom_point() +
geom_smooth(method=lm , color="red", se=FALSE) +
theme_ipsum()
p7
## `geom_smooth()` using formula = 'y ~ x'
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
The scatterplot shows that there is a relationship between the Alt and explaintory variables, including EBIT, NWC, Sale, Equity, RE. Let’s check the correlation:
corr.test(x=replaced_data, method = "pearson")
## Call:corr.test(x = replaced_data, method = "pearson")
## Correlation matrix
## Alt EBIT NWC Sale equity RE
## Alt 1.00 -0.10 0.00 0.14 -0.21 0.22
## EBIT -0.10 1.00 0.31 0.09 -0.05 -0.02
## NWC 0.00 0.31 1.00 0.10 -0.01 0.05
## Sale 0.14 0.09 0.10 1.00 -0.19 0.15
## equity -0.21 -0.05 -0.01 -0.19 1.00 -0.13
## RE 0.22 -0.02 0.05 0.15 -0.13 1.00
## Sample Size
## [1] 640
## Probability values (Entries above the diagonal are adjusted for multiple tests.)
## Alt EBIT NWC Sale equity RE
## Alt 0.00 0.08 1.00 0.00 0.00 0.00
## EBIT 0.01 0.00 0.00 0.16 0.98 1.00
## NWC 0.97 0.00 0.00 0.08 1.00 0.98
## Sale 0.00 0.03 0.01 0.00 0.00 0.00
## equity 0.00 0.23 0.74 0.00 0.00 0.01
## RE 0.00 0.68 0.20 0.00 0.00 0.00
##
## To see confidence intervals of the correlations, print with the short=FALSE option
cor_mat(replaced_data)
#plot the data and see the correlation
base.matrix <- cor_mat(replaced_data)
tidy.matrix <- pull_lower_triangle(base.matrix)
cor_plot(tidy.matrix)
shapiro_test(replaced_data$Alt)
shapiro_test(replaced_data$EBIT)
shapiro_test(replaced_data$NWC)
shapiro_test(replaced_data$Sale)
shapiro_test(replaced_data$equity)
shapiro_test(replaced_data$RE)
Non of variable has the normal distribution.
# Correlation
cor.test(replaced_data$Alt,replaced_data$EBIT)
##
## Pearson's product-moment correlation
##
## data: replaced_data$Alt and replaced_data$EBIT
## t = -2.5733, df = 638, p-value = 0.0103
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.17745888 -0.02403988
## sample estimates:
## cor
## -0.1013519
# Correlation
cor.test(replaced_data$Alt,replaced_data$NWC)
##
## Pearson's product-moment correlation
##
## data: replaced_data$Alt and replaced_data$NWC
## t = -0.032548, df = 638, p-value = 0.974
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.07878159 0.07621990
## sample estimates:
## cor
## -0.001288587
# Correlation
cor.test(replaced_data$Alt,replaced_data$Sale)
##
## Pearson's product-moment correlation
##
## data: replaced_data$Alt and replaced_data$Sale
## t = 3.613, df = 638, p-value = 0.0003265
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.06480876 0.21672099
## sample estimates:
## cor
## 0.1415984
# Correlation
cor.test(replaced_data$Alt,replaced_data$equity)
##
## Pearson's product-moment correlation
##
## data: replaced_data$Alt and replaced_data$equity
## t = -5.3428, df = 638, p-value = 1.275e-07
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.2799552 -0.1315534
## sample estimates:
## cor
## -0.2069444
# Correlation
cor.test(replaced_data$Alt,replaced_data$RE)
##
## Pearson's product-moment correlation
##
## data: replaced_data$Alt and replaced_data$RE
## t = 5.8126, df = 638, p-value = 9.719e-09
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1493576 0.2966082
## sample estimates:
## cor
## 0.2242626
The line of best fit is the statistical estimate (“best guess”) for the coefficients in the model \[ y = \beta_0 + \beta_1 x \] which for us can be rewritten as \[ \text{Alt} = \beta_0 + \beta_1 \cdot \text{EBIT}+ \beta_2 \cdot \text{NWC}+ \beta_3 \cdot \text{Sale}+ \beta_4 \cdot \text{Equity}+ \beta_5 \cdot \text{RE} \]
# fit the model and pull out the coefficients:
p_mod <- lm(Alt ~ EBIT+ NWC + Sale + equity + RE, data = replaced_data)
p_mod$coefficients
## (Intercept) EBIT NWC Sale equity RE
## 5.0276682 -6.3232083 0.3267776 1.6921419 -6.3646423 2.3690832
summary(p_mod)
##
## Call:
## lm(formula = Alt ~ EBIT + NWC + Sale + equity + RE, data = replaced_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.556 -1.891 -0.253 2.024 12.135
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.0277 0.5450 9.225 < 2e-16 ***
## EBIT -6.3232 2.1091 -2.998 0.00282 **
## NWC 0.3268 0.8522 0.383 0.70152
## Sale 1.6921 0.7180 2.357 0.01875 *
## equity -6.3646 1.4288 -4.455 9.94e-06 ***
## RE 2.3691 0.4871 4.864 1.45e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.7 on 634 degrees of freedom
## Multiple R-squared: 0.1023, Adjusted R-squared: 0.09525
## F-statistic: 14.45 on 5 and 634 DF, p-value: 2.001e-13
So from the output of the model, we have the intercept (\(\beta_0\)) equaling 149.7477, and the slope (\(\beta_1\)) equalling 0.25924. We can round these - that much precision is silly - giving our model fit as
\[ \text{Alt} = 6.92 + 14.2 \cdot \text{EBIT} +3.70 \cdot \text{NWC}+ 0.87 \cdot \text{Sale} -16.23 \cdot \text{Equity}+ 0.20 \cdot \text{RE} \]
We can interpret this as follows:
plot(p_mod, which = 1:2)
shapiro.test(p_mod$residuals)
##
## Shapiro-Wilk normality test
##
## data: p_mod$residuals
## W = 0.97779, p-value = 2.836e-08
hist(p_mod$residuals)