library(ggplot2)
library(Rtsne)
library(e1071)
library(lattice)
library(corrplot)
## corrplot 0.92 loaded
library(caret)
library(superml)
## Loading required package: R6
library(CatEncoders)
##
## Attaching package: 'CatEncoders'
## The following object is masked from 'package:base':
##
## transform
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(dplyr)
library(ggplot2)
library(data.table)
##
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
##
## between, first, last
library(dplyr)
library(ggplot2)
library(data.table)
library(mclust)
## Package 'mclust' version 5.4.10
## Type 'citation("mclust")' for citing this R package in publications.
library(caret)
library(corrplot)
library(clustvarsel)
## Package 'clustvarsel' version 2.3.4
## Type 'citation("clustvarsel")' for citing this R package in publications.
library(wskm)
## Loading required package: latticeExtra
##
## Attaching package: 'latticeExtra'
## The following object is masked from 'package:ggplot2':
##
## layer
## Loading required package: fpc
library(cluster)
library(reshape2)
##
## Attaching package: 'reshape2'
## The following objects are masked from 'package:data.table':
##
## dcast, melt
library(DataExplorer)
library(lattice)
library(Hmisc)
## Loading required package: survival
##
## Attaching package: 'survival'
## The following object is masked from 'package:caret':
##
## cluster
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
##
## src, summarize
## The following object is masked from 'package:e1071':
##
## impute
## The following objects are masked from 'package:base':
##
## format.pval, units
library(caret)
library(psych)
##
## Attaching package: 'psych'
## The following object is masked from 'package:Hmisc':
##
## describe
## The following object is masked from 'package:mclust':
##
## sim
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(ggcorrplot)
library(tidyr)
##
## Attaching package: 'tidyr'
## The following object is masked from 'package:reshape2':
##
## smiths
library(RColorBrewer)
library("rpart.plot")
## Loading required package: rpart
dfb <- read.csv("C:/Users/geoff/Downloads/Bankruptcy/data.csv")
head(dfb)
## Bankrupt. ROA.C..before.interest.and.depreciation.before.interest
## 1 1 0.3705943
## 2 1 0.4642909
## 3 1 0.4260713
## 4 1 0.3998440
## 5 1 0.4650222
## 6 1 0.3886803
## ROA.A..before.interest.and...after.tax
## 1 0.4243894
## 2 0.5382141
## 3 0.4990188
## 4 0.4512647
## 5 0.5384322
## 6 0.4151766
## ROA.B..before.interest.and.depreciation.after.tax Operating.Gross.Margin
## 1 0.4057498 0.6014572
## 2 0.5167300 0.6102351
## 3 0.4722951 0.6014500
## 4 0.4577333 0.5835411
## 5 0.5222978 0.5987835
## 6 0.4191338 0.5901714
## Realized.Sales.Gross.Margin Operating.Profit.Rate Pre.tax.net.Interest.Rate
## 1 0.6014572 0.9989692 0.7968871
## 2 0.6102351 0.9989460 0.7973802
## 3 0.6013635 0.9988574 0.7964034
## 4 0.5835411 0.9986997 0.7969670
## 5 0.5987835 0.9989731 0.7973661
## 6 0.5902507 0.9987581 0.7969032
## After.tax.net.Interest.Rate Non.industry.income.and.expenditure.revenue
## 1 0.8088094 0.3026464
## 2 0.8093007 0.3035564
## 3 0.8083875 0.3020352
## 4 0.8089656 0.3033495
## 5 0.8093037 0.3034750
## 6 0.8087706 0.3031158
## Continuous.interest.rate..after.tax. Operating.Expense.Rate
## 1 0.7809849 1.256969e-04
## 2 0.7815060 2.897851e-04
## 3 0.7802839 2.361297e-04
## 4 0.7812410 1.078888e-04
## 5 0.7815500 7.890000e+09
## 6 0.7810691 1.571500e-04
## Research.and.development.expense.rate Cash.flow.rate
## 1 0 0.4581431
## 2 0 0.4618673
## 3 25500000 0.4585206
## 4 0 0.4657054
## 5 0 0.4627463
## 6 0 0.4658615
## Interest.bearing.debt.interest.rate Tax.rate..A. Net.Value.Per.Share..B.
## 1 0.0007250725 0 0.1479499
## 2 0.0006470647 0 0.1822511
## 3 0.0007900790 0 0.1779107
## 4 0.0004490449 0 0.1541865
## 5 0.0006860686 0 0.1675024
## 6 0.0007160716 0 0.1555771
## Net.Value.Per.Share..A. Net.Value.Per.Share..C.
## 1 0.1479499 0.1479499
## 2 0.1822511 0.1822511
## 3 0.1779107 0.1937129
## 4 0.1541865 0.1541865
## 5 0.1675024 0.1675024
## 6 0.1555771 0.1555771
## Persistent.EPS.in.the.Last.Four.Seasons Cash.Flow.Per.Share
## 1 0.1691406 0.3116644
## 2 0.2089439 0.3181368
## 3 0.1805805 0.3071019
## 4 0.1937222 0.3216736
## 5 0.2125366 0.3191625
## 6 0.1744351 0.3253873
## Revenue.Per.Share..Yuan... Operating.Profit.Per.Share..Yuan...
## 1 0.017559780 0.09592053
## 2 0.021144335 0.09372201
## 3 0.005944008 0.09233776
## 4 0.014368468 0.07776240
## 5 0.029689792 0.09689765
## 6 0.018104270 0.07808810
## Per.Share.Net.profit.before.tax..Yuan...
## 1 0.1387362
## 2 0.1699179
## 3 0.1428033
## 4 0.1486028
## 5 0.1684115
## 6 0.1388115
## Realized.Sales.Gross.Profit.Growth.Rate Operating.Profit.Growth.Rate
## 1 0.02210228 0.8481950
## 2 0.02208017 0.8480879
## 3 0.02276010 0.8480940
## 4 0.02204607 0.8480055
## 5 0.02209591 0.8482582
## 6 0.02156494 0.8479828
## After.tax.Net.Profit.Growth.Rate Regular.Net.Profit.Growth.Rate
## 1 0.6889795 0.6889795
## 2 0.6896929 0.6897017
## 3 0.6894627 0.6894697
## 4 0.6891095 0.6891095
## 5 0.6896969 0.6896969
## 6 0.6891051 0.6891775
## Continuous.Net.Profit.Growth.Rate Total.Asset.Growth.Rate
## 1 0.2175354 4.98e+09
## 2 0.2176196 6.11e+09
## 3 0.2176013 7.28e+09
## 4 0.2175682 4.88e+09
## 5 0.2176256 5.51e+09
## 6 0.2175664 6.08e+08
## Net.Value.Growth.Rate Total.Asset.Return.Growth.Rate.Ratio
## 1 0.0003269773 0.2631000
## 2 0.0004430401 0.2645158
## 3 0.0003964253 0.2641840
## 4 0.0003824259 0.2633712
## 5 0.0004389476 0.2652182
## 6 0.0003517819 0.2632500
## Cash.Reinvestment.. Current.Ratio Quick.Ratio Interest.Expense.Ratio
## 1 0.3637253 0.002258963 0.0012077551 0.6299513
## 2 0.3767091 0.006016206 0.0040393668 0.6351725
## 3 0.3689132 0.011542554 0.0053475602 0.6296314
## 4 0.3840766 0.004194059 0.0028964911 0.6302284
## 5 0.3796897 0.006022446 0.0037274466 0.6360550
## 6 0.3880258 0.002740085 0.0008546614 0.6301838
## Total.debt.Total.net.worth Debt.ratio.. Net.worth.Assets
## 1 0.021265924 0.2075763 0.7924237
## 2 0.012502394 0.1711763 0.8288237
## 3 0.021247686 0.2075158 0.7924842
## 4 0.009572402 0.1514648 0.8485352
## 5 0.005149600 0.1065091 0.8934909
## 6 0.014213152 0.1804275 0.8195725
## Long.term.fund.suitability.ratio..A. Borrowing.dependency
## 1 0.005024455 0.3902844
## 2 0.005058882 0.3767600
## 3 0.005099899 0.3790929
## 4 0.005046924 0.3797427
## 5 0.005303319 0.3750254
## 6 0.004913193 0.3814482
## Contingent.liabilities.Net.worth Operating.profit.Paid.in.capital
## 1 0.006478502 0.09588483
## 2 0.005835039 0.09374338
## 3 0.006561982 0.09231847
## 4 0.005365848 0.07772729
## 5 0.006623525 0.09692706
## 6 0.005749123 0.07810185
## Net.profit.before.tax.Paid.in.capital
## 1 0.1377573
## 2 0.1689616
## 3 0.1480356
## 4 0.1475605
## 5 0.1674610
## 6 0.1378252
## Inventory.and.accounts.receivable.Net.value Total.Asset.Turnover
## 1 0.3980357 0.08695652
## 2 0.3977249 0.06446777
## 3 0.4065805 0.01499250
## 4 0.3979245 0.08995502
## 5 0.4000788 0.17541229
## 6 0.4004191 0.09595202
## Accounts.Receivable.Turnover Average.Collection.Days
## 1 0.001813884 0.003487364
## 2 0.001286356 0.004916808
## 3 0.001495338 0.004226849
## 4 0.001966056 0.003214967
## 5 0.001448673 0.004366891
## 6 0.001527802 0.004137189
## Inventory.Turnover.Rate..times. Fixed.Assets.Turnover.Frequency
## 1 1.820926e-04 1.165007e-04
## 2 9.360000e+09 7.190000e+08
## 3 6.500000e+07 2.650000e+09
## 4 7.130000e+09 9.150000e+09
## 5 1.633674e-04 2.935211e-04
## 6 6.500000e+08 9.300000e+09
## Net.Worth.Turnover.Rate..times. Revenue.per.person
## 1 0.03290323 0.034164182
## 2 0.02548387 0.006888651
## 3 0.01338710 0.028996960
## 4 0.02806452 0.015463478
## 5 0.04016129 0.058111423
## 6 0.02967742 0.021300471
## Operating.profit.per.person Allocation.rate.per.person
## 1 0.3929129 0.03713530
## 2 0.3915900 0.01233497
## 3 0.3819678 0.14101631
## 4 0.3784966 0.02131999
## 5 0.3943715 0.02398821
## 6 0.3775695 0.03282877
## Working.Capital.to.Total.Assets Quick.Assets.Total.Assets
## 1 0.6727753 0.16667296
## 2 0.7511109 0.12723600
## 3 0.8295019 0.34020088
## 4 0.7257542 0.16157453
## 5 0.7518225 0.26032988
## 6 0.6867286 0.08026371
## Current.Assets.Total.Assets Cash.Total.Assets Quick.Assets.Current.Liability
## 1 0.1906430 0.0040944060 0.001996771
## 2 0.1824191 0.0149477270 0.004136030
## 3 0.6028057 0.0009909445 0.006302481
## 4 0.2258149 0.0188506248 0.002961238
## 5 0.3583802 0.0141609738 0.004274771
## 6 0.2145360 0.0026452256 0.000988425
## Cash.Current.Liability Current.Liability.to.Assets
## 1 1.473360e-04 0.14730845
## 2 1.383910e-03 0.05696283
## 3 5.340000e+09 0.09816206
## 4 1.010646e-03 0.09871463
## 5 6.804636e-04 0.11019485
## 6 1.008563e-04 0.13900211
## Operating.Funds.to.Liability Inventory.Working.Capital
## 1 0.3340152 0.2769202
## 2 0.3411060 0.2896416
## 3 0.3367315 0.2774555
## 4 0.3487164 0.2765803
## 5 0.3446388 0.2879127
## 6 0.3505631 0.2766785
## Inventory.Current.Liability Current.Liabilities.Liability
## 1 0.001035990 0.6762692
## 2 0.005209682 0.3085886
## 3 0.013878786 0.4460275
## 4 0.003540148 0.6158484
## 5 0.004868570 0.9750066
## 6 0.004879131 0.7333519
## Working.Capital.Equity Current.Liabilities.Equity
## 1 0.7212746 0.3390770
## 2 0.7319753 0.3297401
## 3 0.7427286 0.3347769
## 4 0.7298249 0.3315090
## 5 0.7319996 0.3307263
## 6 0.7252016 0.3355344
## Long.term.Liability.to.Current.Assets Retained.Earnings.to.Total.Assets
## 1 0.025592368 0.9032248
## 2 0.023946819 0.9310652
## 3 0.003715116 0.9099034
## 4 0.022165200 0.9069022
## 5 0.000000000 0.9138502
## 6 0.003772505 0.9030413
## Total.income.Total.expense Total.expense.Assets Current.Asset.Turnover.Rate
## 1 0.002021613 0.06485571 7.010000e+08
## 2 0.002225608 0.02551586 1.065198e-04
## 3 0.002060071 0.02138743 1.791094e-03
## 4 0.001831359 0.02416107 8.140000e+09
## 5 0.002223930 0.02638525 6.680000e+09
## 6 0.001865609 0.04009362 8.010000e+09
## Quick.Asset.Turnover.Rate Working.capitcal.Turnover.Rate Cash.Turnover.Rate
## 1 6.550000e+09 0.5938305 4.58e+08
## 2 7.700000e+09 0.5939155 2.49e+09
## 3 1.022676e-03 0.5945019 7.61e+08
## 4 6.050000e+09 0.5938888 2.03e+09
## 5 5.050000e+09 0.5939153 8.24e+08
## 6 2.810000e+09 0.5938458 2.95e+08
## Cash.Flow.to.Sales Fixed.Assets.to.Assets Current.Liability.to.Liability
## 1 0.6715677 0.4242058 0.6762692
## 2 0.6715699 0.4688281 0.3085886
## 3 0.6715713 0.2761792 0.4460275
## 4 0.6715192 0.5591440 0.6158484
## 5 0.6715631 0.3095549 0.9750066
## 6 0.6715676 0.6031935 0.7333519
## Current.Liability.to.Equity Equity.to.Long.term.Liability
## 1 0.3390770 0.1265495
## 2 0.3297401 0.1209161
## 3 0.3347769 0.1179223
## 4 0.3315090 0.1207605
## 5 0.3307263 0.1109332
## 6 0.3355344 0.1129172
## Cash.Flow.to.Total.Assets Cash.Flow.to.Liability CFO.to.Assets
## 1 0.6375554 0.4586091 0.5203819
## 2 0.6411000 0.4590011 0.5671013
## 3 0.6427646 0.4592540 0.5384905
## 4 0.5790393 0.4485179 0.6041051
## 5 0.6223741 0.4544109 0.5784689
## 6 0.6374698 0.4584993 0.6221901
## Cash.Flow.to.Equity Current.Liability.to.Current.Assets Liability.Assets.Flag
## 1 0.3129049 0.11825048 0
## 2 0.3141631 0.04777528 0
## 3 0.3145154 0.02534649 0
## 4 0.3023823 0.06724962 0
## 5 0.3115672 0.04772537 0
## 6 0.3132685 0.09952193 0
## Net.Income.to.Total.Assets Total.assets.to.GNP.price No.credit.Interval
## 1 0.7168453 0.009219440 0.6228790
## 2 0.7952971 0.008323302 0.6236517
## 3 0.7746697 0.040002853 0.6238410
## 4 0.7395545 0.003252475 0.6229287
## 5 0.7950159 0.003877563 0.6235207
## 6 0.7104205 0.005277875 0.6226046
## Gross.Profit.to.Sales Net.Income.to.Stockholder.s.Equity Liability.to.Equity
## 1 0.6014533 0.8278902 0.2902019
## 2 0.6102365 0.8399693 0.2838460
## 3 0.6014493 0.8367743 0.2901885
## 4 0.5835376 0.8346971 0.2817212
## 5 0.5987815 0.8399727 0.2785138
## 6 0.5901723 0.8299390 0.2850871
## Degree.of.Financial.Leverage..DFL.
## 1 0.02660063
## 2 0.26457682
## 3 0.02655472
## 4 0.02669663
## 5 0.02475185
## 6 0.02667537
## Interest.Coverage.Ratio..Interest.expense.to.EBIT. Net.Income.Flag
## 1 0.5640501 1
## 2 0.5701749 1
## 3 0.5637061 1
## 4 0.5646634 1
## 5 0.5756166 1
## 6 0.5645383 1
## Equity.to.Liability
## 1 0.01646874
## 2 0.02079431
## 3 0.01647411
## 4 0.02398233
## 5 0.03549020
## 6 0.01953448
str(dfb)
## 'data.frame': 6819 obs. of 96 variables:
## $ Bankrupt. : int 1 1 1 1 1 1 0 0 0 0 ...
## $ ROA.C..before.interest.and.depreciation.before.interest: num 0.371 0.464 0.426 0.4 0.465 ...
## $ ROA.A..before.interest.and...after.tax : num 0.424 0.538 0.499 0.451 0.538 ...
## $ ROA.B..before.interest.and.depreciation.after.tax : num 0.406 0.517 0.472 0.458 0.522 ...
## $ Operating.Gross.Margin : num 0.601 0.61 0.601 0.584 0.599 ...
## $ Realized.Sales.Gross.Margin : num 0.601 0.61 0.601 0.584 0.599 ...
## $ Operating.Profit.Rate : num 0.999 0.999 0.999 0.999 0.999 ...
## $ Pre.tax.net.Interest.Rate : num 0.797 0.797 0.796 0.797 0.797 ...
## $ After.tax.net.Interest.Rate : num 0.809 0.809 0.808 0.809 0.809 ...
## $ Non.industry.income.and.expenditure.revenue : num 0.303 0.304 0.302 0.303 0.303 ...
## $ Continuous.interest.rate..after.tax. : num 0.781 0.782 0.78 0.781 0.782 ...
## $ Operating.Expense.Rate : num 1.26e-04 2.90e-04 2.36e-04 1.08e-04 7.89e+09 ...
## $ Research.and.development.expense.rate : num 0.00 0.00 2.55e+07 0.00 0.00 0.00 7.30e+08 5.09e+07 0.00 0.00 ...
## $ Cash.flow.rate : num 0.458 0.462 0.459 0.466 0.463 ...
## $ Interest.bearing.debt.interest.rate : num 0.000725 0.000647 0.00079 0.000449 0.000686 ...
## $ Tax.rate..A. : num 0 0 0 0 0 ...
## $ Net.Value.Per.Share..B. : num 0.148 0.182 0.178 0.154 0.168 ...
## $ Net.Value.Per.Share..A. : num 0.148 0.182 0.178 0.154 0.168 ...
## $ Net.Value.Per.Share..C. : num 0.148 0.182 0.194 0.154 0.168 ...
## $ Persistent.EPS.in.the.Last.Four.Seasons : num 0.169 0.209 0.181 0.194 0.213 ...
## $ Cash.Flow.Per.Share : num 0.312 0.318 0.307 0.322 0.319 ...
## $ Revenue.Per.Share..Yuan... : num 0.01756 0.02114 0.00594 0.01437 0.02969 ...
## $ Operating.Profit.Per.Share..Yuan... : num 0.0959 0.0937 0.0923 0.0778 0.0969 ...
## $ Per.Share.Net.profit.before.tax..Yuan... : num 0.139 0.17 0.143 0.149 0.168 ...
## $ Realized.Sales.Gross.Profit.Growth.Rate : num 0.0221 0.0221 0.0228 0.022 0.0221 ...
## $ Operating.Profit.Growth.Rate : num 0.848 0.848 0.848 0.848 0.848 ...
## $ After.tax.Net.Profit.Growth.Rate : num 0.689 0.69 0.689 0.689 0.69 ...
## $ Regular.Net.Profit.Growth.Rate : num 0.689 0.69 0.689 0.689 0.69 ...
## $ Continuous.Net.Profit.Growth.Rate : num 0.218 0.218 0.218 0.218 0.218 ...
## $ Total.Asset.Growth.Rate : num 4.98e+09 6.11e+09 7.28e+09 4.88e+09 5.51e+09 6.08e+08 5.72e+09 6.63e+09 6.89e+09 5.55e+09 ...
## $ Net.Value.Growth.Rate : num 0.000327 0.000443 0.000396 0.000382 0.000439 ...
## $ Total.Asset.Return.Growth.Rate.Ratio : num 0.263 0.265 0.264 0.263 0.265 ...
## $ Cash.Reinvestment.. : num 0.364 0.377 0.369 0.384 0.38 ...
## $ Current.Ratio : num 0.00226 0.00602 0.01154 0.00419 0.00602 ...
## $ Quick.Ratio : num 0.00121 0.00404 0.00535 0.0029 0.00373 ...
## $ Interest.Expense.Ratio : num 0.63 0.635 0.63 0.63 0.636 ...
## $ Total.debt.Total.net.worth : num 0.02127 0.0125 0.02125 0.00957 0.00515 ...
## $ Debt.ratio.. : num 0.208 0.171 0.208 0.151 0.107 ...
## $ Net.worth.Assets : num 0.792 0.829 0.792 0.849 0.893 ...
## $ Long.term.fund.suitability.ratio..A. : num 0.00502 0.00506 0.0051 0.00505 0.0053 ...
## $ Borrowing.dependency : num 0.39 0.377 0.379 0.38 0.375 ...
## $ Contingent.liabilities.Net.worth : num 0.00648 0.00584 0.00656 0.00537 0.00662 ...
## $ Operating.profit.Paid.in.capital : num 0.0959 0.0937 0.0923 0.0777 0.0969 ...
## $ Net.profit.before.tax.Paid.in.capital : num 0.138 0.169 0.148 0.148 0.167 ...
## $ Inventory.and.accounts.receivable.Net.value : num 0.398 0.398 0.407 0.398 0.4 ...
## $ Total.Asset.Turnover : num 0.087 0.0645 0.015 0.09 0.1754 ...
## $ Accounts.Receivable.Turnover : num 0.00181 0.00129 0.0015 0.00197 0.00145 ...
## $ Average.Collection.Days : num 0.00349 0.00492 0.00423 0.00321 0.00437 ...
## $ Inventory.Turnover.Rate..times. : num 1.82e-04 9.36e+09 6.50e+07 7.13e+09 1.63e-04 ...
## $ Fixed.Assets.Turnover.Frequency : num 1.17e-04 7.19e+08 2.65e+09 9.15e+09 2.94e-04 ...
## $ Net.Worth.Turnover.Rate..times. : num 0.0329 0.0255 0.0134 0.0281 0.0402 ...
## $ Revenue.per.person : num 0.03416 0.00689 0.029 0.01546 0.05811 ...
## $ Operating.profit.per.person : num 0.393 0.392 0.382 0.378 0.394 ...
## $ Allocation.rate.per.person : num 0.0371 0.0123 0.141 0.0213 0.024 ...
## $ Working.Capital.to.Total.Assets : num 0.673 0.751 0.83 0.726 0.752 ...
## $ Quick.Assets.Total.Assets : num 0.167 0.127 0.34 0.162 0.26 ...
## $ Current.Assets.Total.Assets : num 0.191 0.182 0.603 0.226 0.358 ...
## $ Cash.Total.Assets : num 0.004094 0.014948 0.000991 0.018851 0.014161 ...
## $ Quick.Assets.Current.Liability : num 0.002 0.00414 0.0063 0.00296 0.00427 ...
## $ Cash.Current.Liability : num 1.47e-04 1.38e-03 5.34e+09 1.01e-03 6.80e-04 ...
## $ Current.Liability.to.Assets : num 0.1473 0.057 0.0982 0.0987 0.1102 ...
## $ Operating.Funds.to.Liability : num 0.334 0.341 0.337 0.349 0.345 ...
## $ Inventory.Working.Capital : num 0.277 0.29 0.277 0.277 0.288 ...
## $ Inventory.Current.Liability : num 0.00104 0.00521 0.01388 0.00354 0.00487 ...
## $ Current.Liabilities.Liability : num 0.676 0.309 0.446 0.616 0.975 ...
## $ Working.Capital.Equity : num 0.721 0.732 0.743 0.73 0.732 ...
## $ Current.Liabilities.Equity : num 0.339 0.33 0.335 0.332 0.331 ...
## $ Long.term.Liability.to.Current.Assets : num 0.02559 0.02395 0.00372 0.02217 0 ...
## $ Retained.Earnings.to.Total.Assets : num 0.903 0.931 0.91 0.907 0.914 ...
## $ Total.income.Total.expense : num 0.00202 0.00223 0.00206 0.00183 0.00222 ...
## $ Total.expense.Assets : num 0.0649 0.0255 0.0214 0.0242 0.0264 ...
## $ Current.Asset.Turnover.Rate : num 7.01e+08 1.07e-04 1.79e-03 8.14e+09 6.68e+09 ...
## $ Quick.Asset.Turnover.Rate : num 6.55e+09 7.70e+09 1.02e-03 6.05e+09 5.05e+09 ...
## $ Working.capitcal.Turnover.Rate : num 0.594 0.594 0.595 0.594 0.594 ...
## $ Cash.Turnover.Rate : num 4.58e+08 2.49e+09 7.61e+08 2.03e+09 8.24e+08 ...
## $ Cash.Flow.to.Sales : num 0.672 0.672 0.672 0.672 0.672 ...
## $ Fixed.Assets.to.Assets : num 0.424 0.469 0.276 0.559 0.31 ...
## $ Current.Liability.to.Liability : num 0.676 0.309 0.446 0.616 0.975 ...
## $ Current.Liability.to.Equity : num 0.339 0.33 0.335 0.332 0.331 ...
## $ Equity.to.Long.term.Liability : num 0.127 0.121 0.118 0.121 0.111 ...
## $ Cash.Flow.to.Total.Assets : num 0.638 0.641 0.643 0.579 0.622 ...
## $ Cash.Flow.to.Liability : num 0.459 0.459 0.459 0.449 0.454 ...
## $ CFO.to.Assets : num 0.52 0.567 0.538 0.604 0.578 ...
## $ Cash.Flow.to.Equity : num 0.313 0.314 0.315 0.302 0.312 ...
## $ Current.Liability.to.Current.Assets : num 0.1183 0.0478 0.0253 0.0672 0.0477 ...
## $ Liability.Assets.Flag : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Net.Income.to.Total.Assets : num 0.717 0.795 0.775 0.74 0.795 ...
## $ Total.assets.to.GNP.price : num 0.00922 0.00832 0.04 0.00325 0.00388 ...
## $ No.credit.Interval : num 0.623 0.624 0.624 0.623 0.624 ...
## $ Gross.Profit.to.Sales : num 0.601 0.61 0.601 0.584 0.599 ...
## $ Net.Income.to.Stockholder.s.Equity : num 0.828 0.84 0.837 0.835 0.84 ...
## $ Liability.to.Equity : num 0.29 0.284 0.29 0.282 0.279 ...
## $ Degree.of.Financial.Leverage..DFL. : num 0.0266 0.2646 0.0266 0.0267 0.0248 ...
## $ Interest.Coverage.Ratio..Interest.expense.to.EBIT. : num 0.564 0.57 0.564 0.565 0.576 ...
## $ Net.Income.Flag : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Equity.to.Liability : num 0.0165 0.0208 0.0165 0.024 0.0355 ...
# checking for missing values
colSums(is.na(dfb))
## Bankrupt.
## 0
## ROA.C..before.interest.and.depreciation.before.interest
## 0
## ROA.A..before.interest.and...after.tax
## 0
## ROA.B..before.interest.and.depreciation.after.tax
## 0
## Operating.Gross.Margin
## 0
## Realized.Sales.Gross.Margin
## 0
## Operating.Profit.Rate
## 0
## Pre.tax.net.Interest.Rate
## 0
## After.tax.net.Interest.Rate
## 0
## Non.industry.income.and.expenditure.revenue
## 0
## Continuous.interest.rate..after.tax.
## 0
## Operating.Expense.Rate
## 0
## Research.and.development.expense.rate
## 0
## Cash.flow.rate
## 0
## Interest.bearing.debt.interest.rate
## 0
## Tax.rate..A.
## 0
## Net.Value.Per.Share..B.
## 0
## Net.Value.Per.Share..A.
## 0
## Net.Value.Per.Share..C.
## 0
## Persistent.EPS.in.the.Last.Four.Seasons
## 0
## Cash.Flow.Per.Share
## 0
## Revenue.Per.Share..Yuan...
## 0
## Operating.Profit.Per.Share..Yuan...
## 0
## Per.Share.Net.profit.before.tax..Yuan...
## 0
## Realized.Sales.Gross.Profit.Growth.Rate
## 0
## Operating.Profit.Growth.Rate
## 0
## After.tax.Net.Profit.Growth.Rate
## 0
## Regular.Net.Profit.Growth.Rate
## 0
## Continuous.Net.Profit.Growth.Rate
## 0
## Total.Asset.Growth.Rate
## 0
## Net.Value.Growth.Rate
## 0
## Total.Asset.Return.Growth.Rate.Ratio
## 0
## Cash.Reinvestment..
## 0
## Current.Ratio
## 0
## Quick.Ratio
## 0
## Interest.Expense.Ratio
## 0
## Total.debt.Total.net.worth
## 0
## Debt.ratio..
## 0
## Net.worth.Assets
## 0
## Long.term.fund.suitability.ratio..A.
## 0
## Borrowing.dependency
## 0
## Contingent.liabilities.Net.worth
## 0
## Operating.profit.Paid.in.capital
## 0
## Net.profit.before.tax.Paid.in.capital
## 0
## Inventory.and.accounts.receivable.Net.value
## 0
## Total.Asset.Turnover
## 0
## Accounts.Receivable.Turnover
## 0
## Average.Collection.Days
## 0
## Inventory.Turnover.Rate..times.
## 0
## Fixed.Assets.Turnover.Frequency
## 0
## Net.Worth.Turnover.Rate..times.
## 0
## Revenue.per.person
## 0
## Operating.profit.per.person
## 0
## Allocation.rate.per.person
## 0
## Working.Capital.to.Total.Assets
## 0
## Quick.Assets.Total.Assets
## 0
## Current.Assets.Total.Assets
## 0
## Cash.Total.Assets
## 0
## Quick.Assets.Current.Liability
## 0
## Cash.Current.Liability
## 0
## Current.Liability.to.Assets
## 0
## Operating.Funds.to.Liability
## 0
## Inventory.Working.Capital
## 0
## Inventory.Current.Liability
## 0
## Current.Liabilities.Liability
## 0
## Working.Capital.Equity
## 0
## Current.Liabilities.Equity
## 0
## Long.term.Liability.to.Current.Assets
## 0
## Retained.Earnings.to.Total.Assets
## 0
## Total.income.Total.expense
## 0
## Total.expense.Assets
## 0
## Current.Asset.Turnover.Rate
## 0
## Quick.Asset.Turnover.Rate
## 0
## Working.capitcal.Turnover.Rate
## 0
## Cash.Turnover.Rate
## 0
## Cash.Flow.to.Sales
## 0
## Fixed.Assets.to.Assets
## 0
## Current.Liability.to.Liability
## 0
## Current.Liability.to.Equity
## 0
## Equity.to.Long.term.Liability
## 0
## Cash.Flow.to.Total.Assets
## 0
## Cash.Flow.to.Liability
## 0
## CFO.to.Assets
## 0
## Cash.Flow.to.Equity
## 0
## Current.Liability.to.Current.Assets
## 0
## Liability.Assets.Flag
## 0
## Net.Income.to.Total.Assets
## 0
## Total.assets.to.GNP.price
## 0
## No.credit.Interval
## 0
## Gross.Profit.to.Sales
## 0
## Net.Income.to.Stockholder.s.Equity
## 0
## Liability.to.Equity
## 0
## Degree.of.Financial.Leverage..DFL.
## 0
## Interest.Coverage.Ratio..Interest.expense.to.EBIT.
## 0
## Net.Income.Flag
## 0
## Equity.to.Liability
## 0
duplicates <- dfb[duplicated(dfb),] # creating a table and storing the duplicates in it
duplicates # displaying the table
## [1] Bankrupt.
## [2] ROA.C..before.interest.and.depreciation.before.interest
## [3] ROA.A..before.interest.and...after.tax
## [4] ROA.B..before.interest.and.depreciation.after.tax
## [5] Operating.Gross.Margin
## [6] Realized.Sales.Gross.Margin
## [7] Operating.Profit.Rate
## [8] Pre.tax.net.Interest.Rate
## [9] After.tax.net.Interest.Rate
## [10] Non.industry.income.and.expenditure.revenue
## [11] Continuous.interest.rate..after.tax.
## [12] Operating.Expense.Rate
## [13] Research.and.development.expense.rate
## [14] Cash.flow.rate
## [15] Interest.bearing.debt.interest.rate
## [16] Tax.rate..A.
## [17] Net.Value.Per.Share..B.
## [18] Net.Value.Per.Share..A.
## [19] Net.Value.Per.Share..C.
## [20] Persistent.EPS.in.the.Last.Four.Seasons
## [21] Cash.Flow.Per.Share
## [22] Revenue.Per.Share..Yuan...
## [23] Operating.Profit.Per.Share..Yuan...
## [24] Per.Share.Net.profit.before.tax..Yuan...
## [25] Realized.Sales.Gross.Profit.Growth.Rate
## [26] Operating.Profit.Growth.Rate
## [27] After.tax.Net.Profit.Growth.Rate
## [28] Regular.Net.Profit.Growth.Rate
## [29] Continuous.Net.Profit.Growth.Rate
## [30] Total.Asset.Growth.Rate
## [31] Net.Value.Growth.Rate
## [32] Total.Asset.Return.Growth.Rate.Ratio
## [33] Cash.Reinvestment..
## [34] Current.Ratio
## [35] Quick.Ratio
## [36] Interest.Expense.Ratio
## [37] Total.debt.Total.net.worth
## [38] Debt.ratio..
## [39] Net.worth.Assets
## [40] Long.term.fund.suitability.ratio..A.
## [41] Borrowing.dependency
## [42] Contingent.liabilities.Net.worth
## [43] Operating.profit.Paid.in.capital
## [44] Net.profit.before.tax.Paid.in.capital
## [45] Inventory.and.accounts.receivable.Net.value
## [46] Total.Asset.Turnover
## [47] Accounts.Receivable.Turnover
## [48] Average.Collection.Days
## [49] Inventory.Turnover.Rate..times.
## [50] Fixed.Assets.Turnover.Frequency
## [51] Net.Worth.Turnover.Rate..times.
## [52] Revenue.per.person
## [53] Operating.profit.per.person
## [54] Allocation.rate.per.person
## [55] Working.Capital.to.Total.Assets
## [56] Quick.Assets.Total.Assets
## [57] Current.Assets.Total.Assets
## [58] Cash.Total.Assets
## [59] Quick.Assets.Current.Liability
## [60] Cash.Current.Liability
## [61] Current.Liability.to.Assets
## [62] Operating.Funds.to.Liability
## [63] Inventory.Working.Capital
## [64] Inventory.Current.Liability
## [65] Current.Liabilities.Liability
## [66] Working.Capital.Equity
## [67] Current.Liabilities.Equity
## [68] Long.term.Liability.to.Current.Assets
## [69] Retained.Earnings.to.Total.Assets
## [70] Total.income.Total.expense
## [71] Total.expense.Assets
## [72] Current.Asset.Turnover.Rate
## [73] Quick.Asset.Turnover.Rate
## [74] Working.capitcal.Turnover.Rate
## [75] Cash.Turnover.Rate
## [76] Cash.Flow.to.Sales
## [77] Fixed.Assets.to.Assets
## [78] Current.Liability.to.Liability
## [79] Current.Liability.to.Equity
## [80] Equity.to.Long.term.Liability
## [81] Cash.Flow.to.Total.Assets
## [82] Cash.Flow.to.Liability
## [83] CFO.to.Assets
## [84] Cash.Flow.to.Equity
## [85] Current.Liability.to.Current.Assets
## [86] Liability.Assets.Flag
## [87] Net.Income.to.Total.Assets
## [88] Total.assets.to.GNP.price
## [89] No.credit.Interval
## [90] Gross.Profit.to.Sales
## [91] Net.Income.to.Stockholder.s.Equity
## [92] Liability.to.Equity
## [93] Degree.of.Financial.Leverage..DFL.
## [94] Interest.Coverage.Ratio..Interest.expense.to.EBIT.
## [95] Net.Income.Flag
## [96] Equity.to.Liability
## <0 rows> (or 0-length row.names)
# Using Numeric variables only
numeric_table <- dfb %>%
select_if(is.numeric) %>%
select(ROA.C..before.interest.and.depreciation.before.interest,
ROA.A..before.interest.and...after.tax ,
ROA.B..before.interest.and.depreciation.after.tax ,
Operating.Gross.Margin ,
Realized.Sales.Gross.Margin ,
Operating.Profit.Rate ,
Pre.tax.net.Interest.Rate ,
After.tax.net.Interest.Rate ,
Non.industry.income.and.expenditure.revenue ,
Continuous.interest.rate..after.tax. ,
Operating.Expense.Rate ,
Research.and.development.expense.rate ,
Cash.flow.rate ,
Interest.bearing.debt.interest.rate ,
Tax.rate..A. ,
Net.Value.Per.Share..B. ,
Net.Value.Per.Share..A. ,
Net.Value.Per.Share..C. ,
Persistent.EPS.in.the.Last.Four.Seasons ,
Cash.Flow.Per.Share ,
Revenue.Per.Share..Yuan... ,
Operating.Profit.Per.Share..Yuan... ,
Per.Share.Net.profit.before.tax..Yuan... ,
Realized.Sales.Gross.Profit.Growth.Rate ,
Operating.Profit.Growth.Rate ,
After.tax.Net.Profit.Growth.Rate ,
Regular.Net.Profit.Growth.Rate ,
Continuous.Net.Profit.Growth.Rate ,
Total.Asset.Growth.Rate ,
Net.Value.Growth.Rate ,
Total.Asset.Return.Growth.Rate.Ratio ,
Cash.Reinvestment.. ,
Current.Ratio ,
Quick.Ratio ,
Interest.Expense.Ratio ,
Total.debt.Total.net.worth ,
Debt.ratio.. ,
Net.worth.Assets ,
Long.term.fund.suitability.ratio..A. ,
Borrowing.dependency ,
Contingent.liabilities.Net.worth ,
Operating.profit.Paid.in.capital ,
Net.profit.before.tax.Paid.in.capital ,
Inventory.and.accounts.receivable.Net.value ,
Total.Asset.Turnover ,
Accounts.Receivable.Turnover ,
Average.Collection.Days ,
Inventory.Turnover.Rate..times. ,
Fixed.Assets.Turnover.Frequency ,
Net.Worth.Turnover.Rate..times. ,
Revenue.per.person ,
Operating.profit.per.person ,
Allocation.rate.per.person ,
Working.Capital.to.Total.Assets ,
Quick.Assets.Total.Assets ,
Current.Assets.Total.Assets ,
Cash.Total.Assets ,
Quick.Assets.Current.Liability ,
Cash.Current.Liability ,
Current.Liability.to.Assets ,
Operating.Funds.to.Liability ,
Inventory.Working.Capital ,
Inventory.Current.Liability ,
Current.Liabilities.Liability ,
Working.Capital.Equity ,
Current.Liabilities.Equity ,
Long.term.Liability.to.Current.Assets ,
Retained.Earnings.to.Total.Assets ,
Total.income.Total.expense ,
Total.expense.Assets ,
Current.Asset.Turnover.Rate ,
Quick.Asset.Turnover.Rate ,
Working.capitcal.Turnover.Rate ,
Cash.Turnover.Rate ,
Cash.Flow.to.Sales ,
Fixed.Assets.to.Assets ,
Current.Liability.to.Liability ,
Current.Liability.to.Equity ,
Equity.to.Long.term.Liability ,
Cash.Flow.to.Total.Assets ,
Cash.Flow.to.Liability ,
CFO.to.Assets ,
Cash.Flow.to.Equity ,
Current.Liability.to.Current.Assets ,
Net.Income.to.Total.Assets ,
Total.assets.to.GNP.price ,
No.credit.Interval ,
Gross.Profit.to.Sales ,
Net.Income.to.Stockholder.s.Equity ,
Liability.to.Equity ,
Degree.of.Financial.Leverage..DFL. ,
Interest.Coverage.Ratio..Interest.expense.to.EBIT.,
Equity.to.Liability)
corrMat <- cor(numeric_table)
# highly correlated features
high <- findCorrelation(corrMat, cutoff = 0.75)
# names of highly correlated features
names(numeric_table[, high])
## [1] "ROA.A..before.interest.and...after.tax"
## [2] "ROA.C..before.interest.and.depreciation.before.interest"
## [3] "ROA.B..before.interest.and.depreciation.after.tax"
## [4] "Net.Income.to.Total.Assets"
## [5] "Persistent.EPS.in.the.Last.Four.Seasons"
## [6] "Per.Share.Net.profit.before.tax..Yuan..."
## [7] "Net.profit.before.tax.Paid.in.capital"
## [8] "Operating.Profit.Per.Share..Yuan..."
## [9] "Net.Value.Per.Share..A."
## [10] "Net.Value.Per.Share..B."
## [11] "Debt.ratio.."
## [12] "Net.worth.Assets"
## [13] "Operating.Funds.to.Liability"
## [14] "Liability.to.Equity"
## [15] "Borrowing.dependency"
## [16] "Current.Liabilities.Equity"
## [17] "Gross.Profit.to.Sales"
## [18] "Operating.Gross.Margin"
## [19] "Quick.Assets.Total.Assets"
## [20] "Total.Asset.Turnover"
## [21] "Working.Capital.Equity"
## [22] "Current.Liabilities.Liability"
## [23] "After.tax.net.Interest.Rate"
## [24] "Pre.tax.net.Interest.Rate"
## [25] "Operating.Profit.Rate"
## [26] "Regular.Net.Profit.Growth.Rate"
## [27] "Cash.Flow.to.Sales"
# Calculate the correlations
corr <- cor(numeric_table, use = "complete.obs")
ggcorrplot(round(corr, 2),
type = "full", lab = T)

