100% found this document useful (1 vote)
146 views73 pages

Knitted R Code - FRA Project

The document reads in raw data and validation data from CSV files, examines their structure and column names. It then splits the raw data into training and validation sets, adds a 'Default' column classified by net worth, and reorders columns. Some columns are removed that have over 50% missing values. Remaining missing values in the training set are replaced with column means, and this process is repeated for the validation set. The default rate for the full training set is also calculated.

Uploaded by

Nishank Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
146 views73 pages

Knitted R Code - FRA Project

The document reads in raw data and validation data from CSV files, examines their structure and column names. It then splits the raw data into training and validation sets, adds a 'Default' column classified by net worth, and reorders columns. Some columns are removed that have over 50% missing values. Remaining missing values in the training set are replaced with column means, and this process is repeated for the validation set. The default rate for the full training set is also calculated.

Uploaded by

Nishank Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 73

#Set the working directory and load the data file.

## Read Input data from raw-data and validation_data


data_raw = read.csv("raw-data.csv", header = TRUE)
data_validation = read.csv("validation_data.csv", header = TRUE)

## View column names


names(data_raw)
names(data_validation)
[1] "Num" "Default...1"
[3] "Total.assets" "Net.worth"
[5] "Total.income" "Change.in.stock"
[7] "Total.expenses" "Profit.after.tax"
[9] "PBDITA" "PBT"
[11] "Cash.profit"
"PBDITA.as...of.total.income"
[13] "PBT.as...of.total.income"
"PAT.as...of.total.income"
[15] "Cash.profit.as...of.total.income" "PAT.as...of.net.worth"
[17] "Sales"
"Income.from.financial.services"
[19] "Other.income" "Total.capital"
[21] "Reserves.and.funds"
"Deposits..accepted.by.commercial.banks."
[23] "Borrowings"
"Current.liabilities...provisions"
[25] "Deferred.tax.liability" "Shareholders.funds"
[27] "Cumulative.retained.profits" "Capital.employed"
[29] "TOL.TNW"
"Total.term.liabilities...tangible.net.worth"
[31] "Contingent.liabilities...Net.worth...." "Contingent.liabilities"
[33] "Net.fixed.assets" "Investments"
[35] "Current.assets" "Net.working.capital"
[37] "Quick.ratio..times." "Current.ratio..times."
[39] "Debt.to.equity.ratio..times."
"Cash.to.current.liabilities..times."
[41] "Cash.to.average.cost.of.sales.per.day" "Creditors.turnover"
[43] "Debtors.turnover"
"Finished.goods.turnover"
[45] "WIP.turnover" "Raw.material.turnover"
[47] "Shares.outstanding" "Equity.face.value"
[49] "EPS" "Adjusted.EPS"
[51] "Total.liabilities" "PE.on.BSE"

## View Structure of Input data


str(data_raw)
str(data_validation)
'data.frame': 3541 obs. of 52 variables:
$ Num : int 1 2 3 4 5 6 7 8 9
10 ...
$ Networth.Next.Year : num 8890.6 394.3 92.2 2.7
109 ...
$ Total.assets : num 17512.3 941 232.8 2.7
478.5 ...
$ Net.worth : num 7093.2 351.5 100.6 2.7
107.6 ...
$ Total.income : num 24965 1527 477 NA 1580
...
$ Change.in.stock : num 235.8 42.7 -5.2 NA -17
...
$ Total.expenses : num 23658 1455 479 NA 1558
...
$ Profit.after.tax : num 1543.2 115.2 -6.6 NA
5.5 ...
$ PBDITA : num 2860.2 283 5.8 NA
31 ...
$ PBT : num 2417.2 188.4 -6.6 NA
6.3 ...
$ Cash.profit : num 1872.8 158.6 0.3 NA
11.9 ...
$ PBDITA.as...of.total.income : num 11.46 18.53 1.22 0
1.96 ...
$ PBT.as...of.total.income : num 9.68 12.33 -1.38 0 0.4
...
$ PAT.as...of.total.income : num 6.18 7.54 -1.38 0 0.35
2.81 0 0.72 8.29 -2.88 ...
$ Cash.profit.as...of.total.income : num 7.5 10.38 0.06 0
0.75 ...
$ PAT.as...of.net.worth : num 23.78 38.08 -6.35 0
5.25 ...
$ Sales : num 24458 1504 476 NA 1575
...
$ Income.from.financial.services : num 158 4 1.5 NA 3.9 6.4
NA NA 7.3 NA ...
$ Other.income : num 297.2 15.9 0.2 NA
0.9 ...
$ Total.capital : num 423.8 115.5 81.4 0.5
6.2 ...
$ Reserves.and.funds : num 6822.8 257.8 19.2 2.2
161.8 ...
$ Deposits..accepted.by.commercial.banks. : logi NA NA NA NA NA NA ...
$ Borrowings : num 14.9 272.5 35.4 NA
193.1 ...
$ Current.liabilities...provisions : num 9965.9 210 96.8 NA
112.8 ...
$ Deferred.tax.liability : num 284.9 85.2 NA NA
4.6 ...
$ Shareholders.funds : num 7093.2 351.5 100.6 2.7
107.6 ...
$ Cumulative.retained.profits : num 6263.3 247.4 32.4 2.2
82.7 ...
$ Capital.employed : num 7108.1 624 136 2.7
300.7 ...
$ TOL.TNW : num 1.33 1.23 1.44 0 2.83
1.8 0.03 5.17 1.05 3.25 ...
$ Total.term.liabilities...tangible.net.worth: num 0 0.34 0.29 0 1.59
0.37 0.03 0.94 0.3 0.54 ...
$ Contingent.liabilities...Net.worth.... : num 14.8 19.2 45.8 0
34.9 ...
$ Contingent.liabilities : num 1049.7 67.6 46.1 NA
37.6 ...
$ Net.fixed.assets : num 1900.2 286.4 38.7 2.5
94.8 ...
$ Investments : num 1069.6 2.2 4.3 NA
7.4 ...
$ Current.assets : num 13277.5 563.9 167.5
0.2 349.7 ...
$ Net.working.capital : num 3588.5 203.5 59.6 0.2
215.8 ...
$ Quick.ratio..times. : num 1.18 0.95 1.11 NA 1.41
0.48 NA 0.54 0.59 0.39 ...
$ Current.ratio..times. : num 1.37 1.56 1.55 NA 2.54
1.27 NA 1.15 1.58 0.5 ...
$ Debt.to.equity.ratio..times. : num 0 0.78 0.35 0 1.79
1.09 0.32 2.31 0.94 3.13 ...
$ Cash.to.current.liabilities..times. : num 0.43 0.06 0.21 NA 0
0.11 NA 0.04 0.19 0 ...
$ Cash.to.average.cost.of.sales.per.day : num 68.21 5.96 17.07 NA
0 ...
$ Creditors.turnover : num 3.62 9.8 5.28 0 13 ...
$ Debtors.turnover : num 3.85 5.7 5.07 0
9.46 ...
$ Finished.goods.turnover : num 200.55 14.21 9.24 NA
12.68 ...
$ WIP.turnover : num 21.78 7.49 0.23 NA 7.9
...
$ Raw.material.turnover : num 7.71 11.46 NA 0
17.03 ...
$ Shares.outstanding : num 42381675 11550000
8149090 52404 619635 ...
$ Equity.face.value : num 10 10 10 10 10 10 10
NA 10 10 ...
$ EPS : num 35.52 9.97 -0.5 0 7.91
...
$ Adjusted.EPS : num 7.1 9.97 -0.5 0
7.91 ...
$ Total.liabilities : num 17512.3 941 232.8 2.7
478.5 ...
$ PE.on.BSE : num 27.31 8.17 -5.76 NA NA
...

