Skip to main content
Table of Contents
< All Topics
Print

Step 1 – Converting SPSS formatted data

Reading data from the Wiley Web Site

The data from the book is available in SPSS .sav format and available fror download from the Wiley site https://www.wiley.com//legacy/wileychi/delaurentis/

In this page, the left “Supplementary material” list element points to a page asking for the term located on Page 106 of the book as loading keyword Two data sets are proposed: SAS and SPSS-PASW. We have used the second one: https://www.wiley.com//legacy/wileychi/delaurentis/supp/SPSS-PASW.zip

The package “haven” has been loaded from the USA-CA berkeley CRAN Repository

The RPackage Haven enables to read the SPSS format https://cran.r-project.org/web/packages/haven/index.html

Specifying your project directory (Replace by the location of your own project directory)

projdir = “C:/RExercise/”

Reading the full dataset and saving it to .csv

library(haven)
wcs1org <- read_sav(sprintf(“%sW_CS_1_OriginalDataSet.sav”, projdir))
write.csv(wcs1org, file = sprintf(“%sW_CS_1_OriginalDataSet.csv”, projdir))

Reading the “training” dataset and saving it to .csv (page 116)

wcs1train <- read_sav(“C:/Projets_En_Cours/AI_MTPL/UCI_Internal_Ratings/SPSS-PASW/W_CS_1_AnalysisSampleDataSet.sav”)
write.csv(wcs1train, file = “C:/Projets_En_Cours/AI_MTPL/UCI_Internal_Ratings/SPSS-PASW/W_CS_1_AnalysisSampleDataSet.csv”)

Reading the “cleaned” training data set and saving it to .csv (page 129)

wcs2train <- read_sav(“C:/Projets_En_Cours/AI_MTPL/UCI_Internal_Ratings/SPSS-PASW/W_CS_1_AnalysisSampleDataSet_2.sav”)
write.csv(wcs2train, file = “C:/Projets_En_Cours/AI_MTPL/UCI_Internal_Ratings/SPSS-PASW/W_CS_1_AnalysisSampleDataSet_2.csv”)

The .csv file is modified using a standard text editor so that the first column named INDEX (generated by default by R) is removed, short names are assigned to the variables and “qualitative” variables values are turned into text by putting them between quotes:

  • BADGOOD variable values are transformed and put into “quoted” text: 0 -> “Good” and 1 -> “Bad”
  • STATUS variable values are transformed and put into “quoted” text: 3 -> “Performing”, 2 -> “Substandard”, 1 -> “Doubtful”, 0 -> “Unknown”
  • SECTOR The file is then re-imported

NOTE : The double-quote ” being a reserved character in Excel Formulas, one should replce it by an “escape” expression of the form : =””””&E2&””””

Furthermore, the separator in the .csv file being “;” this should be explicitely specified in the read.csv R function

wcs2train <- read.csv(“C:/Projets_En_Cours/AI_MTPL/UCI_Internal_Ratings/SPSS-PASW/W_CS_1_AnalysisSampleDataSet_2B.csv”, header=TRUE, sep=”;”)

Finally, list the name and type of all variables for checking:

sapply(wcs2train, class)

Double check the content of the BADGOOD field (of type “factor” in R) in order to count the number of companies being Active (labelled “bad”) and those being Insolvent (labelled “bad”)

summary(wcs2train$BADGOOD)

Here, the R ouput is:
“Bad” “Good”
51 1221

NOTE: All resulting files are available for download at : https://github.com/MoiraCorp/DLMM-IRating-in-R/tree/main/steps/step1/assets

List of ratios used in the DLMM model

Variable (Short)Variable Name in TextDescription
ROEROERatio Net Profit/Equity
EBITDAONEBITDAonSALESRatio EBITDA/Sales [%]
ROIROIRatio EBIT/Operating Assets [%]
ROAROARatio Current Income/Total Assets [%]
V89AEBITDAonVPRatio EBITDA/Value of Production
ROSROSRatio EBIT/Sales [%]
ASSETSTUASSETS_TURNOVERRatio Total Assets/Turnover
INVENTORINVENTORY_TURNOVERRatio Inventory/Turnover
RECEIVABReceivables_TurnoverRatio Trade Receivables at year end/Turnover
V94ARECEIVABLES_PERIODRatio Trade Receivables/Daily Sales
V95AINVENTORY_PERIODRatio Inventory/Daily Sales
PAYABLESPAYABLES_PERIODRatio Trade Payables/Daily Purchases
COMMERCICOMMERCIAL_WC_PERIODRatio (Trade Receivables + Inventory – Trade Payables)/Daily Sales
IEONEBITIEonEBITDARatio Interest Expenses/EBITDA [%]
NIEONEBINIEonEBITDARatio Net Interest Expenses/EBITDA [%]
IEONLIABIEonLIABLITIESRatio Interest Expenses/Liabilities [%]
IEONFINAIEonFINANCIAL_DEBTSRatio Interest Expenses/Financial Debts [%]
EXTRICExtr_I_C_onCurrent_IncomeRatio Gross of Tax Profit/Income from ordinary (current) activities
TAXESONGTaxesOnGross_ProfitRatio Taxes/Gross of Tax Profit
INTANGIBINTANGIBLESonTARatio Intangibles/Total Assets [%]
TRADERETRADE_RECEIVABLESonTARatio Trade Receivables/Total Assets [%]
V110AINVENTORIESonTARatio Inventories/Total Assets [%]
EQUITYONEQUITYonPERMANENT_CAPITALRatio Equity/Permanent Capital [%]
TRADEPATRADE_PAYABLESonTLRatio Trade Payables/Total Liabilities [%]
DEBTEQUDEBT_EQUITY_RATIORatio Debt/Equity [%]
CURRENTCURRENT_RATIORatio Current Assets/Current Liabilities
QUICKRAQUICK_RATIORatio (Current Assets – Inventories)/Current Liabilities
SALESONVSALESonVPRatio Sales/Value of Production [%]
SALESMINSALESminusVConEBITRatio (Sales –Variable Costs)/EBIT
ROAMINUSROAminusIEonTLROA minus Ratio Interest Expenses/Total Liabilities
EBITDAIEEBITDAonIERatio EBITDA/Interest Expenses
EQUILIABLEQUITYonLIABILITIESRatio Equity/Liabilities
DEBTEQUTRDebtEquityTrRatio Interest-bearing Financial Debt/Equity
ROETRROETrRatio Net Profit/Total Stockholder’s Equity

