# Wolfram Mathematica

## Federal Deposit Insurance Corporation Institutional Data

The Federal Deposit Insurance Corporation (FDIC) is an independent US government agency charged with insuring deposits in US financial institutions. Presently, deposits in member institutions are insured up to \$250,000. Here, the holdings, size distribution, and geographic dispersal of member institutions are explored.

First, load an entity store of FDIC data as a ResourceObject.

In:= ```fdic = ResourceData[ ResourceObject[ Association[ "Name" -> "FDIC Institution EntityStore", "UUID" -> "6f5d37d4-1406-483c-b67c-f58d903d16b1", "ResourceType" -> "DataResource", "Version" -> "1.0.0", "Description" -> "A Wolfram Language EntityStore with selected \ data on FDIC insured institutions", "ContentSize" -> Quantity[0, "Bytes"], "ContentElements" -> {"EntityStore"}]]]```
Out= Register the store for this session.

In:= `PrependTo[\$EntityStores, fdic];`

Count the number of FDIC institutions.

In:= `Length[ents = EntityList["FDICInstitution"]]`
Out= List some of the available properties of the entity store.

In:= `EntityProperties["FDICInstitution"] // Sort // Take[#, 20] &`
Out= Visualize the geographic locations of FDIC-affiliated banks.

In:= `GeoListPlot[EntityList["FDICInstitution"], PlotMarkers -> "\$"]`
Out= Display the rank distribution in a log-log plot.

In:= ```ListLogLogPlot[ Reverse@Sort[EntityValue["FDICInstitution", "TotalAssets"]], AxesLabel -> Automatic, PlotStyle -> PointSize[Medium]]```
Out= Plot employees vs. assets.

In:= ```empVsAssets = EntityValue[ "FDICInstitution", {"TotalEmployeeNumber", "TotalAssets"}];```
In:= `ListLogLogPlot[empVsAssets, AxesLabel -> Automatic]`
Out= Label the six largest institutions.

show complete Wolfram Language input
In:= ```ListLogLogPlot[ Callout[{#2, #3}, #1] & @@@ EntityValue[ EntityList[ EntityClass["FDICInstitution", "TotalAssets" -> TakeLargest]], {"Label", "TotalEmployeeNumber", "TotalAssets"}], PlotRangePadding -> Scaled[0.25], AxesLabel -> {"employee count", "assets"}]```
Out= Plot liabilities vs. assets.

In:= ```assetsVsLiability = EntityValue["FDICInstitution", {"TotalAssets", "TotalLiabilities"}];```
In:= `ListLogLogPlot[assetsVsLiability, AxesLabel -> Automatic]`
Out= Plot net loans and leases vs. total deposits together with a fit.

In:= ```loanVsDeposit = EntityValue[ "FDICInstitution", {"NetLoansAndLeases", "TotalDeposits"}];```
In:= ```nmf = NonlinearModelFit[ Select[QuantityMagnitude /@ loanVsDeposit, Min[#] > 0 &], c + a x^\[Alpha], {a, \[Alpha], c}, x]```
Out= In:= ```Show[ListPlot[loanVsDeposit], Plot[Evaluate[Normal[nmf]], {x, 0, 10^10}, PlotStyle -> Red, AxesLabel -> Automatic]]```
Out= Compare Tier 1 (secure) and Tier 2 capital (riskier) to total assets.

In:= ```{tierOneCapitalToAssets, tierTwoCapitalToAssetsCapitalToAssets} = (Divide @@@ EntityValue[ "FDICInstitution", {#, "TotalAssets"}]) & /@ {"TierOneCapital", "TierTwoRiskBasedCapital"};```
In:= ```Histogram[{tierOneCapitalToAssets, tierTwoCapitalToAssetsCapitalToAssets}, {0, 0.3, 0.01}, ChartLegends -> {"Tier 1", "Tier 2"}, PlotLabel -> "Capital/Assets Ratio"]```
Out= Retrieve the distribution of assets as an "EntityAssociation".

In:= ```dat = EntityValue["FDICInstitution", "TotalAssets", "EntityAssociation"];```

Plot the distribution of assets.

In:= `Histogram[dat, "Log", AxesLabel -> Automatic]`
Out= Display locations of banks with assets more than 5 billion and 300 billion dollars.