## View Summary of Input data


summary(data_raw)
summary(data_validation)
data_training = data_raw[ !(data_raw$Num %in% data_validation$Num), ]
dim(data_validation)
dim(data_training)

## Add a column of Default based on the value of NetWorthNextYear.


# 0 if NetWorthNextYear is positive,
#1 if NetWorthNextYear is negative.
#Then remove the NetWorthNextYear column

data_training$Default <- ifelse(data_training$`Networth Next Year`>=0 ,0,1)


data_training = data_training[,c(1,3,4:53)]

## Reordering the columns so making the details easy to find


data_training = data_training[,order(names(data_training))]
data_validation = data_validation[,order(names(data_validation))]
data_training = data_training[,c(29,1:28,30:52)] data_validation =
data_validation[,c(29,1:28,30:52)] attach(data_training)

##Default Rate for the data set


default_rate = (sum(data_training$Default)/(nrow(data_training)))*100
paste("Default Rate for the dataset is ", default_rate, "%")

## For finding the missing values:


missing_values = lapply(data_training,function(x)
sum(is.na(x))) missing_values
missmap(data_training, main = "Missing values vs
observed")
Output:
> missing_values
$`Networth Next
Year` [1] 0

$`Adjusted
EPS` [1] 0

$Borrowings
[1] 301

$`Capital
employed` [1] 0

$`Cash profit`
[1] 108

$`Cash profit as % of total


income` [1] 57

$`Cash to average cost of sales per


day` [1] 70

$`Cash to current liabilities


(times)` [1] 8
[1] 366

$`Contingent liabilities` [1] 974

$`Contingent liabilities / Net worth (%)` [1] 0

$`Creditors turnover` [1] 38

$`Cumulative retained profits` [1] 31

$`Current assets` [1] 52

$`Current liabilities & provisions` [1] 82

$`Current ratio (times)` [1] 81

$`Debt to equity ratio (times)` [1] 0

$`Debtors turnover` [1] 34

$Default
[1] 0

$`Deferred tax liability` [1] 911

$`Deposits (accepted by commercial banks)` [1] 2826

$EPS
[1] 0

$`Equity face value` [1] 0

$`Finished goods turnover` [1] 369

$`Income from financial services` [1] 759

$Investments
[1] 1155

$`Net fixed assets` [1] 104

$`Net working capital` [1] 27


#Remove columns for both test and training data for which more than
50% is missing i.e. ones which have more 1416 missing
data_training <-subset(data_training,-c(data_training$`PE on
BSE`,data_training$`Deposits (accepted by commercial
banks)`,data_training$Investments))
data_validation <- subset(data_validation, select =
-c(data_validation$`PE on BSE`,data_validation$`Deposits (accepted by
commercial banks)`,data_validation$Investments))

## 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

## 2 2 1 941 352 1527 43


## 3 3 1 233 101 477 -5
## 4 4 1 3 3 0 0
## 5 5 1 479 108 1581 -17
## 6 6 1 2434 676 2649 62
## Total.expenses Profit.after.tax PBDITA PBT Cash.profit
## 1 23658 1543 2860 2417 1873
## 2 1455 115 283 188 159
## 3 479 -7 6 -7 0
## 4 0 0 0 0 0
## 5 1558 6 31 6 12
## 6 2636 75 200 75 147
## PBDITA.as...of.total.income PBT.as...of.total.income
## 1 11 10
## 2 19 12
## 3 1 -1
## 4 0 0
## 5 2 0
## 6 8 3
## PAT.as...of.total.income Cash.profit.as...of.total.income

## 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

## 2 286 2 564 204


## 3 39 4 168 60
## 4 3 0 0 0
## 5 95 7 350 216
## 6 865 23 1296 279
## Quick.ratio..times. Current.ratio..times.
Debt.to.equity.ratio..times.
## 1 1 1
0
## 2 1 2
1
## 3 1 2
0
## 4 0 0
0
## 5 1 3
2
## 6 0 1
1
## Cash.to.current.liabilities..times.
## 1 0
## 2 0
## 3 0
## 4 0
## 5 0
## 6 0
## Cash.to.average.cost.of.sales.per.day Creditors.turnover
## 1 68 4
## 2 6 10
## 3 17 5
## 4 0 0
## 5 0 13
## 6 16 7
## Debtors.turnover Finished.goods.turnover WIP.turnover
## 1 4 201 22
## 2 6 14 7
## 3 5 9 0
## 4 0 1 0
## 5 9 13 8
## 6 21 10 8
## Raw.material.turnover Shares.outstanding Equity.face.value EPS
## 1 8 42381675 10 36
## 2 11 11550000 10 10
## 3 0 8149090 10 -1
## 4 0 52404 10 0

## 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

## Max. : 44.0000 Max. : 57.000


## PAT.as...of.net.worth Sales Income.from.financial.services
## Min. :-141.000 Min. : 1 Min. : 0.0
## 1st Qu.: 0.000 1st Qu.: 71 1st Qu.: 0.0
## Median : 8.000 Median : 358 Median : 1.0
## Mean : 8.935 Mean : 1969 Mean : 25.2
## 3rd Qu.: 20.000 3rd Qu.: 1315 3rd Qu.: 5.0
## Max. : 97.000 Max. :42041 Max. :1037.0
## Other.income Total.capital Reserves.and.funds
## Min. : 0.000 Min. : 1.0 Min. : -235.0
## 1st Qu.: 0.000 1st Qu.: 13.0 1st Qu.: 3.0
## Median : 0.000 Median : 42.0 Median : 50.0
## Mean : 9.661 Mean : 149.8 Mean : 609.8
## 3rd Qu.: 3.000 3rd Qu.: 100.0 3rd Qu.: 263.0
## Max. :368.000 Max. :2939.0 Max. :17698.0
## Deposits..accepted.by.commercial.banks. Borrowings
## Mode:logical Min. : 0.0
## NA's:35411st Qu.: 11.0
## Median : 75.0
## Mean : 616.6
## 3rd Qu.: 296.0
## Max. :17534.0 ## Current.liabilities...provisions Deferred.tax.liability ##
Min. : 0.0 Min. : 0.00
## 1st Qu.: 15.0 1st Qu.: 0.00
## Median : 65.0 Median : 4.00
## Mean : 475.6 Mean : 83.79
## 3rd Qu.: 249.0 3rd Qu.: 27.00
## Max. :11525.0 Max. :3537.00
## Shareholders.funds Cumulative.retained.profits Capital.employed ## Min.
: 0.0 Min. : -501.0 Min. : 1
## 1st Qu.: 32.0 1st Qu.: 1.0 1st Qu.: 61
## Median : 106.0 Median : 36.0 Median : 215
## Mean : 769.6 Mean : 444.6 Mean : 1402
## 3rd Qu.: 393.0 3rd Qu.: 199.0 3rd Qu.: 767
## Max. :20921.0 Max. :13090.0 Max. :34915
## TOL.TNW Total.term.liabilities...tangible.net.worth
## Min. : 0.000 Min. : 0.000
## 1st Qu.: 1.000 1st Qu.: 0.000
## Median : 1.000 Median : 0.000
## Mean : 3.202 Mean : 1.202
## 3rd Qu.: 3.000 3rd Qu.: 1.000
## Max. :56.000 Max. :29.000
## Contingent.liabilities...Net.worth.... Contingent.liabilities
## Min. : 0.00 Min. : 0.0
## 1st Qu.: 0.00 1st Qu.: 0.0
## Median : 5.00 Median : 6.0
## Mean : 36.07 Mean : 281.5
## 3rd Qu.: 31.00 3rd Qu.: 84.0
## Max. :774.00 Max. :12158.0
## Net.fixed.assets Investments Current.assets
Net.working.capital
## Min. : 0.0 Min. : 0.0 Min. : 0.0 Min. :-
1771.0
## 1st Qu.: 22.0 1st Qu.: 0.0 1st Qu.: 32.0 1st Qu.:
-1.0
## Median : 87.0 Median : 0.0 Median :
138.0 Median : 16.0
## Mean : 648.6 Mean : 228.7 Mean : 780.6 Mean :
106.9
## 3rd Qu.: 329.0 3rd Qu.: 16.0 3rd Qu.: 486.0 3rd Qu.:
82.0
## Max. :17183.0 Max. :17183.0 Max. :17836.0 Max. :
3689.0
## Quick.ratio..times. Current.ratio..times. Debt.to.equity.ratio..times.
## Min. : 0.000 Min. : 0.0 Min. : 0.000
## 1st Qu.: 0.000 1st Qu.: 1.0 1st Qu.: 0.000
## Median : 1.000 Median : 1.0 Median : 1.000
## Mean : 1.056 Mean : 1.7 Mean : 1.939
## 3rd Qu.: 1.000 3rd Qu.: 2.0 3rd Qu.: 2.000
## Max. :15.000 Max. :19.0 Max. :37.000
## Cash.to.current.liabilities..times.

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 ...

## $ PE.on.BSE : int 27 8 -6 363 363


363 363 363 12 -2 ...

#Let's remove the blank variable from the file


## $ 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 1 1 1 0 1 0 0 1 1
0 ...
## $ Current.ratio..times. : int 1 2 2 0 3 1 0 1 2
1 ...
## $ Debt.to.equity.ratio..times. : int 0 1 0 0 2 1 0 2 1
3 ...
## $ Cash.to.current.liabilities..times. : int 0 0 0 0 0 0 0 0 0
0 ...
## $ Cash.to.average.cost.of.sales.per.day : int 68 6 17 0 0 16 0 5
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
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 ...

#Let's run first iteration


my_logit <- glm(Default~., family = "binomial", data = train)
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
my_logit
##
## Call: glm(formula = Default ~ ., family = "binomial", data = train) ##
## Coefficients:
## (Intercept)
## 2.480e+00
## Total.assets
## -4.837e-03
## Net.worth
## 1.927e-03
## Total.income
## -3.294e-02
## Change.in.stock
## -9.628e-03
## Total.expenses
## 2.805e-03
## Profit.after.tax
## -3.300e-03
## PBDITA
## 3.423e-02
## PBT
## 1.544e-03
## Cash.profit
## 8.677e-03
## PBDITA.as...of.total.income
## -3.056e-03
## PBT.as...of.total.income
## 9.450e-03
## PAT.as...of.total.income

## -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

anova(my_logit, test = "Chisq")


## Analysis of Deviance Table
##
## Model: binomial, link: logit
##
## Response: Default
##
## Terms added sequentially (first to last)

## ## ## ## NULL Df Deviance Resid. Df


3540
## Total.assets 1 7.2 3539
## Net.worth 1 80.0 3538
## Total.income 1 65.3 3537
## Change.in.stock 1 0.2 3536
## Total.expenses 1 59.3 3535
## Profit.after.tax 1 48.2 3534
## PBDITA 1 58.6 3533
## PBT 1 16.3 3532
## Cash.profit 1 114.4 3531
## PBDITA.as...of.total.income
1 25.0 3530
## PBT.as...of.total.income
1 9.2 3529
## PAT.as...of.total.income
1 0.3 3528
## Cash.profit.as...of.total.income
1 3.9 3527
## PAT.as...of.net.worth
1 145.4 3526
## Sales 1 17.4 3525
## Income.from.financial.services 1 12.6 3524
## Other.income 1 0.0 3523
## Total.capital 1 1.1 3522
## Reserves.and.funds 1 32.4 3521
## Borrowings 1 1.4 3520
## Current.liabilities...provisions 1 13.2 3519
## Deferred.tax.liability 1 1.8 3518
## Shareholders.funds 1 1.0 3517
## Cumulative.retained.profits 1 4.2 3516
## Capital.employed 1 3.3 3515
## TOL.TNW 1 64.9 3514
## Total.term.liabilities...tangible.net.worth
1 0.5 3513
## Contingent.liabilities...Net.worth.... 1 0.0 3512
## Contingent.liabilities 1 10.9 3511
## Net.fixed.assets 1 2.4 3510
## Investments 1 0.0 3509
## Current.assets 1 0.0 3508
## Net.working.capital 1 0.0 3507
## Quick.ratio..times. 1 576.7 3506
## Current.ratio..times. 1 0.0 3505
## Debt.to.equity.ratio..times. 1 0.0 3504
## Cash.to.current.liabilities..times. 1 3316.0 3503
## Cash.to.average.cost.of.sales.per.day 1 0.0 3502
## Creditors.turnover 1 0.0 3501
## Debtors.turnover 1 3099.8 3500

## Finished.goods.turnover 1 0.0 3499


## WIP.turnover 1 0.0 3498
## Raw.material.turnover 1 4181.1 3497
## Shares.outstanding 1 2667.2 3496
## Equity.face.value 1 0.0 3495
## EPS 1 0.0 3494
## Adjusted.EPS 1 0.0 3493
## Total.liabilities 0 0.0 3493
## PE.on.BSE 1 14478.9 3492
## Resid. Dev Pr(>Chi)
## NULL 1723.7
## Total.assets 1716.5 0.0072743 **
## Net.worth 1636.5 < 2.2e-16 ***
## Total.income 1571.2 6.528e-16 ***
## Change.in.stock 1571.0 0.6269971
## Total.expenses 1511.7 1.338e-14 ***
## Profit.after.tax 1463.4 3.781e-12 ***
## PBDITA 1404.9 1.980e-14 ***
## PBT 1388.6 5.539e-05 ***
## Cash.profit 1274.2 < 2.2e-16 ***
## PBDITA.as...of.total.income
1249.2 5.655e-07 ***
## PBT.as...of.total.income
1240.1 0.0024808 **
## PAT.as...of.total.income
1239.8 0.5984652
## Cash.profit.as...of.total.income
1235.8 0.0469348 *
## PAT.as...of.net.worth
1090.4 < 2.2e-16 ***
## Sales 1073.0 3.036e-05 ***
## Income.from.financial.services 1060.4 0.0003876 ***
## Other.income 1060.4 0.9578082
## Total.capital 1059.3 0.2932411
## Reserves.and.funds 1026.9 1.257e-08 ***
## Borrowings 1025.4 0.2285386
## Current.liabilities...provisions 1012.2 0.0002760 ***
## Deferred.tax.liability 1010.4 0.1780105
## Shareholders.funds 1009.4 0.3186585
## Cumulative.retained.profits 1005.2 0.0410643 *
## Capital.employed 1002.0 0.0707777 .
## TOL.TNW 937.0 7.683e-16 ***
## Total.term.liabilities...tangible.net.worth
936.6 0.4989419
## Contingent.liabilities...Net.worth.... 936.6 0.9063633
## Contingent.liabilities 925.6 0.0009474 ***
## Net.fixed.assets 923.2 0.1227011
## Investments 12975.7 1.0000000
## Current.assets 13264.1 1.0000000
## Net.working.capital 13696.6 1.0000000
## Quick.ratio..times. 13119.9 < 2.2e-16 ***
## Current.ratio..times. 13119.9 1.0000000
## Debt.to.equity.ratio..times. 15787.1 1.0000000
## Cash.to.current.liabilities..times. 12471.1 < 2.2e-16 ***
## Cash.to.average.cost.of.sales.per.day 15787.1 1.0000000
## Creditors.turnover 15859.2 1.0000000
## Debtors.turnover 12759.5 < 2.2e-16 ***
## Finished.goods.turnover 13912.9 1.0000000
## WIP.turnover 19103.1 1.0000000
## Raw.material.turnover 14922.1 < 2.2e-16 ***
## Shares.outstanding 12254.8 < 2.2e-16 ***
## Equity.face.value 13119.9 1.0000000
## EPS 13840.8 1.0000000
## Adjusted.EPS 15354.6 1.0000000
## Total.liabilities 15354.6
## PE.on.BSE 875.7 < 2.2e-16 ***

## ---
## 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

## PBT 1.544e-03 1.453e-02


0.106
## Cash.profit 8.677e-03 5.072e-03
1.711
## PBDITA.as...of.total.income
-3.056e-03 6.015e-03
-0.508
## PBT.as...of.total.income
9.450e-03 1.692e-02
0.559
## PAT.as...of.total.income
-1.122e-02 1.811e-02
-0.620
## Cash.profit.as...of.total.income
7.606e-03 6.603e-03
1.152
## PAT.as...of.net.worth
2.186e-02 3.106e-03
7.039
## Sales 2.976e-02 6.485e-03
4.589
## Income.from.financial.services 4.540e-02 2.195e-02
2.068
## Other.income 2.707e-02 1.925e-02
1.406
## Total.capital 2.973e-03 1.850e-03
1.608
## Reserves.and.funds 5.914e-03 2.122e-03
2.787
## Borrowings 1.305e-03 6.581e-03
0.198
## Current.liabilities...provisions 5.379e-03 2.063e-03
2.608
## Deferred.tax.liability 3.635e-03 4.063e-03
0.895
## Shareholders.funds 1.107e-03 6.023e-03
0.184
## Cumulative.retained.profits 1.859e-03 2.218e-03
0.838
## Capital.employed 3.352e-03 6.968e-03
0.481
## TOL.TNW -4.281e-02 1.886e-02
-2.269
## Total.term.liabilities...tangible.net.worth
5.996e-02 4.377e-02
1.370
## Contingent.liabilities...Net.worth.... -1.386e-03 8.976e-04
-1.544
## Contingent.liabilities 2.916e-03 1.174e-03
2.485
## Net.fixed.assets -1.190e-03 7.400e-04
-1.608
## Investments -1.891e-03 1.653e-03
-1.144

## Current.assets -1.590e-03 1.704e-03


-0.933
## Net.working.capital 1.027e-03 1.855e-03
0.554
## Quick.ratio..times. 2.479e-01 1.231e-01
2.014
## Current.ratio..times. 1.323e-03 6.617e-02
0.020
## Debt.to.equity.ratio..times. -7.344e-02 3.420e-02
-2.148
## Cash.to.current.liabilities..times. -3.563e-01 2.011e-01
-1.772
## Cash.to.average.cost.of.sales.per.day -8.885e-04 3.968e-04
-2.239
## Creditors.turnover 5.455e-03 6.255e-03
0.872
## Debtors.turnover -3.261e-03 3.206e-03
-1.017
## Finished.goods.turnover -1.757e-03 6.833e-04
-2.572
## WIP.turnover 5.073e-03 3.530e-03
1.437
## Raw.material.turnover -4.918e-03 6.989e-03
-0.704
## Shares.outstanding -5.119e-10 2.858e-09
-0.179
## Equity.face.value 8.851e-06 1.043e-03
0.008
## EPS -2.357e-02 2.344e-02
-1.006
## Adjusted.EPS 2.418e-02 2.358e-02
1.025
## Total.liabilities NA NA
NA
## PE.on.BSE 9.813e-04 6.564e-04
1.495
## Pr(>|z|)
## (Intercept)< 2e-16 ***
## Total.assets 0.00781 **
## Net.worth 0.48398
## Total.income 1.78e-05 ***
## Change.in.stock 0.12485
## Total.expenses 0.47550
## Profit.after.tax 0.82777
## PBDITA 2.33e-07 ***
## PBT 0.91537
## Cash.profit 0.08714 .

## 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

#Now is the time to implement and check the performance of boruta


package. The syntax of boruta is almost similar to regression (lm)
method.
# install.packages("Boruta")
library(Boruta)
## Warning: package 'Boruta' was built under R version 3.4.4 ## Loading
required package: ranger
set.seed(123)
boruta.train <- Boruta(Default~., data = train, doTrace = 2)

boruta.train$ImpHistory[is.finite(boruta.train$ImpHistory[,i]),i]) names(lz) <-