List of financial accounting terms used in the DLMM data set

Variable (Short)Description
INDEXIndex in file
BORCODEBorrower’s code (assigned by the bank)
STATUSBorrower’s classification in regulatory grades (3 = performing, 2 = substandard, 1 = doubtful, 0 = unknown)
SUBSECTORNumerical code for business subs-sector
SECTORNumerical code for business sector
INTASSETSIntangible assets, net
GRFIXASSTTangible fixed assets, gross
ACCDEPRECAccumulated depreciation and impairment
NETFIXASSTTangible fixed assets, net
ADVTAINPROAdvances and tangible assets in progress
NETINVESTInvestments, net
SECLOANSSecurities and loans
NCROCNon-current receivables and other credits
NCFINASSTNon-current financial assets
TOTNCASSTTotal non-current assets
ADVANCESAdvances
RMINVENTRaw materials inventories, net
WIPINVENTWork in progress and finished goods, net
NETINVENTIventories, net
TRRECEIVAccounts and notes receivables
STLOANSShort term loans
OSTCREDITSOther short term credits
OCASSTSOther current assets (prepaid expenses,…)
CURSECCurrent securities
CASHCash and cash equivalents
CASHSTINVCash and s. t. investments
TOTCURASSTTotal current assets
TOTASSTTotal assets
EQUITYTotal stockholder’s equity
PROVCHARGProvisions for liabilities and charges
EMPLBENEFEmployee benefits
TOTPRVSNSProvisions
BONDSBonds
BORFROMSHBorrowings from shareholders falling due beyond 1 year
MLTBORBANKBorrowings from banks falling due beyond 1 year
MLTBOROTBorrowings from others falling due beyond 1 year
MLTTROTLIABTrade and other liabilities falling due beyond 1 year
MLTDEBTSMedium and long term debts
TOTPERMCAPTotal permanent capital
STBORBANKBank loans payables
OTSTLOANSOther loans payables
STFINDEBTShort term financial debt
TRPAYABLESTrade payables
ADPAYMENTSAdvance payments from customers
TOTSTPAYABTotal trade payables (short term)
TAXPAYABTax payables (short term)
OTSTPAYABOther payables (short term)
OTSTLIABOther liabalities (short term)
TOTCURLIABTotal current liabilities
TOTEQU_LIABTotal stockholder’s equity & liabilities
SALESNet sales
CHFGWIPINVChange in stocks of finished goods and w.i.p.
CAPITCOSTSCapitalized product development costs
GRANTSGrants for the financ.year & other sales (engineering)
VPValue of production
PURCHPurchase of raw materials and consumables
CHRMINVChange in stocks of raw mat. & consumables
CSTSERVCosts for services
AVAdded value
STAFFCOSTStaff costs
EBITDAGross operating income
DEPRDepreciation of tangible fixed assets
WRDWWCWrite-downs on working capital
PROVProvisions for liabilities and charges
EBITNet operating income
ONONFRCOther (non-operating non-financial) revenues & charges
INTCAPITALCapitalization of intangible assets
DEPRCAPITDepreciation of intangible assets
EBFPLIncome on ord. act. before financial P&L
FININCOMFinancial income
FINLOSWDLosses on and write-downs of financ.assets
EBIIncome of ord. act. before interest exp.
IEInterest and other financial expenses
EOOAIncome on ordinary activities
GLNFAGains (losses) on disposal of non-financ.assets
RWDNFAReduction in write-downs & (W-D) on non-fin. assets
EXINCCHExtraordinary income and (charges
GPROFGross profit before tax profit
CTAXCorporate income taxes
OTAXOther taxes
ADNPROFAdjusted net (of tax) profit
ACCDEPRAccelerated depreciation
OTAXITEMOther items due to tax regulations (+ -)
PROUSRESProvisions (-) to and (+) uses of reserves
NPROFProfit (loss) for the financial year