Wolfram 语言

更丰富的知识库访问

美国联邦存款保险公司组织数据

美国联邦存款保险公司(FDIC)是一个管理美国金融机构存款的独立美国政府机构. 目前,加盟机构的存款有最高 $250,000 的保险. 在此,对加盟机构的资产、大小分布和地理分散进行了研究.

首先, 加载作为 ResourceObject 的 FDIC 数据实体库.

In[1]:=
Click for copyable input
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[1]=

注册该部分数据库.

In[2]:=
Click for copyable input
PrependTo[$EntityStores, fdic];

计算 FDIC 机构数目.

In[3]:=
Click for copyable input
Length[ents = EntityList["FDICInstitution"]]
Out[3]=

列举实体库中可用的属性.

In[4]:=
Click for copyable input
EntityProperties["FDICInstitution"] // Sort // Take[#, 20] &
Out[4]=

可视化 FDIC 相关银行的地理位置.

In[5]:=
Click for copyable input
GeoListPlot[EntityList["FDICInstitution"], PlotMarkers -> "$"]
Out[5]=

在对数-对数图中显示排名分布.

In[6]:=
Click for copyable input
ListLogLogPlot[ Reverse@Sort[EntityValue["FDICInstitution", "TotalAssets"]], AxesLabel -> Automatic, PlotStyle -> PointSize[Medium]]
Out[6]=

职员与资产绘图.

In[7]:=
Click for copyable input
empVsAssets = EntityValue[ "FDICInstitution", {"TotalEmployeeNumber", "TotalAssets"}];
In[8]:=
Click for copyable input
ListLogLogPlot[empVsAssets, AxesLabel -> Automatic]
Out[8]=

标注最大的六个机构.

显示完整的 Wolfram 语言输入
In[9]:=
Click for copyable input
ListLogLogPlot[ Callout[{#2, #3}, #1] & @@@ EntityValue[ EntityList[ EntityClass["FDICInstitution", "TotalAssets" -> TakeLargest[6]]], {"Label", "TotalEmployeeNumber", "TotalAssets"}], PlotRangePadding -> Scaled[0.25], AxesLabel -> {"employee count", "assets"}]
Out[9]=

债务与资产绘图.

In[10]:=
Click for copyable input
assetsVsLiability = EntityValue["FDICInstitution", {"TotalAssets", "TotalLiabilities"}];
In[11]:=
Click for copyable input
ListLogLogPlot[assetsVsLiability, AxesLabel -> Automatic]
Out[11]=

将贷款净额和租赁相对各项存款连同一同拟合绘图.

In[12]:=
Click for copyable input
loanVsDeposit = EntityValue[ "FDICInstitution", {"NetLoansAndLeases", "TotalDeposits"}];
In[13]:=
Click for copyable input
nmf = NonlinearModelFit[ Select[QuantityMagnitude /@ loanVsDeposit, Min[#] > 0 &], c + a x^\[Alpha], {a, \[Alpha], c}, x]
Out[13]=
In[14]:=
Click for copyable input
Show[ListPlot[loanVsDeposit], Plot[Evaluate[Normal[nmf]], {x, 0, 10^10}, PlotStyle -> Red, AxesLabel -> Automatic]]
Out[14]=

将等级 1(安全)和等级 2(高风险)资产与总资产相对比.

In[15]:=
Click for copyable input
{tierOneCapitalToAssets, tierTwoCapitalToAssetsCapitalToAssets} = (Divide @@@ EntityValue[ "FDICInstitution", {#, "TotalAssets"}]) & /@ {"TierOneCapital", "TierTwoRiskBasedCapital"};
In[16]:=
Click for copyable input
Histogram[{tierOneCapitalToAssets, tierTwoCapitalToAssetsCapitalToAssets}, {0, 0.3, 0.01}, ChartLegends -> {"Tier 1", "Tier 2"}, PlotLabel -> "Capital/Assets Ratio"]
Out[16]=

提取资产分布作为 "EntityAssociation".

In[17]:=
Click for copyable input
dat = EntityValue["FDICInstitution", "TotalAssets", "EntityAssociation"];

资产分布的绘图.

In[18]:=
Click for copyable input
Histogram[dat, "Log", AxesLabel -> Automatic]
Out[18]=

显示资产超过 50 到 3000 亿美金的银行地址.

In[19]:=
Click for copyable input
GeoListPlot[ Keys[Select[dat, GreaterThan[Quantity[#, "USDollars"]]]]] & /@ {5*^9, 300*^9}
Out[19]=

用图形显示所持资产超过其余 6121 家银行总和的前 10 家银行.

显示完整的 Wolfram 语言输入
In[20]:=
Click for copyable input
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[20]=

找出拥有最高存储的 1% 的银行.

In[21]:=
Click for copyable input
dat1 = EntityValue["FDICInstitution", "TotalDeposits", "EntityAssociation"];
In[22]:=
Click for copyable input
{bottom1percent, top1percent} = Quantile[values = Values[dat1], {0.01, 0.99}]
Out[22]=

将其绘制在地图上.

In[23]:=
Click for copyable input
GeoListPlot[Keys[Select[dat1, GreaterThan[top1percent]]]]
Out[23]=

每个城市的资产分布和本福特(Benford)定律有着显著程度的一致.

显示完整的 Wolfram 语言输入
In[24]:=
Click for copyable input
$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[25]:=
Click for copyable input
ListPlot[{Tally[ IntegerDigits[Round[QuantityMagnitude[#2]]][[1]] & @@@ $percity], Table[{d, Length[$percity] Log10[1 + 1/d]}, {d, 1, 9}]}, PlotRange -> All, Filling -> Axis, PlotLegends -> {"total assets", "Benford"}]
Out[25]=

显示拥有最高财务杠杆的银行.

显示完整的 Wolfram 语言输入
In[26]:=
Click for copyable input
dataSet3 = Append[#, <| "FinancialLeverage" -> N[#TotalLiabilities/#TotalEquity]|>] & /@ EntityValue[ "FDICInstitution", {"Position", "TotalLiabilities", "TotalEquity"}, "Dataset"];
In[27]:=
Click for copyable input
dataSet3[TakeLargestBy["FinancialLeverage", 10]]
Out[27]=

绘制财务杠杆分布图.

In[28]:=
Click for copyable input
Histogram[dataSet3[All, "FinancialLeverage"], {0, 20, 0.5}, PlotLabel -> "FDIC banks Financial Leverage distribution"]
Out[28]=

通过图形研究资产、长期资产和负债的关系.

显示完整的 Wolfram 语言输入
In[29]:=
Click for copyable input
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[30]:=
Click for copyable input
data2 = Select[{#1/#2, #1/#3, #4} & @@@ data, Between[{0, 15}][#[[1]]] && Between[{1, 1.4}][#[[2]]] &];
In[31]:=
Click for copyable input
sdk = SmoothKernelDistribution[Most /@ data2];
In[32]:=
Click for copyable input
label[{a_, b_, c_, _[d_]}] := Column[{d, Grid[Transpose[{props, Quantity[NumberForm[#, 4], "USDollars"] & /@ {a, b, c}}], Dividers -> Center]}]
In[33]:=
Click for copyable input
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[33]=

相关范例

de en es fr ja ko pt-br ru