colnames(boruta.train$ImpHistory)
Labels <- sort(sapply(lz,median))
axis(side = 1,las=2,labels = names(Labels), at =
1:ncol(boruta.train$ImpHistory), cex.axis = 0.7)

final.boruta <- TentativeRoughFix(boruta.train) print(final.boruta)


## Boruta performed 99 iterations in 6.128146 mins.
## Tentatives roughfixed over the last 99 iterations.
## 42 attributes confirmed important: Adjusted.EPS, Borrowings,
Capital.employed, Cash.profit, Cash.profit.as...of.total.income and 37
more;
## 7 attributes confirmed unimportant:
## Cash.to.average.cost.of.sales.per.day,
## Cash.to.current.liabilities..times., Creditors.turnover,
## Current.ratio..times., Equity.face.value and 2 more;
train <- train[,getSelectedAttributes(final.boruta, withTentative = F)]
train <- cbind(data[2],train) dim(train)
## [1] 3541 43
View(train)
colnames(train[1]) = "Default"

boruta.df <- attStats(final.boruta) class(boruta.df)


## [1] "data.frame"
print(boruta.df)
## meanImp medianImp
## Total.assets 5.6848550 5.4741921
## Net.worth 10.1874958 10.2583608
## Total.income 5.7116518 5.6530456
## Change.in.stock 7.6687597 7.6367323
## Total.expenses 6.0135622 5.9888636
## Profit.after.tax 11.2455511 11.3079792
## PBDITA 8.1337785 8.2247391
## PBT 12.1360119 12.1463871
## Cash.profit 11.2626284 11.2452606
## PBDITA.as...of.total.income 7.9302617 7.9647158
## PBT.as...of.total.income 10.5030411 10.4486280
## PAT.as...of.total.income 9.7589165 9.8462562
## Cash.profit.as...of.total.income 11.8367538 11.9593037
## PAT.as...of.net.worth 16.0474512 16.1155187
## Sales 5.7853502 5.7269845
## Income.from.financial.services 3.6098586 3.5708939
## Other.income 4.6264741 4.6391333
## Total.capital 5.6958011 5.6444980
## Reserves.and.funds 7.8528069 7.6862604
## Borrowings 6.8840979 6.9319835
## Current.liabilities...provisions 6.7433888 6.8067864
## Deferred.tax.liability 4.8057418 4.8025729
## Shareholders.funds 9.7960840 9.7826295
## Cumulative.retained.profits 9.2598965 9.2850155
## Capital.employed 7.5643983 7.4892053
## TOL.TNW 19.8694788 19.8687016
## Total.term.liabilities...tangible.net.worth 13.4156150 13.4252889
## Contingent.liabilities...Net.worth.... 6.4054664 6.4414674
## Contingent.liabilities 5.3286876 5.4567158
## Net.fixed.assets 7.0360965 6.9920044
## Investments 2.0726629 2.1512085
## Current.assets 5.7225924 5.7868951
## Net.working.capital 6.9316837 6.9061285
## Quick.ratio..times. -0.2011067 -0.2369274
## Current.ratio..times. 1.2389497 1.4154778
## Debt.to.equity.ratio..times. 17.5078508 17.5173415

