Knitted R Code - FRA Project
Knitted R Code - FRA Project
$`Adjusted
EPS` [1] 0
$Borrowings
[1] 301
$`Capital
employed` [1] 0
$`Cash profit`
[1] 108
$Default
[1] 0
$EPS
[1] 0
$Investments
[1] 1155
## Now replacing the NA by the mean value for the given attribute:
mean_values = array()
##Replace the rest of missing NAs with mean values in TRAINING data.
for (i in 1:length(data_training)) {
mean_values[i] = mean(data_training[,i],na.rm=T)
data_training[,i][is.na(data_training[,i])] <-
mean_values[i]
}
#Replace the rest of missing NAs with mean values for given
training & validation data.
data_validation_non_missing = data_validation
for (i in 1:length(data_validation_non_missing)) {
data_validation_non_missing[,i]
[is.na(data_validation_non_missing[,i])] <-
mean(data_validation_non_missing[,i],na.rm=T)
}
#Code for the capping for 99% & 1% values to reduce
the number of outliers:
## Remove Outliers
data_summary = summary(data_training)
data_summary
col_length = ncol(data_summary)
View(data_training)
data_training_pruned
=data_training
View(data_training_pru
ned)
#Remove anything above 99% and Remove anything below 1%
for (i in 2:col_length) {
# for (i in 2:18) {
if (colnames(data_training_pruned)[i] != "Default") {
topmost = quantile(data_training[,i], 0.99)
bottommost = quantile(data_training[,i], 0.01)
data_training_pruned = training_pruned[data_training_pruned[,i] <
topmost,]
#Logistic Regression
library(ISLR)
library(dplyr)
library(ggvis)
library(boot)
library(rJava)
str(data)
## 'data.frame': 3541 obs. of 52 variables:
## $ X...Num : int 12345 6789
10 ...
## $ Default : int 11111 1111
0 ...
## $ Total.assets : int 17512 941 233 3
479 2434 327 80 574 89 ...
## $ Net.worth : int 7093 352 101 3 108
676 245 13 239 20 ...
## $ Total.income : int 24965 1527 477 0
1581 2649 0 154 583 83 ...
## $ Change.in.stock : int 236 43 -5 0 -17 62
0 -9 31 -7 ...
## $ Total.expenses : int 23658 1455 479 0
1558 2636 0 144 565 79 ...
## $ Profit.after.tax : int 1543 115 -7 0 6 75
0 1 48 -2 ...
## $ PBDITA : int 2860 283 6 0 31
200 0 10 110 0 ...
## $ PBT : int 2417 188 -7 0 6 75
0 2 69 -14 ...
## $ Cash.profit : int 1873 159 0 0 12
147 0 4 83 -11 ...
## $ PBDITA.as...of.total.income : int 11 19 1 0 2 8 0 6
19 0 ...
## $ PBT.as...of.total.income : int 10 12 -1 0 0 3 0 1
12 -17 ...
## $ PAT.as...of.total.income : int 6 8 -1 0 0 3 0 1 8
-3 ...
## $ Cash.profit.as...of.total.income : int 8 10 0 0 1 6 0 3
14 -13 ...
## $ PAT.as...of.net.worth : int 24 38 -6 0 5 22 0
10 22 -12 ...
## $ Sales : int 24458 1504 476 1
1575 2640 1 153 574 83 ...
## $ Income.from.financial.services : int 158 4 2 0 4 6 0 0
7 0 ...
## $ Other.income : int 297 16 0 0 1 0 0 0
1 0 ...
## $ Total.capital : int 424 116 81 1 6 34
78 10 58 50 ...
## $ Reserves.and.funds : int 6823 258 19 2 162
972 241 -2 201 -30 ...
## $ Deposits..accepted.by.commercial.banks. : logi NA NA NA NA NA NA
...
## $ Borrowings : int 15 273 35 0 193
717 8 29 204 61 ...
## $ Current.liabilities...provisions: int 9966 210 97 0 113
556 0 37 75 2 ...
## $ Deferred.tax.liability : int 285 85 0 0 5 54 0
1 36 5 ...
## $ Shareholders.funds : int 7093 352 101 3 108
698 315 13 259 20 ...
## $ Cumulative.retained.profits : int 6263 247 32 2 83
318 -4 -2 174 -30 ...
## $ Capital.employed : int 7108 624 136 3 301
1415 323 42 463 81 ...
## $ TOL.TNW : int 1 1 1 0 3 2 0 5 1
3 ...
## $ Total.term.liabilities...tangible.net.worth: int 0 0 0 0 2 0 0 1 0
1 ...
## $ Contingent.liabilities...Net.worth.... : int 15 19 46 0 35
36 0
0 40 0 ...
## $ Contingent.liabilities : int 1050 68 46 0 38
245 0 0 95 0 ...
## $ Net.fixed.assets : int 1900 286 39 3 95
865 0 10 207 24 ...
## $ Investments : int 1070 2 4 0 7 23
298 0 0 7 ...
## $ Current.assets : int 13278 564 168 0
350 1296 21 62 328 27 ...
## $ Net.working.capital : int 3589 204 60 0 216
279 21 8 120 -26 ...
## $ Quick.ratio..times. : int 111010011
0 ...
## $ Current.ratio..times. : int 122031012
1 ...
## $ Debt.to.equity.ratio..times. : int 010021021
3 ...
## $ Cash.to.current.liabilities..times.: int 000000000
0 ...
## $ Cash.to.average.cost.of.sales.per.day : int 68 6 17 0 0 16
05
29 1 ...
## $ Creditors.turnover : int 4 10 5 0 13 7 0 3
13 0 ...
## $ Debtors.turnover : int 4 6 5 0 9 21 0 6 7
3 ...
## $ Finished.goods.turnover : int 201 14 9 1 13 10 1
15 6 43 ...
## $ WIP.turnover : int 22 7 0 0 8 8 0 11
5 6 ...
## $ Raw.material.turnover : int 8 11 0 0 17 5 0 6
4 5 ...
## $ Shares.outstanding : int 42381675 11550000
8149090 52404 619635 1141718 50070 359249712 3807100 5000000 ...
## $ Equity.face.value : int 10 10 10 10 10 10
10 1000 10 10 ...
## $ EPS : int 36 10 -1 0 8 31 0
0 13 0 ...
## $ Adjusted.EPS : int 7 10 -1 0 8 15 0 0
1 0 ...
## $ Total.liabilities : int 17512 941 233 3
479 2434 327 80 574 89 ...
## $ PE.on.BSE : int 27 8 -6 363 363
363 363 363 12 -2 ...
head(data)
## X...Num Default Total.assets Net.worth Total.income Change.in.stock
## 1 1 1 17512 7093 24965 236
## 1 6 8
## 2 8 10
## 3 -1 0
## 4 0 0
## 5 0 1
## 6 3 6
## PAT.as...of.net.worth Sales Income.from.financial.services
Other.income
## 1
297 24 24458 158
## 2 38 1504 4
16
## 3 -6 476 2
0
## 4 0 1 0
0
## 5 5 1575 4
1
## 6 22 2640 6
0
## Total.capital Reserves.and.funds
Deposits..accepted.by.commercial.banks.
## 1 424 6823
NA
## 2 116 258
NA
## 3 81 19
NA
## 4 1 2
NA
## 5 6 162
NA
## 6 34 972
NA
## Borrowings Current.liabilities...provisions Deferred.tax.liability
## 1 15 9966 285
## 2 273 210 85
## 3 35 97 0
## 4 0 0 0
## 5 193 113 5
## 6 717 556 54
## Shareholders.funds Cumulative.retained.profits
Capital.employed
TOL.TNW
## 1 7093 6263 7108
1
## 2 352 247 624
1
## 3 101 32 136
1
## 4 3 2 3
0
## 5 108 83 301
3
## 6 698 318 1415
2
## Total.term.liabilities...tangible.net.worth
## 1 0
## 2 0
## 3 0
## 4 0
## 5 2
## 6 0
## Contingent.liabilities...Net.worth.... Contingent.liabilities
## 1 15 1050
## 2 19 68
## 3 46 46
## 4 0 0
## 5 35 38
## 6 36 245
## Net.fixed.assets Investments Current.assets
Net.working.capital
## 1 1900 1070 13278 3589
## 5 17 619635 10 8
## 6 5 1141718 10 31
## Adjusted.EPS Total.liabilities PE.on.BSE
## 1 7 17512 27
## 2 10 941 8
## 3 -1 233 -6
## 4 0 3 363
## 5 8 479 363
## 6 15 2434 363
summary(data)
## X...Num Default Total.assets Net.worth
## Min. : 1 Min. :0.0000 Min. : 2 Min. :
0.0
## 1st Qu.: 886 1st Qu.:1.0000 1st Qu.: 91 1st Qu.:
31.0
## Median :1771 Median :1.0000 Median : 310 Median : 102.0
## Mean :1771 Mean :0.9339 Mean : 2051 Mean : 754.1
## 3rd Qu.:2656 3rd Qu.:1.0000 3rd Qu.: 1099 3rd Qu.: 377.0
## Max. :3541 Max. :1.0000 Max. :51659 Max. :20921.0
## Total.income Change.in.stock Total.expenses Profit.after.tax
## Min. : 0 Min. :-283.00 Min. : 0 Min. :-
192.0
## 1st Qu.: 76 1st Qu.: -1.00 1st Qu.: 75 1st Qu.:
0.0
## Median : 371 Median : 1.00 Median : 361 Median : 8.0
## Mean : 2028 Mean : 19.54 Mean : 1905 Mean : 128.8
## 3rd Qu.: 1340 3rd Qu.: 13.00 3rd Qu.: 1285 3rd Qu.: 48.0
## Max. :43481 Max. : 676.00 Max. :38581 Max.
:4345.0
## PBDITA PBT Cash.profit
## Min. : -25.0 Min. :-202.0 Min. :-117.0
## 1st Qu.: 5.0 1st Qu.: 0.0 1st Qu.: 2.0
## Median : 32.0 Median : 11.0 Median : 17.0
## Mean : 285.4 Mean : 175.6 Mean : 189.9
## 3rd Qu.: 139.0 3rd Qu.: 68.0 3rd Qu.: 87.0
## Max. :7498.0 Max. :5803.0 Max. :5818.0
## PBDITA.as...of.total.income PBT.as...of.total.income
## Min. :-67.00 Min. :-260.0000
## 1st Qu.: 5.00 1st Qu.: 0.0000
## Median : 9.00 Median : 3.0000
## Mean : 11.03 Mean : 0.2883
## 3rd Qu.: 16.00 3rd Qu.: 9.0000
## Max. : 81.00 Max. : 52.0000
## PAT.as...of.total.income Cash.profit.as...of.total.income ## Min. :-
238.0000 Min. :-136.000
## 1st Qu.: 0.0000 1st Qu.: 2.000
## Median : 2.0000 Median : 5.000
## Mean : -0.8763 Mean : 4.862
## 3rd Qu.: 6.0000 3rd Qu.: 11.000
Cash.to.average.cost.of.sales.per.day
##
## Min. :0.0000
1st Qu.:0.0000 Min. :
1st Qu.: 0.00
3.00
## Median :0.0000 Median : 8.00
## Mean :0.2203 Mean : 47.24
## 3rd Qu.:0.0000 3rd Qu.: 21.00
## Max. :6.0000 Max. :1278.00
## Creditors.turnover Debtors.turnover Finished.goods.turnover
## Min. : 0.00 Min. : 0.00 Min. : 1
## 1st Qu.: 4.00 1st Qu.: 4.00 1st Qu.: 6
## Median : 7.00 Median : 7.00 Median :
16
## Mean : 21.97 Mean : 28.62 Mean : 136
##
##
## 3rd Qu.: 15.00
Max. :135.00
WIP.turnover 3rd Qu.: 15.00 3rd Qu.: 49
Max. :202.00 Max. :1123
Raw.material.turnover Shares.outstanding
## Min. : 0.00 Min. : 0.00 Min. : 14121
## 1st Qu.: 4.00 1st Qu.: 3.00 1st Qu.: 2209860
## Median : 9.00 Median : 7.00 Median :
6297477
## Mean : 39.05 Mean : 17.69 Mean : 84573778
## 3rd Qu.: 24.00 3rd Qu.: 15.00 3rd Qu.: 57890000
## Max. :269.00 Max. :102.00 Max. :359249712
## Equity.face.value EPS Adjusted.EPS Total.liabilities
## Min. : 1.0 Min. :-65.00 Min. :-65.00 Min. :
2
## 1st Qu.: 10.0 1st Qu.: 0.00 1st Qu.: 0.00 1st Qu.:
91
## Median : 10.0 Median : 1.00 Median :
1.00 Median : 310
## Mean : 218.9 Mean : 25.87 Mean : 24.69 Mean :
2051
## 3rd Qu.: 100.0 3rd Qu.: 10.00 3rd Qu.: 7.00 3rd Qu.:
1099
## Max. :1000.0 Max. :896.00 Max. :896.00 Max.
:51659
## PE.on.BSE
## Min. :-163.0
## 1st Qu.: 13.0
## Median : 363.0
## Mean : 228.7
## 3rd Qu.: 363.0
## Max. : 363.0
dim(data)
## [1] 3541 52
train <- data[,2:52]
val <- val[,2:52] str(train)
## 'data.frame': 3541 obs. of 51 variables:
## $ Default : int 111 111111
0 ...
## $ Total.assets : int 17512 941 233 3
479 2434 327 80 574 89 ...
## $ Net.worth : int 7093 352 101 3 108
676 245 13 239 20 ...
## $ Total.income : int 24965 1527 477 0
1581 2649 0 154 583 83 ...
## $ Change.in.stock : int 236 43 -5 0 -17 62
0 -9 31 -7 ...
## $ Total.expenses : int 23658 1455 479 0
1558 2636 0 144 565 79 ...
## $ Profit.after.tax : int 1543 115 -7 0 6 75
0 1 48 -2 ...
## $ PBDITA : int 2860 283 6 0 31
200 0 10 110 0 ...
## $ PBT : int 2417 188 -7 0 6 75
0 2 69 -14 ...
## $ Cash.profit : int 1873 159 0 0 12
147 0 4 83 -11 ...
## $ PBDITA.as...of.total.income : int 11 19 1 0 2 8 0 6
19 0 ...
## $ PBT.as...of.total.income : int 10 12 -1 0 0 3 0 1
12 -17 ...
## $ PAT.as...of.total.income : int 6 8 -1 0 0 3 0 1 8
-3 ...
## $ Cash.profit.as...of.total.income : int 8 10 0 0 1 6 0 3
14 -13 ...
## $ PAT.as...of.net.worth : int 24 38 -6 0 5 22 0
10 22 -12 ...
## $ Sales : int 24458 1504 476 1
1575 2640 1 153 574 83 ...
## $ Income.from.financial.services : int 158 4 2 0 4 6 0 0
7 0 ...
## $ Other.income : int 297 16 0 0 1 0 0 0
1 0 ...
## $ Total.capital : int 424 116 81 1 6 34
78 10 58 50 ...
## $ Reserves.and.funds : int 6823 258 19 2 162
972 241 -2 201 -30 ...
## $ Deposits..accepted.by.commercial.banks. : logi NA NA NA NA NA NA
...
## $ Borrowings : int 15 273 35 0 193
717 8 29 204 61 ...
## $ Current.liabilities...provisions: int 9966 210 97 0 113
556 0 37 75 2 ...
## $ Deferred.tax.liability : int 285 85 0 0 5 54 0
1 36 5 ...
## $ Shareholders.funds : int 7093 352 101 3 108
698 315 13 259 20 ...
## $ Cumulative.retained.profits : int 6263 247 32 2 83
318 -4 -2 174 -30 ...
## $ Capital.employed : int 7108 624 136 3 301
1415 323 42 463 81 ...
## $ TOL.TNW : int 1 1 1 0 3 2 0 5 1
3 ...
## $ Total.term.liabilities...tangible.net.worth: int 0 0 0 0 2 0 0 1 0
1 ...
## $ Contingent.liabilities...Net.worth.... : int 15 19 46 0 35 36 0
0 40 0 ...
## $ Contingent.liabilities : int 1050 68 46 0 38
245 0 0 95 0 ...
## $ Net.fixed.assets : int 1900 286 39 3 95
865 0 10 207 24 ...
## $ Investments : int 1070 2 4 0 7 23
298 0 0 7 ...
## $ Current.assets : int 13278 564 168 0
350 1296 21 62 328 27 ...
## $ Net.working.capital : int 3589 204 60 0 216
279 21 8 120 -26 ...
## $ Quick.ratio..times. : int 111010011
0 ...
## $ Current.ratio..times. : int 122031012
1 ...
## $ Debt.to.equity.ratio..times. : int 010021021
3 ...
## $ Cash.to.current.liabilities..times.: int 000000000
0 ...
## $ Cash.to.average.cost.of.sales.per.day : int 68 6 17 0 0 16
05
29 1 ...
## $ Creditors.turnover : int 4 10 5 0 13 7 0 3
13 0 ...
## $ Debtors.turnover : int 4 6 5 0 9 21 0 6 7
3 ...
## $ Finished.goods.turnover : int 201 14 9 1 13 10 1
15 6 43 ...
## $ WIP.turnover : int 22 7 0 0 8 8 0 11
5 6 ...
## $ Raw.material.turnover : int 8 11 0 0 17 5 0 6
4 5 ...
## $ Shares.outstanding : int 42381675 11550000
8149090 52404 619635 1141718 50070 359249712 3807100 5000000 ...
## $ Equity.face.value : int 10 10 10 10 10 10
10 1000 10 10 ...
## $ EPS : int 36 10 -1 0 8 31 0
0 13 0 ...
## $ Adjusted.EPS : int 7 10 -1 0 8 15 0 0
1 0 ...
## $ Total.liabilities : int 17512 941 233 3
479 2434 327 80 574 89 ...
## $ PE.on.BSE : int 27 8 -6 363 363
363 363 363 12 -2 ...
View(train)
## Warning: running command ''/usr/bin/otool' -L '/Library/Frameworks/ ##
R.framework/Resources/modules/R_de.so'' had status 1
dim(train)
## [1] 3541 51
str(train)
## 'data.frame': 3541 obs. of 51 variables:
## $ Default : int 1 1 1 1 1 1 1 1 1
0 ...
## $ Total.assets : int 17512 941 233 3
479 2434 327 80 574 89 ...
## $ Net.worth
676 245 13 239 20 ... : int 7093 352 101 3 108
## $ Total.income : int 24965 1527 477 0
1581 2649 0 154 583 83 ...
## $ Change.in.stock : int 236 43 -5 0 -17 62
0 -9 31 -7 ...
## $ Total.expenses : int 23658 1455 479 0
1558 2636 0 144 565 79 ...
## $ Profit.after.tax : int 1543 115 -7 0 6 75
0 1 48 -2 ...
## $ PBDITA : int 2860 283 6 0 31
200 0 10 110 0 ...
## $ PBT : int 2417 188 -7 0 6 75
0 2 69 -14 ...
## $ Cash.profit : int 1873 159 0 0 12
147 0 4 83 -11 ...
## $ PBDITA.as...of.total.income
: int 11 19 1 0 2 8 0 6
19 0 ...
## $ PBT.as...of.total.income
: int 10 12 -1 0 0 3 0 1
12 -17 ...
## $ PAT.as...of.total.income
: int 6 8 -1 0 0 3 0 1 8
-3 ...
## $ Cash.profit.as...of.total.income
: int 8 10 0 0 1 6 0 3
14 -13 ...
## $ PAT.as...of.net.worth
: int 24 38 -6 0 5 22 0
10 22 -12 ...
## $ Sales : int 24458 1504 476 1
1575 2640 1 153 574 83 ...
## $ Income.from.financial.services : int 158 4 2 0 4 6 0 0
7 0 ...
## $ Other.income : int 297 16 0 0 1 0 0 0
1 0 ...
## $ Total.capital : int 424 116 81 1 6 34
78 10 58 50 ...
## $ Reserves.and.funds : int 6823 258 19 2 162
972 241 -2 201 -30 ...
## $ Deposits..accepted.by.commercial.banks. : logi NA NA
NA NA NA NA
...
## $ Borrowings : int 15 273 35 0 193
717 8 29 204 61 ...
## $ Current.liabilities...provisions : int 9966 210 97 0 113
556 0 37 75 2 ...
## $ Deferred.tax.liability : int 285 85 0 0 5 54 0
1 36 5 ...
## $ Shareholders.funds : int 7093 352 101 3 108
698 315 13 259 20 ...
## $ Cumulative.retained.profits : int 6263 247 32 2 83
318 -4 -2 174 -30 ...
## $ Capital.employed
1415 323 42 463 81 ... : int 7108 624 136 3 301
## $ TOL.TNW : int 1110 32 0 51
3 ...
## $ Total.term.liabilities...tangible.net.worth: int
0000 20 0 10
1 ...
## $ Contingent.liabilities...Net.worth.... : int 15 19 46 0
35 36 0
0 40 0 ...
## $ Contingent.liabilities : int 1050 68 46 0 38
245 0 0 95 0 ...
## $ Net.fixed.assets : int 1900 286 39 3 95
865 0 10 207 24 ...
## $ Investments : int 1070 2 4 0 7 23
298 0 0 7 ...
## $ Current.assets : int 13278 564 168 0
350 1296 21 62 328 27 ...
## $ Net.working.capital : int 3589 204 60 0
216
279 21 8 120 -26 ...
## $ Quick.ratio..times. : int 1110 10 0 11
0 ...
## $ Current.ratio..times. : int 1220 31 0 1
2
1 ...
## $ Debt.to.equity.ratio..times. : int 0100 21 0
21
3 ...
## $ Cash.to.current.liabilities..times.: int 0000 00 0
00
0 ...
## $ Cash.to.average.cost.of.sales.per.day : int 68 6 17 0
0 16 05
29 1 ...
## $ Creditors.turnover : int 4 10 5 0 13 7 03
13 0 ...
## $ Debtors.turnover : int 4650 9 21 0 6 7
3 ...
## $ Finished.goods.turnover : int 201 14 9 1 13
10 1
15 6 43 ...
## $ WIP.turnover : int 22 7 0 0 8 80 11
5 6 ...
## $ Raw.material.turnover : int 8 11 0 0 17 5 0
6
4 5 ...
## $ Shares.outstanding : int 42381675 11550000
8149090 52404 619635 1141718 50070 359249712 3807100 5000000 ...
## $ Equity.face.value : int 10 10 10 10 10 10
10 1000 10 10 ...
## $ EPS : int 36 10 -1 0 8 31 0
0 13 0 ...
## $ Adjusted.EPS : int 7 10 -1 0 8 15 00
1 0 ...
## $ Total.liabilities : int 17512 941 233 3
479 2434 327 80 574 89 ...
## $ Shares.outstanding
8149090 52404 619635 1141718 50070 359249712 : int 42381675
11550000
3807100 5000000 ...
## $ Equity.face.value : int 10 10 10 10 10 10
10 1000 10 10 ...
## $ EPS : int 36 10 -1 0 8 31 0
0 13 0 ...
## $ Adjusted.EPS : int 7 10 -1 0 8 15 0
1 0 ...
## $ Total.liabilities : int 17512 941 233 3
479 2434 327 80 574 89 ...
## $ PE.on.BSE : int 27 8 -6 363 363
363 363 363 12 -2 ...
## -1.122e-02
## Cash.profit.as...of.total.income
## 7.606e-03
## PAT.as...of.net.worth
## 2.186e-02
## Sales
## 2.976e-02
## Income.from.financial.services
## 4.540e-02
## Other.income
## 2.707e-02
## Total.capital
## 2.973e-03
## Reserves.and.funds
## 5.914e-03
## Borrowings
## 1.305e-03
## Current.liabilities...provisions
## 5.379e-03
## Deferred.tax.liability
## 3.635e-03
## Shareholders.funds
## 1.107e-03
## Cumulative.retained.profits
## 1.859e-03
## Capital.employed
## 3.352e-03
## TOL.TNW
## -4.281e-02
## Total.term.liabilities...tangible.net.worth
## 5.996e-02
## Contingent.liabilities...Net.worth....
## -1.386e-03
## Contingent.liabilities
## 2.916e-03
## Net.fixed.assets
## -1.190e-03
## Investments
## -1.891e-03
## Current.assets
## -1.590e-03
## Net.working.capital
## 1.027e-03
## Quick.ratio..times.
## 2.479e-01
## Current.ratio..times.
## 1.323e-03
## Debt.to.equity.ratio..times.
## -7.344e-02
## Cash.to.current.liabilities..times.
## -3.563e-01
## Cash.to.average.cost.of.sales.per.day
## -8.885e-04
## Creditors.turnover
## 5.455e-03
## Debtors.turnover
## -3.261e-03
## Finished.goods.turnover
## -1.757e-03
## WIP.turnover
## 5.073e-03
## Raw.material.turnover
## -4.918e-03
## Shares.outstanding
## -5.119e-10
## Equity.face.value
## 8.851e-06
## EPS
## -2.357e-02
## Adjusted.EPS
## 2.418e-02
## Total.liabilities
## NA
## PE.on.BSE
## 9.813e-04
##
## Degrees of Freedom: 3540 Total (i.e. Null); 3492 Residual ## Null
Deviance: 1724
## Residual Deviance: 875.7 AIC: 973.7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(my_logit)
##
## Call:
## glm(formula = Default ~ ., family = "binomial", data = train)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -4.5474 0.0013 0.1066 0.2671 3.3697
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error z
value
## (Intercept)2.480e+00 2.333e-01
10.629
## Total.assets -4.837e-03 1.818e-03
-2.660
## Net.worth 1.927e-03 2.753e-03
0.700
## Total.income -3.294e-02 7.676e-03
-4.291
## Change.in.stock -9.628e-03 6.273e-03
-1.535
## Total.expenses 2.805e-03 3.931e-03
0.714
## Profit.after.tax -3.300e-03 1.517e-02
-0.218
## PBDITA 3.423e-02 6.620e-03
## PBDITA.as...of.total.income ## PBT.as...of.total.income
## PAT.as...of.total.income
## Cash.profit.as...of.total.income
0.61145 0.57638 0.53557 0.24933
## PAT.as...of.net.worth
1.93e-12 ***
## Sales 4.46e-06 ***
## Income.from.financial.services 0.03863 *
## Other.income 0.15963
## Total.capital 0.10792
## Reserves.and.funds 0.00532 **
## Borrowings 0.84280
## Current.liabilities...provisions 0.00912 **
## Deferred.tax.liability 0.37094
## Shareholders.funds 0.85422
## Cumulative.retained.profits 0.40191
## Capital.employed 0.63049
## TOL.TNW 0.02325 *
## Total.term.liabilities...tangible.net.worth
0.17072
## Contingent.liabilities...Net.worth.... 0.12266
## Contingent.liabilities 0.01297 *
## Net.fixed.assets 0.10789
## Investments 0.25255
## Current.assets 0.35097
## Net.working.capital 0.57971
## Quick.ratio..times. 0.04398 *
## Current.ratio..times. 0.98405
## Debt.to.equity.ratio..times. 0.03173 *
## Cash.to.current.liabilities..times. 0.07640 .
## Cash.to.average.cost.of.sales.per.day 0.02516 *
## Creditors.turnover 0.38317
## Debtors.turnover 0.30911
## Finished.goods.turnover 0.01011 *
## WIP.turnover 0.15071
## Raw.material.turnover 0.48165
## Shares.outstanding 0.85788
## Equity.face.value 0.99323
## EPS 0.31453
## Adjusted.EPS 0.30522
## Total.liabilities NA
## PE.on.BSE 0.13492
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 1723.67 on 3540 degrees of freedom
## Residual deviance: 875.68 on 3492 degrees of freedom ## AIC: 973.68
##
## Number of Fisher Scoring iterations: 14
## Profit.after.tax
## -5.557e-03
## PBDITA
## 3.323e-02
## PBT
## 4.607e-03
## Cash.profit
## 9.070e-03
## PBDITA.as...of.total.income
## -5.804e-03
## PBT.as...of.total.income
## 8.545e-03
## PAT.as...of.total.income
## -9.263e-03
## Cash.profit.as...of.total.income
## 7.531e-03
## PAT.as...of.net.worth
## 2.187e-02
## Sales
## 2.981e-02
## Income.from.financial.services
## 4.569e-02
## Other.income
## 2.607e-02
## Total.capital
## 3.800e-03
## Reserves.and.funds
## 6.725e-03
## Borrowings
## 4.076e-03
## Current.liabilities...provisions
## 6.221e-03
## Deferred.tax.liability
## 4.757e-03
## Shareholders.funds
## 4.020e-03
## Cumulative.retained.profits
## 1.920e-03
## Capital.employed
## 1.641e-03
## TOL.TNW
## -4.839e-02
## Total.term.liabilities...tangible.net.worth
## 7.314e-02
## Contingent.liabilities...Net.worth....
## -1.511e-03
## Contingent.liabilities
## 3.080e-03
## Net.fixed.assets
## -1.043e-03
## Current.assets
## -6.561e-04
## Net.working.capital
## 6.987e-04
## Debt.to.equity.ratio..times.
## -7.458e-02
## Debtors.turnover
## -3.324e-03
## Finished.goods.turnover
## -1.735e-03
## WIP.turnover
## 6.230e-03
## Raw.material.turnover
## -7.932e-04
## Shares.outstanding
## -6.817e-10
## EPS
## -2.328e-02
## Adjusted.EPS
## 2.396e-02
## Total.liabilities
## NA
## PE.on.BSE
## 1.021e-03
##
## Degrees of Freedom: 3540 Total (i.e. Null); 3499 Residual ## Null
Deviance: 1724
## Residual Deviance: 891.8 AIC: 975.8
anova(my_logit1, test = "Chisq")
## Analysis of Deviance Table
##
## Model: binomial, link: logit
##
## Response: Default
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df
## NULL 3540
## Total.assets 1 7.204 3539
## Net.worth 1 79.964 3538
## Total.income 1 65.271 3537
## Change.in.stock 1 0.236 3536
## Total.expenses 1 59.323 3535
## Profit.after.tax 1 48.235 3534
## PBDITA 1 58.552 3533
## PBT 1 16.254 3532
## Cash.profit 1 114.393 3531
## PBDITA.as...of.total.income
1 25.026 3530
## PBT.as...of.total.income
1 9.155 3529
## PAT.as...of.total.income
1 0.277 3528
## Cash.profit.as...of.total.income
1 3.948 3527
## PAT.as...of.net.worth
1 145.441 3526
## Sales 1 17.395 3525
## Income.from.financial.services 1 12.591 3524
## Other.income 1 0.003 3523
## Total.capital 1 1.105 3522
## Reserves.and.funds 1 32.396 3521
## Borrowings 1 1.450 3520
## Current.liabilities...provisions 1 13.226 3519
## Deferred.tax.liability 1 1.814 3518
## Shareholders.funds 1 0.994 3517
## Cumulative.retained.profits 1 4.173 3516
## Capital.employed 1 3.265 3515
## TOL.TNW 1 64.950 3514
## Total.term.liabilities...tangible.net.worth
1 0.457 3513
## Contingent.liabilities...Net.worth.... 1 0.014 3512
## Contingent.liabilities 1 10.928 3511
## Net.fixed.assets 1 2.382 3510
## Current.assets 1 0.395 3509
## Net.working.capital 1 0.585 3508
## Debt.to.equity.ratio..times. 1 5.927 3507
## Debtors.turnover 1 15.735 3506
## Finished.goods.turnover 1 1.669 3505
## WIP.turnover 1 3.826 3504
## Raw.material.turnover 1 0.046 3503
## Shares.outstanding 1 0.283 3502
## EPS 1 0.083 3501
## Adjusted.EPS 1 0.358 3500
## Total.liabilities 0 0.000 3500
## Adjusted.EPS 1.073
## Total.liabilities NA
## PE.on.BSE
1.588
##
## (Intercept) ## Total.assets ## Net.worth
## Total.income
## Change.in.stock ## Total.expenses ## Profit.after.tax
## PBDITA
## PBT
## Cash.profit
## PBDITA.as...of.total.income
## PBT.as...of.total.income
## PAT.as...of.total.income
## Cash.profit.as...of.total.income
## PAT.as...of.net.worth
## Sales
## Income.from.financial.services
## Other.income ## Total.capital ## Reserves.and.funds
## Borrowings
## Current.liabilities...provisions
## Deferred.tax.liability
## Shareholders.funds
## Cumulative.retained.profits
## Capital.employed
## TOL.TNW
## Total.term.liabilities...tangible.net.worth ##
Contingent.liabilities...Net.worth....
## Contingent.liabilities
## Net.fixed.assets
## Current.assets
## Net.working.capital
## Debt.to.equity.ratio..times.
## Debtors.turnover
## Finished.goods.turnover
## WIP.turnover 2.396e-02
NA
1.021e-03
Pr(>|z|)
< 2e-16 ***
0.000348 ***
0.754895
9.48e-06 ***
0.090970 .
0.469292
0.713202
2.03e-07 ***
0.748487
0.076220 .
0.349315
0.618103
0.612450
0.260816
1.56e-12 ***
4.53e-06 ***
0.033310 *
0.186449
0.036706 *
0.001548 **
0.465168
0.002866 **
0.311092
0.406196
0.384686
0.793121
0.011952 *
0.081988 .
0.098474 .
0.021172 *
0.148006
0.667474
0.703895
0.025548 *
0.256839
0.011250 *
0.074904 . 2.233e-02
NA
6.428e-04
## Raw.material.turnover 0.905425
## Shares.outstanding 0.275059
## EPS 0.293590
## Adjusted.EPS 0.283333
## Total.liabilities NA
## PE.on.BSE 0.112368
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Dispersion parameter for binomial family taken to be 1)
## Null deviance: 1723.67 on 3540 degrees of freedom
## Residual deviance: 891.84 on 3499 degrees of freedom
## AIC: 975.84
## Number of Fisher Scoring iterations: 15
toselect.x <- summary(my_logit1)$coeff[-1,4] < 0.05
#EDIT: as subsequent posters have pointed out, the latter line should be
#to include all variables.
##
## Call: glm(formula = sig.formula, data = train)
##
## Coefficients:
## (Intercept) Total.assets
## 9.496e-01 7.235e-07
## Total.income PBDITA
## -2.750e-05 -4.759e-05
## PAT.as...of.net.worth
Sales
## 2.944e-03 3.332e-05
## Income.from.financial.services Total.capital
## 2.626e-05 -2.628e-06
## Reserves.and.funds Current.liabilities...provisions
## 1.084e-05 -9.504e-06
## TOL.TNW Contingent.liabilities
## -6.309e-03 1.606e-06
## Debt.to.equity.ratio..times. Finished.goods.turnover
## -8.543e-03 -4.220e-05
##
## Degrees of Freedom: 3540 Total (i.e. Null); 3527 Residual
## Null Deviance: 218.5
## Residual Deviance: 147.2 AIC: -1183
anova(my_logit2, test = "Chisq")
## Analysis of Deviance Table
##
## Model: gaussian, link: identity
##
## Response: Default
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev
## NULL 3540 218.54
## Total.assets 1 0.303 3539 218.23
## Total.income 1 1.241 3538 216.99
## PBDITA 1 0.640 3537 216.35
## PAT.as...of.net.worth
1 45.225 3536 171.13
## Sales 1 0.255 3535 170.87
## Income.from.financial.services 1 0.138 3534 170.74
## Total.capital 1 0.004 3533 170.73
## Reserves.and.funds 1 1.142 3532 169.59
## Current.liabilities...provisions 1 0.129 3531 169.46
## TOL.TNW 1 20.403 3530 149.06
## Contingent.liabilities 1 0.005 3529 149.05
## Debt.to.equity.ratio..times. 1 1.237 3528 147.81
## Finished.goods.turnover 1 0.645 3527 147.17
## Pr(>Chi)
## NULL
## Total.assets 0.007064 **
## Total.income 4.939e-08 ***
## PBDITA 8.968e-05 ***
## PAT.as...of.net.worth
< 2.2e-16 ***
## Sales 0.013464 *
## Income.from.financial.services 0.069416 .
## Total.capital 0.749960
## Reserves.and.funds 1.689e-07 ***
## Current.liabilities...provisions 0.078935 . ## TOL.TNW < 2.2e-16 ***
## Contingent.liabilities 0.724730
## Debt.to.equity.ratio..times. 5.176e-08 ***
## Finished.goods.turnover 8.424e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(my_logit2)
##
## Call:
## glm(formula = sig.formula, data = train)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.04856 -0.00428 0.03888 0.06529 1.13657
##
## Coefficients: ## Estimate Std.Error t value Pr(>|t|)
## (Intercept)9.496e-01 4.614e-03 205.814 < 2e-16
## Total.assets 7.235e-07 2.255e-06 0.321 0.7483
## Total.income -2.750e-05 2.179e-05 -1.262 0.2071
## PBDITA -4.759e-05 1.469e-05 -3.240 0.0012
## PAT.as...of.net.worth
2.944e-03 1.272e-04 23.145 < 2e-16
## Sales 3.332e-05 2.122e-05 1.570 0.1165
## Income.from.financial.services 2.626e-05 6.339e-05 0.414 0.6787
## Total.capital -2.628e-06 1.304e-05 -0.202 0.8403
## Reserves.and.funds 1.084e-05 5.358e-06 2.022 0.0432
## Current.liabilities...provisions -9.505e-06 6.712e-06 -1.416 0.1568
## TOL.TNW -6.309e-03 1.037e-03 -6.083 1.30e-09
## Contingent.liabilities 1.605e-06 5.438e-06 0.295 0.7678
## Debt.to.equity.ratio..times. -8.543e-03 1.602e-03 -5.335 1.02e-07
## Finished.goods.turnover -4.220e-05 1.073e-05 -3.932 8.59e-05
##
## (Intercept)***
## Total.assets
## Total.income
## PBDITA **
## PAT.as...of.net.worth
***
## Sales
## Income.from.financial.services
## Total.capital
## Reserves.and.funds *
## Current.liabilities...provisions
## TOL.TNW ***
## Contingent.liabilities
## Debt.to.equity.ratio..times. ***
## Finished.goods.turnover ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.04172674)
##
## Null deviance: 218.54 on 3540 degrees of freedom
## Residual deviance: 147.17 on 3527 degrees of freedom
## AIC: -1183.5
##
## Number of Fisher Scoring iterations: 2 my_logit2_Val <-
glm(formula=sig.formula,data=val)
my_logit2_Val
##
## Call:
## glm(formula = sig.formula, data = val)
## Coefficients:
## (Intercept) Total.assets
## 9.664e-02 1.066e-06
## Total.income PBDITA
## 7.901e-06 8.637e-06
## PAT.as...of.net.worth
Sales
## -3.443e-03 -8.545e-06
## Income.from.financial.services Total.capital
## -1.020e-05 -1.370e-05
## Reserves.and.funds Current.liabilities...provisions
## -4.999e-06 2.686e-06
## TOL.TNW Contingent.liabilities
## 2.761e-03 -2.444e-06
## Debt.to.equity.ratio..times. Finished.goods.turnover
## -3.197e-03 -2.476e-05
##
## Degrees of Freedom: 396 Total (i.e. Null); 383 Residual ## (318
observations deleted due to missingness)
## Null Deviance: 15.36
## Residual Deviance: 10.85 AIC: -272.6
anova(my_logit2_Val, test = "Chisq")
## Income.from.financial.services ## Total.capital
## Reserves.and.funds
## Current.liabilities...provisions
## TOL.TNW
## Contingent.liabilities
## Debt.to.equity.ratio..times. .
## Finished.goods.turnover
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(my_logit2_Val)
##
## Call:
## glm(formula = sig.formula, data = val)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.49273 -0.06993 -0.03881 0.00430 0.91737
##
## Coefficients: ## Estimate Std.Error t value Pr(>|t|)
## (Intercept)9.664e-02 1.027e-02 9.413 <2e-16
## Total.assets 1.066e-06 2.493e-06 0.427 0.6693
## Total.income 7.901e-06 2.883e-05 0.274 0.7842
## PBDITA 8.637e-06 7.841e-06 1.102 0.2714
## PAT.as...of.net.worth
-3.443e-03 2.820e-04 -12.210 <2e-16
## Sales -8.545e-06 3.026e-05 -0.282 0.7778
## Income.from.financial.services -1.020e-05 4.226e-05 -0.241 0.8093
## Total.capital -1.370e-05 1.290e-05 -1.062 0.2891
## Reserves.and.funds -4.999e-06 6.011e-06 -0.832 0.4061
## Current.liabilities...provisions 2.686e-06 6.102e-06 0.440 0.6600
## TOL.TNW 2.761e-03 1.412e-03 1.955 0.0513
## Contingent.liabilities -2.444e-06 3.802e-06 -0.643 0.5208
## Debt.to.equity.ratio..times. -3.197e-03 1.779e-03 -1.797 0.0731
## Finished.goods.turnover -2.476e-05 2.891e-05 -0.856 0.3923
##
## (Intercept)***
## Total.assets
## Total.income
## PBDITA
## PAT.as...of.net.worth
***
## Sales
## Income.from.financial.services
## Total.capital
## Reserves.and.funds
## Current.liabilities...provisions
## TOL.TNW .
## Contingent.liabilities
## Debt.to.equity.ratio..times. .
## Finished.goods.turnover
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ##
## (Dispersion parameter for gaussian family taken to be 0.0283165) ##
## Null deviance: 15.355 on 396 degrees of freedom
## Residual deviance: 10.845 on 383 degrees of freedom
## (318 observations deleted due to missingness)
## AIC: -572.65
##
## Number of Fisher Scoring iterations: 2
The AIC Score on both Train and Test Dataset had a good match.