Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 580

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 583

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 586

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 589

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php on line 592

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673

Warning: Cannot modify header information - headers already sent by (output started at /home/calcul9/public_html/wp-content/themes/suffusion/functions/media.php:580) in /home/calcul9/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1673
{"id":1175,"date":"2011-01-24T17:19:49","date_gmt":"2011-01-24T23:19:49","guid":{"rendered":"http:\/\/www.calculatinginvestor.com\/"},"modified":"2011-03-12T08:58:35","modified_gmt":"2011-03-12T14:58:35","slug":"calculating-breakeven-inflation","status":"publish","type":"page","link":"http:\/\/www.calculatinginvestor.com\/octave-code\/calculating-breakeven-inflation\/","title":{"rendered":"Calculating the Breakeven Inflation Rate from the Yield Curve"},"content":{"rendered":"

Note:<\/strong> This page contains links to the data sources and the Octave source\u00a0code which I used to generate the plots in my \u00a0Inflation Expectations and the Breakeven Rate of Inflation<\/a> post. <\/em><\/p>\n

Data: <\/strong><\/p>\n

The first graph plotted in my inflation expectations post <\/a>was created using the FRED database at the St. Louis Fed website<\/a>.\u00a0 This site is an excellent resource for a variety of macroeconomic information and signing up for an account is free.<\/p>\n

The data used\u00a0to\u00a0create the 30-year\u00a0yield curves and breakeven inflation rates\u00a0is from the Treasury department website<\/a>.\u00a0 The “Daily Treasury Yield Curve Rates” and the “Daily Treasury Real Yield Curve Rates” are copied to text files which are read by the Octave script.\u00a0 The script uses the last line of the file, but it can easily be modified to plot data from other dates.<\/p>\n

Code:<\/strong><\/p>\n

The Octave code used to generate the yield curve and expected inflation plots is shown here:<\/p>\n

\r\nclear all;\r\nclose all;\r\n\r\n% Read in data from text files.  Data source is U.S. Treasury website\r\nnomdata = dlmread('treasuryyieldcurve.txt',' ');\r\nrealdata = dlmread('realyieldcurve.txt',' ');\r\n\r\n% Read yields from last line of each file\r\ny_treas = nomdata(end,2:12).\/100;\r\ny_real = realdata(end,2:6).\/100;\r\n\r\n% Maturities for each rate\r\nx_treas = [1\/12 0.25 0.5 1 2 3 5 7 10 20 30];\r\nx_real = [5 7 10 20 30];\r\n\r\n% Interpolate Values\r\nx1 = (1:60)\/2;\r\ny1 = interp1(x_treas,y_treas,x1,'spline');\r\ny2 = interp1(x_real,y_real,x1,'spline');\r\n\r\n% Extrapolate curve for difference and extend\r\ny1y2 = interp1(x1(10:60),(y1(10:60)-y2(10:60)),x1,'spline','extrap')\r\ny2 = [(y1(1:9)-y1y2(1:9)) y2(10:60)]\r\n\r\n% Compare fit to actual data\r\nfigure(1)\r\nplot(x1(8:60),100*y1(8:60),'linewidth',2,x1(8:60),100*y2(8:60),'linewidth',2,x1(8:60),100*(y1(8:60)-y2(8:60)),'linewidth',2)\r\npause(5)\r\ntitle('Constant Maturity Yields on Coupon Paying Bonds','fontsize',20)\r\nxlabel('Time to Maturity','fontsize',16)\r\nylabel('Constant Maturity Yield (%)','fontsize',16)\r\nlegend('Treasury','TIPS','Breakeven Inflation','location','northwest')\r\n\r\n% Bootstrap Zero Curve\r\n\r\n% Treasuries\r\nrstart = log(1 + (y1(1)*(1\/12)))\/(1\/12);\r\nz1(1) = 100\/(100*(1+y1(1)\/2));\r\n\r\nfor i = 2:length(y1)\r\n\tz1(i) = (100 - y1(i)\/2*100*sum(z1(1:i-1)))\/(100*(1+y1(i)\/2));\r\nend\r\n\r\n% TIPs\r\nz2(1) = 100\/(100*(1+y2(1)\/2));\r\n\r\nfor i = 2:length(y2)\r\n\tz2(i) = (100 - y2(i)\/2*100*sum(z2(1:i-1)))\/(100*(1+y2(i)\/2));\r\nend\r\n\r\n% Nominal Discount Factor\r\nx_treas = x1(~isnan(z1));\r\nz_treas = z1(~isnan(z1));\r\n\r\n% Real Discount Factor\r\nx_real = x1(~isnan(z2));\r\nz_real = z2(~isnan(z2));\r\n\r\n% Plot Discount Factor\r\nfigure(2)\r\nplot(x_treas,z_treas,'linewidth',2,x_real,z_real,'linewidth',2)\r\npause(5)\r\ntitle('Bootstrapped Discount Factors for Zero Coupon Bonds','fontsize',20)\r\nxlabel('Time to Maturity','fontsize',16)\r\nylabel('Discount Factor','fontsize',16)\r\n\r\n% Convert to annualized zero coupon yield and calculate inflation\r\nr_treas = (1.\/z_treas).^(1.\/x_treas) -1;\r\nr_real = (1.\/z_real).^(1.\/x_real)-1;\r\ninfl = r_treas - r_real;\r\n\r\n% Plot Zero Coupon Rates\r\nfigure(3)\r\nplot(x_treas(8:60),100*r_treas(8:60),'linewidth',2,x_real(8:60),100*r_real(8:60),'linewidth',2,x_treas(8:60),100*infl(8:60),'linewidth',2)\r\npause(5)\r\ntitle('Annualized Interest Rates on Zero Coupon Bonds and Breakeven Rate of Inflation','fontsize',20)\r\nxlabel('Time to Maturity','fontsize',16)\r\nylabel('Annualized Interest Rate (%)','fontsize',16)\r\nlegend('Treasury Zero','TIPS Zero','Breakeven Inflation','location','northwest')\r\n\r\n% Calculate Forward Rates\r\nforward_treas = -log(z_treas(2:end).\/z_treas(1:end-1))\/0.5;\r\nforward_real = -log(z_real(2:end).\/z_real(1:end-1))\/0.5;\r\nforward_infl = forward_treas - forward_real;\r\n\r\n% Plot forward rates\r\nfigure(4)\r\nplot(x_treas(8:end-1),100*forward_treas(8:end),'linewidth',2,x_real(8:end-1),100*forward_real(8:end),'linewidth',2,x_real(8:end-1),100*forward_infl(8:end),'linewidth',2)\r\npause(5)\r\naxis([0 30 -1 8])\r\npause(3)\r\ntitle('Forward Interest and Inflation Rates','fontsize',20)\r\nxlabel('Time to Maturity','fontsize',16)\r\nylabel('Annualized Interest Rate (%)','fontsize',16)\r\nlegend('Forward Nominal (Treasuries)','Forward Real (TIPS)','Forward Breakeven Inflation','location','northwest')\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Note: This page contains links to the data sources and the Octave source\u00a0code which I used to generate the plots in my \u00a0Inflation Expectations and the Breakeven Rate of Inflation post. Data: The first graph plotted in my inflation expectations post was created using the FRED database at the St. Louis Fed website.\u00a0 This site […]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":145,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/1175"}],"collection":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/comments?post=1175"}],"version-history":[{"count":11,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/1175\/revisions"}],"predecessor-version":[{"id":2030,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/1175\/revisions\/2030"}],"up":[{"embeddable":true,"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/pages\/145"}],"wp:attachment":[{"href":"http:\/\/www.calculatinginvestor.com\/wp-json\/wp\/v2\/media?parent=1175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}