lppl.confidence.trust.A: Compute the LPPLS Confidence and Trust indicators which...

Description Usage Arguments Details Value References Examples

View source: R/LPPL_confidence_trust.R

Description

This function computes the LPPLS Confidence and Trust indicators which satisfy the filtering condition 1 and 2, respectively, in Table 1 by Sornette et al. (2015)

Usage

1
2
3
4
5
6
7
8
lppl.confidence.trust.A(
  x,
  time.scale,
  max.window,
  step.shrinking.window,
  boot.rep,
  clust_number
)

Arguments

x

is a T x 1 numeric data vector (or xts object)

time.scale

is the (maximum) rolling window size

max.window

is the maximum amount to be substracted from time.scale to create shrinking estimation windows. The initial maximum rolling window size for estimating the LPPL model is time.scale (=t2-t1); then, the window size is decreased by the amount given by step.shrinking.window and a new LPPL estimation is performed with window size (t2-t1+step.shrinking.window); this process continues till the estimation window size is (t2-t1+max.window). As a consequence, there are [max.window/step.shrinking.window+1] estimations with endpoint given by t2, whereas the starting dates are given by t1+i, where i=0,step.shrinking.window,2*step.shrinking.window...,max.window.

step.shrinking.window

is the amount by which the time.scale is decreased at each step

boot.rep

is the number of bootstrp replications used to compute the LPPL trust indicator at each ending point t2

clust_number

is the number of clusters for parallel computation

Details

This function computes the LPPLS Confidence and Trust indicators which satisfy the filtering condition 1 and 2, respectively, in Table 1 by Sornette et al. (2015). More specifically, it estimates the LPPL model using the 3-step procedure by Geraskin and Fantazzini (2013) and Fantazzini (2016) where, for each endpoint t2, the initial maximum rolling window size for estimating the LPPL model is time.scale (=t2-t1); then, the window size is decreased by the amount given by step.shrinking.window and a new LPPL estimation is performed with window size (t2-t1+step.shrinking.window); this process continues till the estimation window size is (t2-t1+max.window). As a consequence, there are [max.window/step.shrinking.window+1] estimations for each endpoint t2, which are then used to compute the filtering conditions 1 in Table 1 by Sornette et al. (2015), that is the DS LPPL Confidence indicator. For each endpoint t2, the DS LPPL Trust indicator is also computed: this is the median level over the [max.window/step.shrinking.window+1] estimations windows of the fraction among the boot.rep synthetic time series that satisfy the filtering condition 2 in Table 1 by Sornette et al. (2015). The synthetic time series are created by resampling boot.rep times the LPPL residuals and adding them to the calibrated LPPLS structure.

The estimated parameters and the DS LPPL Confidence and Trust indicators computed with the rolling LPPL regression are saved in the xts object lppl.roll. The original price series (with the bubble period highlighted in light red), the DS LPPL Confidence and Trust indicators, and the crash lock-in plot are all reported in a single plot with 4 rows.

Value

lppl.roll is a xts object containing the following columns:

- bet: the average estimate of the LPPL parameter beta over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- ome: the average estimate of the LPPL parameter omega over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- phi: the average estimate of the LPPL parameter phi over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- A: the average estimate of the LPPL parameter A over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- B: the average estimate of the LPPL parameter B over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- C: the average estimate of the LPPL parameter C over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- tc: the average estimate of the LPPL parameter tc (= the critical time) over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T. It is reported as number of rows.

- length: the average length of the estimation window over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- num.osc: the average estimate of the LPPL indicator called 'number of oscillations' (=omega/(2*pi) x log(abs((tc-t1)/(tc-t2))) )over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- damping: the average estimate of the LPPL indicator called 'Damping' (= (beta x abs(B))/(omega x abs(C)) ) over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T

- rel.err: the average estimate of the LPPL indicator called 'relative error' (= abs((Y-Yfit)/Yfit) ) over all rolling estimation window sizes with endpoint t2, where t2=time.scale,time.scale+1, ..., T.

- lppl.Confidence: the average fraction of fitting windows for which the LPPLS calibrations satisfy the filtering condition 1 in Table 1 by Sornette et al. (2015). This is called the LPPL Confidence indicator.

- lppl.trust: the median level over the [max.window/step.shrinking.window+1] estimations windows of the fraction among the boot.rep synthetic time series that satisfy the filtering condition 2 in Table 1 by Sornette et al. (2015). The synthetic time series are created by resampling boot.rep times the LPPL residuals and adding them to the calibrated LPPLS structure.

- col.index: numerical sequential index from 1 to the total number of rows of the final xts object.

- crash lock-in: same information as in tc, but in date format.

The function also compute a plot with 4 components:

- the original price series (with the bubble period highlighted in light red)

- the fraction of fitted LPPL satisfying the filtering condition 1 (over time), that is the DS LPPL Confidence indicator.

- the DS LPPL Trust indicator.

- the crash lock-in plot, that is the rolling estimates for the critical time tc

References

Fantazzini, D. (2016). The oil price crash in 2014/15: Was there a (negative) financial bubble?. Energy Policy, 96, 383-396.

Geraskin, P., & Fantazzini, D. (2013). Everything you always wanted to know about log-periodic power laws for bubble modeling but were afraid to ask. The European Journal of Finance, 19(5), 366-391.

Sornette, D., Demos, G., Qun, Z., Cauwels, P., Zhang, Q. (2015). Real-time prediction and post-mortem analysis of the Shanghai 2015 stock market bubble and crash. Journal of Investment Strategies, 4(4), 77-95.

Zhang, Q., Sornette, D., Balcilar, M., Gupta, R., Ozdemir, Z. A., Yetkiner, H. (2016). LPPLS bubble indicators over two centuries of the SP500 index. Physica A: Statistical Mechanics and its Applications, 458, 126-139.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 ## Not run: 
 # Example1: Compute the LPPL confidence indicator  with the SP500 prices
 from 1791 till 2015 (adjusted for dividends and splits), using a 269-month time scale
 data(sp500)
 ct=lppl.confidence.trust.A(x=sp500,time.scale=269,max.window=120,
 step.shrinking.window=10,boot.rep=100,clust_number=7)
 ct

 ## Example 2:  replicate the example in Sornette et al. (2015)
 library(quantmod)
 SSE<-getSymbols("000001.SS",auto.assign=FALSE,from=as.Date("2012-07-01"), to=as.Date("2015-07-31"))
 sse.adj <- SSE[,"000001.SS.Adjusted", drop = F]
 head(sse.adj)
 ct=lppl.confidence.trust.A(x=sse.adj,time.scale=250,max.window=120,
 step.shrinking.window=10,boot.rep=10,clust_number=7)
 ct

 ### Example 3: Compute the LPPL trust indicator  with bitcoin prices
 #load data on bitcoin downloaded from coindesk:  http://www.coindesk.com/price/
 path.bit <- system.file("extdata", "coindesk-bpi-USD-close.csv", package = "bubble")
 dat <- read.table(path.bit, dec = ".", sep =",", header = TRUE)
 dat <- xts(dat[,2], order.by=as.Date(dat[,1]))
 a1<-lppl.confidence.trust.A(x=dat,time.scale=750,max.window=600,step.shrinking.window=150,
 boot.rep=10,clust_number=8)
 a1
 
## End(Not run)

deanfantazzini/bubble documentation built on Oct. 22, 2020, 2:43 p.m.