-
-
Save RobHayward/acdf358834267c974d95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## John Taylor proposed the following rule designed to guide monetary policy: | |
## i = r* + pi + 0.5 ( pi - pi*) + 0.5 ( y - y*) | |
## where i is the nominal federal funds rate, r* is the "natural" real federal funds rate (often taken to be 2%), pi is the rate of inflation, pi* is the target inflation rate (for example, 2%), y is the logarithm of real output, and y* is the logarithm of potential output. | |
## The two basic ideas here are to raise the federal funds rate to one-half the extent that inflation exceeds its target and to lower the federal funds rate to one-half of the percentage that real output falls below its potential. Implicit in this formulation is that a reasonable rule of thumb applied consistently over time is more likely to achieve a good outcome than is aggressive manipulation of monetary policy. It is widely believed that central banks have paid close attention to variations on this Taylor Rule in recent years. | |
## From: http://www.econmodel.com/classic/terms/taylor_rule.htm | |
calculateTaylorRule = function(natural_ff_rate=2, inflation_target=2) | |
{ | |
if ( exists("CPILFESL") == FALSE ) { getSymbols("CPILFESL", src="FRED") } | |
if ( exists("GDPC96") == FALSE ) { getSymbols("GDPC96", src="FRED") } | |
if ( exists("GDPPOT") == FALSE ) { getSymbols("GDPPOT", src="FRED") } | |
rstar = natural_ff_rate | |
pi = Delt(CPILFESL, k=12)*100 | |
pistar = inflation_target | |
y = log(GDPC96) | |
ystar = log(GDPPOT) | |
i = rstar + pi + 0.5 * (pi - pistar) + 0.5 * ((y - ystar)*100) | |
return( i ) | |
} | |
## | |
## Federal funds rate = 8.5 + 1.4 (Core inflation - Unemployment). | |
## Here "core inflation" is the CPI inflation rate over the previous 12 months excluding food and energy, and "unemployment" is the seasonally-adjusted unemployment rate. The parameters in this formula were chosen to offer the best fit for data from the 1990s. | |
## From: http://gregmankiw.blogspot.com/2006/06/what-would-alan-do.html | |
calculateMankiwRule = function() | |
{ | |
if ( exists("CPILFESL") == FALSE ) { getSymbols("CPILFESL", src="FRED") } | |
if ( exists("UNRATE") == FALSE ) { getSymbols("UNRATE", src="FRED") } | |
i = 8.5 + 1.4 * (Delt(CPILFESL, k=12)*100 - UNRATE) | |
return( i ) | |
} | |
calculateHybridFF = function() | |
{ | |
if ( exists("PCEPILFE") == FALSE ) { getSymbols("PCEPILFE", src="FRED") } | |
if ( exists("U6RATE") == FALSE ) { getSymbols("U6RATE", src="FRED") } | |
if ( exists("GDPC96") == FALSE ) { getSymbols("GDPC96", src="FRED") } | |
if ( exists("GDPPOT") == FALSE ) { getSymbols("GDPPOT", src="FRED") } | |
if ( exists("TCU") == FALSE ) { getSymbols("TCU", src="FRED") } | |
if ( exists("FF") == FALSE ) { getSymbols("FF", src="FRED") } | |
a = na.trim(na.locf(merge(FF, Delt(PCEPILFE, k=12), U6RATE, GDPPOT/GDPC96, TCU))) | |
a = a[endpoints(a, on="months")] | |
names(a) = c("FF", "CPI", "U6RATE", "OUTPUTGAP", "TCU") | |
m = lm(a$FF ~ a$CPI + a$U6RATE + a$OUTPUTGAP + a$TCU + 0) | |
a$model = predict(m) | |
print(cor(a)[,1]) | |
return( a$model ) | |
} | |
plotRules = function() | |
{ | |
if ( exists("DFF") == FALSE ) { getSymbols("DFF", src="FRED") } | |
if ( exists("USRECD") == FALSE ) { getSymbols("USRECD", src="FRED") } | |
a = na.locf( merge(DFF, calculateMankiwRule(), calculateTaylorRule(), Delt(CPILFESL, k=12)*100, UNRATE, USRECD) ) | |
names(a) = c("DFF", "Mankiw", "Taylor", "CPI", "UNRATE", "USRECD") | |
b = na.omit( a[ endpoints(a) ] ) | |
# b = b["2006::"] | |
layout(1:2) | |
par(xaxt="n", yaxt="n") | |
barplot(b$USRECD, border="grey", col="grey") | |
par(new=T, xaxt="s", yaxt="s") | |
plot(b$DFF, main="", ylim=c(min(b), max(b)), ylab="%") | |
lines(b$Mankiw, col="red") | |
lines(b$Taylor, col="blue") | |
lines(b$CPI, col="green") | |
legend("topleft", c("Fed Funds", "Mankiw", "Taylor", "Core CPI"), col=c("black", "red", "blue", "green"), lty=c(1, 1, 1), cex=0.5) | |
title(main="Fed Funds vs Taylor & Mankiw Rules") | |
diff_taylor = b$DFF - b$Taylor | |
diff_mankiw = b$DFF - b$Mankiw | |
plot_ylim=c( | |
min(na.omit(merge(diff_taylor, diff_mankiw, b$CPI))), | |
max(na.omit(merge(diff_taylor, diff_mankiw, b$CPI)))) | |
par(xaxt="n", yaxt="n") | |
barplot(b$USRECD, border="grey", col="grey") | |
par(new=T, xaxt="s", yaxt="s") | |
plot(diff_taylor, main="Model Differences & Inflation+Unemployment", ylim=plot_ylim, ylab="%") | |
lines(diff_mankiw, col="blue") | |
lines(b$CPI, col="green") | |
abline(h=0, lty=2) | |
par(new=T, xaxt="n", yaxt="n") | |
plot.zoo(b$UNRATE, col="red") | |
par(xaxt="s", yaxt="s") | |
axis(4) | |
legend("topleft", c("Fed Funds - Taylor", "Fed Funds - Mankiw", "Inflation", "Unemployment (RHS)"), | |
col=c("black", "blue", "green", "red"), lty=1, cex=0.5) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment