Watanabe.bubble.index: Estimate the particular Watanabe et al.(2007a,b) model for...

Description Usage Arguments Details Value Examples

View source: R/Watanabe_functions.R

Description

This function estimates the particular Watanabe et al.(2007a,b) model for detecting financial bubbles using a rolling regression with window size equal to time.scale and data given by x

Usage

1
Watanabe.bubble.index(x, time.scale, original = FALSE)

Arguments

x

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

time.scale

is the optimal window size determined using the optimal.time.scale function

original

if TRUE the original method by Watanabe et al. (2007a,b) is used, otherwise a simplified approach which does not required nonlinear optimization.

Details

This function estimates the particular Watanabe et al.(2007a,b) model for detecting financial bubbles using a rolling AR(1) regression with window size equal to time.scale and data given by x The estimated parameters with the rolling AR(1) regression are saved in the xts object war1.par, while a bubble index which is 1 in case of a bubble according to the method by Watanabe et al.(2007a,b) in that specific date and zero otherwise is saved in the xts object bubble.index . Both the rolling estimated AR(1) parameters and the bubble index are plotted, with the bubble period highlighted in light red on the original xts object/numeric vector.

Value

results is a list containing the rolling estimated AR(1) parameters and the bubble index

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 ## Not run: 
 #Example 1: Replicate the analysis of plot (a) in Fig.1 in Watanabe et al.(2007b)
 library(quantmod)
 R <- getSymbols("AABA", src = "yahoo", from = as.Date("1998-01-01"), to = as.Date("2001-12-31"))
 head(AABA)
 yahoo.adj <- AABA[,"AABA.Adjusted", drop = F]
 Watanabe.bubble.index(yahoo.adj, 100)

 ### Example 2: Compute the EXponential Curve Fitting (EXCF) method  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]))
 Watanabe.bubble.index(dat, 100)
 
## End(Not run)

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