## Cash.to.current.liabilities..times. -0.5556410 -0.4214221


## Cash.to.average.cost.of.sales.per.day 1.2994065 1.4139290
## Creditors.turnover 3.2275236 3.1830241
## Debtors.turnover 4.2788961 4.3319679
## Finished.goods.turnover 3.1429970 3.1617051
## WIP.turnover 4.0050806 4.0382613
## Raw.material.turnover 4.6093714 4.6663572
## Shares.outstanding 2.6656452 2.6975405
## Equity.face.value 1.4750935 1.4800973
## EPS 9.6019601 9.6210269
## Adjusted.EPS 9.8221389 9.7737227
## Total.liabilities 5.6116307 5.5571793
## PE.on.BSE 6.7680547 6.6058002
## minImp maxImp
## Total.assets 3.62169491 7.7741503
## Net.worth 8.53325506 12.0444190
## Total.income 4.25531086 7.5366142
## Change.in.stock 5.35626655 9.3832366
## Total.expenses 4.18795358 7.3671490
## Profit.after.tax 9.29290291 13.3686461
## PBDITA 6.27044306 9.8091873
## PBT 9.36656365 14.7254457
## Cash.profit 9.10122253 13.6766093
## PBDITA.as...of.total.income
6.53077833 8.8221845
## PBT.as...of.total.income
9.21219159 12.1472935
## PAT.as...of.total.income
8.56497301 11.1001274
## Cash.profit.as...of.total.income
8.83198590 13.4750057
## PAT.as...of.net.worth
14.20364693 18.2428335
## Sales 4.32173965 7.2940169
## Income.from.financial.services 1.85487730 5.3457087
## Other.income 2.16619312 6.1257440
## Total.capital 3.95317186 7.5334725
## Reserves.and.funds 5.28518158 10.2431069
## Borrowings 5.21914925 8.2493878
## Current.liabilities...provisions 4.97984341 8.6195315
## Deferred.tax.liability 3.42353937 6.3229262
## Shareholders.funds 8.26480869 11.2969482
## Cumulative.retained.profits 7.66885623 11.2864544
## Capital.employed 6.06110345 9.6531699
## TOL.TNW 18.06039769 21.7118099
## Total.term.liabilities...tangible.net.worth
11.86162704 15.2825980
## Contingent.liabilities...Net.worth.... 3.96629386 8.5538660
## Contingent.liabilities 3.57293041 6.8769645
## Net.fixed.assets 5.13385839 9.0263262

