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
dlag = function(p, k = 1) | |
{ | |
return( lag(Delt(p, k=k), k=-k) ) | |
} | |
getSymbols( c("CP", "GDP"), src="FRED" ) | |
layout(1:2) | |
a = na.omit(merge(CP/GDP*100, dlag(CP, k=4*5)*100)) |
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
library(quantmod) | |
recplot = function(var, maintitle="", ylab="", ylim=NULL) | |
{ | |
if ( exists("USRECD") == FALSE ) { getSymbols("USRECD", src="FRED", env=.GlobalEnv) } | |
a = na.locf(cbind(USRECD, var)) | |
a = a[ .index(a) %in% .index(var) ] | |
par(oma=c(0,0,0,0)) | |
par(xaxt="n", yaxt="n") |
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 | |
calculateTaylor |
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
plot_PCEWage_drawdown <- function() | |
{ | |
if ( exists("PCE") == FALSE ) { getSymbols("PCE", src="FRED") } | |
if ( exists("A576RC1") == FALSE ) { getSymbols("A576RC1", src="FRED") } | |
pce_wage_dd = ( SMA(calculateDrawdown(PCE/A576RC1)) ) * 100 | |
recplot(pce_wage_dd, main="Drawdown of (PCE as % of Wages)") | |
} |
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
mergeLongEnd = function() | |
{ | |
if ( exists("DGS20") == FALSE ) { getSymbols("DGS20", src="FRED") } | |
if ( exists("DGS30") == FALSE ) { getSymbols("DGS30", src="FRED") } | |
if ( exists("LTGOVTBD") == FALSE ) { getSymbols("LTGOVTBD", src="FRED") } | |
a = merge(DGS30, LTGOVTBD, DGS20) | |
a$s = a$DGS30 | |
a$s[is.na(a$s)] = a$DGS20[is.na(a$s)] | |
a$s[is.na(a$s)] = a$LTGOVTBD[is.na(a$s)] | |
return(a$s) |
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
getSymbols(c("SPY", "TLT", "LQD")) | |
a = merge(SPY[,6], TLT[,6], LQD[,6])[ "2013" ] | |
b = (as.vector(tail(a, n=1)) / as.vector(head(a, n=1))) - 1 | |
names(b) = c("SPY", "TLT", "LQD") | |
b2 = round(b[order(b)] * 100) | |
barplot( b2, names.arg=names(b2) ) | |
text(1:3, 1, paste(b2, "%", sep="")) |
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
a = -Delt(CPIAUCNS, k=12)*100 | |
a = na.omit( a[endpoints(a, on="years")] ) | |
a = cumprod( (1+(a/100)) ) | |
b = M2OWN - Delt(CPIAUCNS, k=12)*100 | |
b = na.omit( b[endpoints(b, on="years")] ) | |
b = cumprod( (1+(b/100)) ) | |
b2 = TB3MS - Delt(CPIAUCNS, k=12)*100 | |
b2 = na.omit( b2[endpoints(b2, on="years")] ) |
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
a = -Delt(CPIAUCNS, k=12)*100 | |
a = na.omit( a[endpoints(a, on="years")] ) | |
a = cumprod( (1+(a/100)) ) | |
b = (M2OWN*0.6 - Delt(CPIAUCNS, k=12)*100) | |
b = na.omit( b[endpoints(b, on="years")] ) | |
b = cumprod( (1+(b/100)) ) | |
b2 = (TB3MS*0.6 - Delt(CPIAUCNS, k=12)*100) | |
b2 = na.omit( b2[endpoints(b2, on="years")] ) |
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
llxc = function( a, ll=-12:12, legend.loc="topleft", displayLegend=T, legend.cex=1.0, overplot=F ) | |
{ | |
if ( ncol(a) < 2 ) | |
{ | |
print( "Not enough columns") | |
return; | |
} | |
a = na.omit(a) | |
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
library(quantmod) | |
getSymbols(c("GDP", "CMDEBT"), src="FRED") | |
plot(cumsum(na.omit(diff(GDP) - diff(CMDEBT)))) |
OlderNewer