# data set without highly correlated variables
c2 <- numeric_table[-high]
# Calculate the correlations
corr <- cor(c2, use = "complete.obs")
ggcorrplot(round(corr, 2),
type = "full", lab = T)

# data set with highly correlated variables
c3 <- numeric_table[high]
# Calculate the correlations
corr <- cor(c3, use = "complete.obs")
ggcorrplot(round(corr, 2),
type = "full", lab = T)

# data set without highly correlated variables
c2 <- numeric_table[-high]
# plotting
par(mfrow = c(1, 2))
corrplot(corrMat, order = "hclust")
## Warning in corrplot(corrMat, order = "hclust"): Not been able to calculate
## text margin, please try again with a clean new empty window using {plot.new();
## dev.off()} or reduce tl.cex
corrplot(cor(c2), order = "hclust")
## Warning in corrplot(cor(c2), order = "hclust"): Not been able to calculate
## text margin, please try again with a clean new empty window using {plot.new();
## dev.off()} or reduce tl.cex

R Programming: Principal Component Analysis
# We then pass df to the prcomp(). We also set two arguments, center and scale,
# to be TRUE then preview our object with summary
# ---
#
mtbank.pca <- prcomp(numeric_table, center = TRUE, scale. = TRUE)
summary(mtbank.pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 3.5409 2.59777 2.16272 2.10438 1.9952 1.7171 1.69295
## Proportion of Variance 0.1348 0.07256 0.05029 0.04762 0.0428 0.0317 0.03082
## Cumulative Proportion 0.1348 0.20738 0.25768 0.30529 0.3481 0.3798 0.41062
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 1.65702 1.62128 1.41656 1.37681 1.36540 1.29655 1.22602
## Proportion of Variance 0.02952 0.02826 0.02158 0.02038 0.02005 0.01808 0.01616
## Cumulative Proportion 0.44014 0.46840 0.48998 0.51036 0.53041 0.54849 0.56465
## PC15 PC16 PC17 PC18 PC19 PC20 PC21
## Standard deviation 1.21771 1.1966 1.14606 1.13470 1.11107 1.08757 1.07265
## Proportion of Variance 0.01594 0.0154 0.01412 0.01384 0.01327 0.01272 0.01237
## Cumulative Proportion 0.58059 0.5960 0.61011 0.62396 0.63723 0.64995 0.66232
## PC22 PC23 PC24 PC25 PC26 PC27 PC28
## Standard deviation 1.04668 1.0386 1.02189 1.02085 1.0113 1.00529 1.00420
## Proportion of Variance 0.01178 0.0116 0.01123 0.01121 0.0110 0.01087 0.01084
## Cumulative Proportion 0.67410 0.6857 0.69693 0.70813 0.7191 0.73000 0.74084
## PC29 PC30 PC31 PC32 PC33 PC34 PC35
## Standard deviation 1.00309 0.99257 0.98711 0.98235 0.9786 0.97510 0.96845
## Proportion of Variance 0.01082 0.01059 0.01048 0.01038 0.0103 0.01022 0.01008
## Cumulative Proportion 0.75166 0.76225 0.77273 0.78311 0.7934 0.80363 0.81372
## PC36 PC37 PC38 PC39 PC40 PC41 PC42
## Standard deviation 0.95846 0.95343 0.95042 0.93797 0.92252 0.91968 0.91095
## Proportion of Variance 0.00988 0.00977 0.00971 0.00946 0.00915 0.00909 0.00892
## Cumulative Proportion 0.82359 0.83337 0.84308 0.85254 0.86169 0.87079 0.87971
## PC43 PC44 PC45 PC46 PC47 PC48 PC49
## Standard deviation 0.89541 0.89155 0.86960 0.84662 0.82187 0.7955 0.76661
## Proportion of Variance 0.00862 0.00855 0.00813 0.00771 0.00726 0.0068 0.00632
## Cumulative Proportion 0.88833 0.89688 0.90501 0.91272 0.91998 0.9268 0.93310
## PC50 PC51 PC52 PC53 PC54 PC55 PC56
## Standard deviation 0.73721 0.7347 0.70958 0.69693 0.66567 0.64798 0.63918
## Proportion of Variance 0.00584 0.0058 0.00541 0.00522 0.00476 0.00451 0.00439
## Cumulative Proportion 0.93895 0.9447 0.95016 0.95539 0.96015 0.96467 0.96906
## PC57 PC58 PC59 PC60 PC61 PC62 PC63
## Standard deviation 0.60265 0.5706 0.54086 0.50036 0.46477 0.46329 0.41262
## Proportion of Variance 0.00391 0.0035 0.00315 0.00269 0.00232 0.00231 0.00183
## Cumulative Proportion 0.97296 0.9765 0.97961 0.98230 0.98463 0.98693 0.98876
## PC64 PC65 PC66 PC67 PC68 PC69 PC70
## Standard deviation 0.40777 0.3979 0.37580 0.33551 0.29787 0.28722 0.25632
## Proportion of Variance 0.00179 0.0017 0.00152 0.00121 0.00095 0.00089 0.00071
## Cumulative Proportion 0.99055 0.9923 0.99377 0.99498 0.99594 0.99683 0.99753
## PC71 PC72 PC73 PC74 PC75 PC76 PC77
## Standard deviation 0.2353 0.1938 0.17066 0.15668 0.14825 0.13899 0.12427
## Proportion of Variance 0.0006 0.0004 0.00031 0.00026 0.00024 0.00021 0.00017
## Cumulative Proportion 0.9981 0.9985 0.99884 0.99911 0.99934 0.99955 0.99972
## PC78 PC79 PC80 PC81 PC82 PC83 PC84
## Standard deviation 0.09817 0.07504 0.06138 0.05158 0.04032 0.03030 0.02794
## Proportion of Variance 0.00010 0.00006 0.00004 0.00003 0.00002 0.00001 0.00001
## Cumulative Proportion 0.99982 0.99988 0.99992 0.99995 0.99997 0.99998 0.99999
## PC85 PC86 PC87 PC88 PC89 PC90
## Standard deviation 0.02542 0.01942 0.01219 8.611e-05 3.248e-06 1.413e-09
## Proportion of Variance 0.00001 0.00000 0.00000 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion 0.99999 1.00000 1.00000 1.000e+00 1.000e+00 1.000e+00
## PC91 PC92 PC93
## Standard deviation 3.504e-15 4.617e-16 2.938e-16
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion 1.000e+00 1.000e+00 1.000e+00
# As a result we obtain 93 principal components,
# each which explain a percentate of the total variation of the dataset
# PC1 explains 13.48% of the total variance
# of the information in the dataset (93 variables) can be encapsulated
# by just that one Principal Component. PC2 explains 7.25% of the variance. etc
# Calling str() to have a look at your PCA object
# ---
#
str(mtbank.pca)
## List of 5
## $ sdev : num [1:93] 3.54 2.6 2.16 2.1 2 ...
## $ rotation: num [1:93, 1:93] 0.239 0.24 0.237 0.121 0.121 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : chr [1:93] "ROA.C..before.interest.and.depreciation.before.interest" "ROA.A..before.interest.and...after.tax" "ROA.B..before.interest.and.depreciation.after.tax" "Operating.Gross.Margin" ...
## .. ..$ : chr [1:93] "PC1" "PC2" "PC3" "PC4" ...
## $ center : Named num [1:93] 0.505 0.559 0.554 0.608 0.608 ...
## ..- attr(*, "names")= chr [1:93] "ROA.C..before.interest.and.depreciation.before.interest" "ROA.A..before.interest.and...after.tax" "ROA.B..before.interest.and.depreciation.after.tax" "Operating.Gross.Margin" ...
## $ scale : Named num [1:93] 0.0607 0.0656 0.0616 0.0169 0.0169 ...
## ..- attr(*, "names")= chr [1:93] "ROA.C..before.interest.and.depreciation.before.interest" "ROA.A..before.interest.and...after.tax" "ROA.B..before.interest.and.depreciation.after.tax" "Operating.Gross.Margin" ...
## $ x : num [1:6819, 1:93] -7.34 -2.7 -4.31 -5.83 -2.34 ...
## ..- attr(*, "dimnames")=List of 2
## .. ..$ : NULL
## .. ..$ : chr [1:93] "PC1" "PC2" "PC3" "PC4" ...
## - attr(*, "class")= chr "prcomp"
# Here we note that our pca object: The center point ($center), scaling ($scale),
# standard deviation(sdev) of each principal component.
# The relationship (correlation or anticorrelation, etc)
# between the initial variables and the principal components ($rotation).
# The values of each sample in terms of the principal components ($x)
# Then Loading our ggbiplot library
#
library(ggbiplot)
## Loading required package: plyr
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
##
## Attaching package: 'plyr'
## The following objects are masked from 'package:Hmisc':
##
## is.discrete, summarize
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## Loading required package: scales
##
## Attaching package: 'scales'
## The following objects are masked from 'package:psych':
##
## alpha, rescale
## Loading required package: grid
ggbiplot(mtbank.pca)

# From the graph we will see that the variables hp, cyl and disp contribute to PC1,
# with higher values in those variables moving the samples to the right on the plot.
# Adding more detail to the plot, we provide arguments rownames as labels
#
ggbiplot(mtbank.pca, labels=rownames(mtbank.pca), obs.scale = 1, var.scale = 1)