## Investments -0.18075665 4.3997736


## Current.assets 4.39201239 7.3043050
## Net.working.capital 5.27815754 9.4319129
## Quick.ratio..times. -2.33315892 2.2648527
## Current.ratio..times. 0.07273932 2.1790623
## Debt.to.equity.ratio..times. 15.26488058 19.1569294
## Cash.to.current.liabilities..times. -1.97738673 0.7096837
## Cash.to.average.cost.of.sales.per.day -0.59722669 3.6906851
## Creditors.turnover 1.50721188 4.8597755
## Debtors.turnover 1.28315109 5.9750329
## Finished.goods.turnover 0.57756594 4.7961857
## WIP.turnover 2.50435679 5.5606877
## Raw.material.turnover 2.45495657 6.4346714
## Shares.outstanding 0.08664660 4.5428689
## Equity.face.value 0.54803752 2.6758926
## EPS 7.91904021 11.1822860
## Adjusted.EPS 7.43819171 11.8957807
## Total.liabilities 3.81336097 8.2587030
## PE.on.BSE 5.27353957 9.1391080
## normHits decision
## Total.assets 0.97979798 Confirmed
## Net.worth 1.00000000 Confirmed
## Total.income 0.98989899 Confirmed
## Change.in.stock 1.00000000 Confirmed
## Total.expenses 0.98989899 Confirmed
## Profit.after.tax 1.00000000 Confirmed
## PBDITA 1.00000000 Confirmed
## PBT 1.00000000 Confirmed
## Cash.profit 1.00000000 Confirmed
## PBDITA.as...of.total.income 1.00000000 Confirmed
## PBT.as...of.total.income 1.00000000 Confirmed
## PAT.as...of.total.income 1.00000000 Confirmed
## Cash.profit.as...of.total.income 1.00000000 Confirmed
## PAT.as...of.net.worth 1.00000000 Confirmed
## Sales 1.00000000 Confirmed
## Income.from.financial.services 0.73737374 Confirmed
## Other.income 0.91919192 Confirmed
## Total.capital 1.00000000 Confirmed
## Reserves.and.funds 1.00000000 Confirmed
## Borrowings 1.00000000 Confirmed
## Current.liabilities...provisions 1.00000000 Confirmed
## Deferred.tax.liability 0.95959596 Confirmed
## Shareholders.funds 1.00000000 Confirmed
## Cumulative.retained.profits 1.00000000 Confirmed

