Calculation of credit impulse in growth growth

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) 
+5
source share
1 answer

It looks like you can really use:

 z <- diff(diff(usd_debt) / coredata(usd_gdp)) plot(z) 

Assuming Ct could be modeled using your usd_debt series?

Yes, you are using diff correct way. diff will call diff.xts when you apply it to the xts object, and in your example usd_ratio really an xts object, so it will be fast (efficient).

Here coredata is an optional but good practice when dividing xts objects, because it returns the base matrix instead. Separating xts objects can be problematic.

+5
source

Source: https://habr.com/ru/post/1269172/


All Articles