In:= ```GeoListPlot[ Keys[Select[dat, GreaterThan[Quantity[#, "USDollars"]]]]] & /@ {5*^9, 300*^9}```
Out= Graphically discover that the top 10 banks hold more assets than the remaining 6121 combined.

show complete Wolfram Language input
In:= ```With[{atas = QuantityMagnitude[ EntityValue["FDICInstitution", EntityProperty["FDICInstitution", "AverageTotalAssets"]]]}, ListLogLogPlot[100 Accumulate[Reverse[Sort[atas]]]/Total[atas], PlotRange -> All, GridLines -> Automatic, PlotStyle -> PointSize[Medium], AxesLabel -> {None, Quantity[None, "Percent"]}]]```
Out= Find banks with the highest 1% of deposits.

In:= ```dat1 = EntityValue["FDICInstitution", "TotalDeposits", "EntityAssociation"];```
In:= ```{bottom1percent, top1percent} = Quantile[values = Values[dat1], {0.01, 0.99}]```
Out= Plot them on a map.

In:= `GeoListPlot[Keys[Select[dat1, GreaterThan[top1percent]]]]`
Out= The distribution of the assets per city fulfills Benford's law to a remarkable degree.

show complete Wolfram Language input
In:= ```\$percity = Reverse[SortBy[{#[[1, 1]], Total[#[[All, -1]]]} & /@ Normal[Normal[ DeleteMissing[ SortBy[GroupBy[ EntityValue["FDICInstitution", {"City", "TotalAssets"}], First] , Length], 1, 3]][[All, -1]]], Last]];```
In:= ```ListPlot[{Tally[ IntegerDigits[Round[QuantityMagnitude[#2]]][] & @@@ \$percity], Table[{d, Length[\$percity] Log10[1 + 1/d]}, {d, 1, 9}]}, PlotRange -> All, Filling -> Axis, PlotLegends -> {"total assets", "Benford"}]```
Out= Show banks with the greatest financial leverage.

show complete Wolfram Language input
In:= ```dataSet3 = Append[#, <| "FinancialLeverage" -> N[#TotalLiabilities/#TotalEquity]|>] & /@ EntityValue[ "FDICInstitution", {"Position", "TotalLiabilities", "TotalEquity"}, "Dataset"];```
In:= `dataSet3[TakeLargestBy["FinancialLeverage", 10]]`
Out= Plot the distribution of the financial leverages.

In:= ```Histogram[dataSet3[All, "FinancialLeverage"], {0, 20, 0.5}, PlotLabel -> "FDIC banks Financial Leverage distribution"]```
Out= Graphically explore the relationship among assets, long-term assets, and liabilities.

show complete Wolfram Language input
In:= ```props = {EntityProperty["FDICInstitution", "TotalAssets"], EntityProperty["FDICInstitution", "LongTermAssets"], EntityProperty["FDICInstitution", "TotalLiabilities"]}; data = Select[ N@QuantityMagnitude@ DeleteMissing[ EntityValue["FDICInstitution", Append[props, "Entity"]], 1, 2], Min[Most[#]] > 0 &];```
In:= ```data2 = Select[{#1/#2, #1/#3, #4} & @@@ data, Between[{0, 15}][#[]] && Between[{1, 1.4}][#[]] &];```
In:= `sdk = SmoothKernelDistribution[Most /@ data2];`
In:= ```label[{a_, b_, c_, _[d_]}] := Column[{d, Grid[Transpose[{props, Quantity[NumberForm[#, 4], "USDollars"] & /@ {a, b, c}}], Dividers -> Center]}]```
In:= ```ContourPlot[PDF[sdk, {x, y}], {x, 0, 15}, {y, 1, 1.4}, PlotRange -> All, Contours -> 50, ContourStyle -> None, ColorFunction -> (Lighter[ColorData["AvocadoColors"][#], 0.5] &), FrameLabel -> {"total asssets"/"long term assets", "total asssets"/"total liabilities"}, Epilog -> ({ColorData["DarkRainbow"][(Log10[#1] - 7)/5], PointSize[0.00125], Point[{#1/#2, #1/#3}]} & @@@ data)]```
Out= 