## Capital.employed 1.00000000 Confirmed


## TOL.TNW 1.00000000 Confirmed
## Total.term.liabilities...tangible.net.worth 1.00000000 Confirmed
## Contingent.liabilities...Net.worth.... 1.00000000 Confirmed
## Contingent.liabilities 0.97979798 Confirmed
## Net.fixed.assets 1.00000000 Confirmed
## Investments 0.22222222 Rejected
## Current.assets 0.98989899 Confirmed
## Net.working.capital 1.00000000 Confirmed
## Quick.ratio..times. 0.00000000 Rejected
## Current.ratio..times. 0.00000000 Rejected
## Debt.to.equity.ratio..times. 1.00000000 Confirmed
## Cash.to.current.liabilities..times. 0.00000000 Rejected
## Cash.to.average.cost.of.sales.per.day 0.01010101 Rejected
## Creditors.turnover 0.60606061 Rejected
## Debtors.turnover 0.83838384 Confirmed
## Finished.goods.turnover 0.57575758 Confirmed
## WIP.turnover 0.82828283 Confirmed
## Raw.material.turnover 0.93939394 Confirmed
## Shares.outstanding 0.38383838 Confirmed
## Equity.face.value 0.01010101 Rejected
## EPS 1.00000000 Confirmed
## Adjusted.EPS 1.00000000 Confirmed
## Total.liabilities 0.96969697 Confirmed
## PE.on.BSE 1.00000000 Confirmed
my_logit1 <- glm(Default~., family = "binomial", data = train)
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
my_logit1
##
## Call: glm(formula = Default ~ ., family = "binomial", data = train) ##
## Coefficients:
## (Intercept)
## 2.598e+00
## Total.assets
## -6.136e-03
## Net.worth
## 6.428e-04
## Total.income
## -3.264e-02
## Change.in.stock
## -9.556e-03
## Total.expenses
## 2.398e-03

