Yield curve animation
​by R. H. Rimmer, 27 March 2023

Yield curve history from the last time the FOMC actually subdued inflation. The animation shows how the inverted yield curve in 1981 finally resolved.
Download data from FRED and set up database.
In[]:=
yieldCurve0=Import["https://www.federalreserve.gov/datadownload/Output.aspx?rel=H15&series=bf17364827e38702b42a58cf8eaa3f78&lastobs=&from=&to=&filetype=csv&label=include&layout=seriescolumn&type=package","CSV"];​​header=Join[{"date"},StringSplit[Rest[yieldCurve0[[1]]]][[All,8]]]​​yieldCurve={DateObject[#1,"Day"],#2,#3,#4,#5,#6,#7,#8,#9,#10,#11,#12}&@@@yieldCurve0[[7;;]];​​yieldCurveDS=AssociationThread[header,#]&/@yieldCurve/.""->Missing[]//Dataset;​​(*1980sdataremovedayswithnodata--ND*)​​yc80DS=Select[yieldCurveDS,1980<=DateValue[#date,"Year"]<1990&&#"10-year"!="ND"&];
Out[]=
{date,1-month,3-month,6-month,1-year,2-year,3-year,5-year,7-year,10-year,20-year,30-year}
In[]:=
reversionDS=Select[yc80DS,DateObject[{1981},"Day"]<#date<DateObject[{1983},"Day"]&]
Out[]=
date
1-month
3-month
6-month
1-year
2-year
3-year
5-year
7-year
10-year
Fri 2 Jan
1981
—
—
—
14.06
13.1
12.83
12.61
12.5
12.42
Mon 5 Jan
1981
—
—
—
13.09
12.28
12.28
12.29
12.21
12.15
Tue 6 Jan
1981
—
—
—
13.23
12.42
12.31
12.21
12.14
12.11
Wed 7 Jan
1981
—
—
—
13.88
12.92
12.78
12.61
12.47
12.38
Thu 8 Jan
1981
—
—
—
13.96
13.09
12.95
12.68
12.5
12.35
Fri 9 Jan
1981
—
—
—
14.24
13.53
13.28
12.88
12.69
12.57
Mon 12 Jan
1981
—
—
—
14.06
13.17
12.94
12.71
12.6
12.45
Tue 13 Jan
1981
—
—
—
14.04
13.3
12.97
12.68
12.62
12.53
Wed 14 Jan
1981
—
—
—
13.75
12.95
12.75
12.61
12.58
12.53
Thu 15 Jan
1981
—
—
—
13.86
13.25
13.02
12.77
12.7
12.62
Fri 16 Jan
1981
—
—
—
13.84
13.08
12.85
12.66
12.61
12.53
Mon 19 Jan
1981
—
—
—
14.43
13.62
13.25
12.92
12.79
12.64
Tue 20 Jan
1981
—
—
—
14.2
13.48
13.1
12.77
12.66
12.5
Wed 21 Jan
1981
—
—
—
14.57
13.79
13.38
13.08
12.9
12.77
Thu 22 Jan
1981
—
—
—
14.69
13.83
13.47
13.16
12.96
12.87
Fri 23 Jan
1981
—
—
—
14.69
13.74
13.42
13.1
12.93
12.84
Mon 26 Jan
1981
—
—
—
14.29
13.4
13.09
12.89
12.75
12.7
Tue 27 Jan
1981
—
—
—
14.34
13.4
13.14
12.92
12.82
12.73
Wed 28 Jan
1981
—
—
—
14.34
13.48
13.19
12.94
12.82
12.77
Thu 29 Jan
1981
—
—
—
14.22
13.42
13.16
12.89
12.8
12.8
rows 1–20 of 498
columns 1–10 of 12
In[]:=
times=
1
12
,
1
4
,
1
2
,1,2,3,5,7,10,20,30;
In[]:=
rycData={#[[1]],Select[Transpose[{times,Rest[#]}],#[[2]]=!=Missing[]&]}&/@Values[Normal[reversionDS]];
In[]:=
plotList=ListPlot[rycData[[#]][[2]],Frame->True,FrameLabel->{"Years to Maturity","Yield Percent"},GridLines->Automatic,PlotRange->{All,{8,18}},PlotLabel->"Yield Curve\n"<>DateString[rycData[[#]][[1]]]]&/@Range[Length[rycData]];
The animation starts with an inverted yield curve. There was a deep recession in 1982, but the Fed held rates up until the summer of 1982 despite the recession. The yield curve began to show long rates higher than short term rates in July 1982.
In[]:=
ListAnimate[plotList,6]
Out[]=