Part Finance Part R question
I am trying to reproduce the following formula in R using the Quantmod package and xts, also using the diff function. The code gives me a plot for a credit boost, but it doesn't seem to copy what I'm trying to get. See Link
https://www.gam.com/media/1434580/biggs.pdf -
page 2 give the formula for Credit Impulse - where C is the loan stock at time t
Credit impulse = (Ct-Ct-1) / GDPt - (Ct-1-Ct-2) / GDPt-1
page 3 Look at the graph (This is the graph I'm trying to replicate for Credit Impulse
Am I using the diff function correctly and can I do it more efficiently in R?
below is my code
#US DEBT [BN][USD][Q] usd_debt <- getSymbols("CRDQUSAPABIS", src = "FRED", auto.assign=FALSE) ##US GDP [BN][USD][Q] usd_gdp <- getSymbols("GDP", src = "FRED", auto.assign=FALSE) #USD Credit Impulse usd_debt <- usd_debt["2000/2016"] usd_gdp <- usd_gdp["2000/2016"] usd_ratio <- usd_debt/usd_gdp usd_ci <- diff(usd_ratio) plot(usd_ci)
source share