## 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

## PE.on.BSE ## 1 2.491 3499


Resid. Dev Pr(>Chi)
## NULL 1723.67
## Total.assets 1716.46 0.0072743 **
## Net.worth 1636.50 < 2.2e-16 ***
## Total.income 1571.23 6.528e-16 ***
## Change.in.stock 1570.99 0.6269971
## Total.expenses 1511.67 1.338e-14 ***
## Profit.after.tax 1463.43 3.781e-12 ***
## PBDITA 1404.88 1.980e-14 ***
## PBT 1388.63 5.539e-05 ***
## Cash.profit 1274.23 < 2.2e-16 ***
## PBDITA.as...of.total.income
1249.21 5.655e-07 ***
## PBT.as...of.total.income
1240.05 0.0024808 **
## PAT.as...of.total.income
1239.78 0.5984652
## Cash.profit.as...of.total.income
1235.83 0.0469348 *
## PAT.as...of.net.worth
1090.39 < 2.2e-16 ***
## Sales 1072.99 3.036e-05 ***
## Income.from.financial.services 1060.40 0.0003876 ***
## Other.income 1060.40 0.9578082
## Total.capital 1059.29 0.2932411
## Reserves.and.funds 1026.90 1.257e-08 ***
## Borrowings 1025.45 0.2285386
## Current.liabilities...provisions 1012.22 0.0002760 ***
## Deferred.tax.liability 1010.41 0.1780105
## Shareholders.funds 1009.41 0.3186585
## Cumulative.retained.profits 1005.24 0.0410643 *
## Capital.employed 1001.97 0.0707777 .
## TOL.TNW 937.02 7.683e-16 ***
## Total.term.liabilities...tangible.net.worth
936.57 0.4989419
## Contingent.liabilities...Net.worth.... 936.55 0.9063633
## Contingent.liabilities 925.62 0.0009474 ***
## Net.fixed.assets 923.24 0.1227011
## Current.assets 922.85 0.5294395
## Net.working.capital 922.26 0.4442690
## Debt.to.equity.ratio..times. 916.34 0.0149143 *
## Debtors.turnover 900.60 7.287e-05 ***
## Finished.goods.turnover 898.93 0.1963453
## WIP.turnover 895.11 0.0504698 .
## Raw.material.turnover 895.06 0.8305061
## Shares.outstanding 894.78 0.5946070
## EPS 894.69 0.7734053
## Adjusted.EPS 894.33 0.5493831
## Total.liabilities 894.33

## PE.on.BSE 891.84 0.1144780


## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(my_logit1)
##
## Call:
## glm(formula = Default ~ ., family = "binomial", data = train) ##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -4.5816 0.0012 0.1121 0.2834 3.2747
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error z
value
## (Intercept)2.598e+00 2.177e-01
11.933
## Total.assets -6.136e-03 1.716e-03
-3.576
## Net.worth 6.428e-04 2.059e-03
0.312
## Total.income -3.264e-02 7.369e-03
-4.429
## Change.in.stock -9.556e-03 5.654e-03
-1.690
## Total.expenses 2.398e-03 3.314e-03
0.724
## Profit.after.tax -5.557e-03 1.512e-02
-0.368
## PBDITA 3.323e-02 6.395e-03
5.196
## PBT 4.607e-03 1.437e-02
0.321
## Cash.profit 9.070e-03 5.116e-03
1.773
## PBDITA.as...of.total.income
-5.804e-03 6.201e-03
-0.936
## PBT.as...of.total.income
8.545e-03 1.714e-02
0.499
## PAT.as...of.total.income
-9.263e-03 1.829e-02
-0.507
## Cash.profit.as...of.total.income
7.531e-03 6.697e-03
1.124
## PAT.as...of.net.worth
2.187e-02 3.093e-03
7.069
## Sales 2.981e-02 6.500e-03
4.586

## Income.from.financial.services 4.569e-02 2.147e-02


2.128
## Other.income 2.607e-02 1.973e-02
1.321
## Total.capital 3.800e-03 1.819e-03
2.089
## Reserves.and.funds 6.725e-03 2.124e-03
3.166
## Borrowings 4.076e-03 5.581e-03
0.730
## Current.liabilities...provisions 6.221e-03 2.086e-03
2.982
## Deferred.tax.liability 4.757e-03 4.696e-03
1.013
## Shareholders.funds 4.020e-03 4.840e-03
0.831
## Cumulative.retained.profits 1.920e-03 2.208e-03
0.869
## Capital.employed 1.641e-03 6.255e-03
0.262
## TOL.TNW -4.839e-02 1.925e-02
-2.514
## Total.term.liabilities...tangible.net.worth
7.314e-02 4.205e-02
1.739
## Contingent.liabilities...Net.worth.... -1.511e-03 9.145e-04
-1.652
## Contingent.liabilities 3.080e-03 1.336e-03
2.305
## Net.fixed.assets -1.043e-03 7.209e-04
-1.447
## Current.assets -6.561e-04 1.527e-03
-0.430
## Net.working.capital 6.987e-04 1.838e-03
0.380
## Debt.to.equity.ratio..times. -7.458e-02 3.340e-02
-2.233
## Debtors.turnover -3.324e-03 2.931e-03
-1.134
## Finished.goods.turnover -1.735e-03 6.844e-04
-2.535
## WIP.turnover 6.230e-03 3.498e-03
1.781
## Raw.material.turnover -7.932e-04 6.676e-03
-0.119
## Shares.outstanding -6.817e-10 6.246e-10
-1.091
## EPS -2.328e-02 2.216e-02
-1.050

## 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")

## Analysis of Deviance Table


##
## Model: gaussian, link: identity
##
## Response: Default
##
## Terms added sequentially (first to last)
##
##
##
Pr(>Chi) Df Deviance Resid. Df Resid. Dev
## NULL 396 15.355
## Total.assets 1 0.0139 395 15.341
0.48353
## Total.income 1 0.0001 394 15.341
0.94292
## PBDITA 1 0.0073 393 15.334
0.61162
## PAT.as...of.net.worth
1 4.3077 392 11.026
2e-16
## Sales 1 0.0003 391 11.026
0.92056
## Income.from.financial.services 1 0.0041 390 11.022
0.70456
## Total.capital 1 0.0037 389 11.018
0.71598
## Reserves.and.funds 1 0.0152 388 11.003
0.46423
## Current.liabilities...provisions 1 0.0079 387 10.995
0.59735
## TOL.TNW 1 0.0223 386 10.973
0.37498
## Contingent.liabilities 1 0.0109 385 10.962
0.53547
## Debt.to.equity.ratio..times. 1 0.0958 384 10.866
0.06586
## Finished.goods.turnover 1 0.0208 383 10.845
0.39178
##
## NULL
## 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
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.

You might also like