Title: | Econometric Analysis of Explosive Time Series |
---|---|
Description: | Testing for and dating periods of explosive dynamics (exuberance) in time series using the univariate and panel recursive unit root tests proposed by Phillips et al. (2015) <doi:10.1111/iere.12132> and Pavlidis et al. (2016) <doi:10.1007/s11146-015-9531-2>.The recursive least-squares algorithm utilizes the matrix inversion lemma to avoid matrix inversion which results in significant speed improvements. Simulation of a variety of periodically-collapsing bubble processes. Details can be found in Vasilopoulos et al. (2022) <doi:10.18637/jss.v103.i10>. |
Authors: | Kostas Vasilopoulos [cre, aut], Efthymios Pavlidis [aut], Enrique Martínez-García [aut], Simon Spavound [aut] |
Maintainer: | Kostas Vasilopoulos <[email protected]> |
License: | GPL-3 |
Version: | 1.0.2 |
Built: | 2024-11-01 06:41:03 UTC |
Source: | CRAN |
ds_radf
objectTakes a ds_radf
object and returns a ggplot2 object, with a
geom_segment() layer.
## S3 method for class 'ds_radf' autoplot(object, trunc = TRUE, ...)
## S3 method for class 'ds_radf' autoplot(object, trunc = TRUE, ...)
object |
An object of class |
trunc |
Whether to remove the period of the minimum window from the plot (default = TRUE). |
... |
Further arguments passed to methods. Not used. |
sim_data_wdate %>% radf() %>% datestamp() %>% autoplot() # Change the colour manually sim_data_wdate %>% radf() %>% datestamp() %>% autoplot() + ggplot2::scale_colour_manual(values = rep("black", 4))
sim_data_wdate %>% radf() %>% datestamp() %>% autoplot() # Change the colour manually sim_data_wdate %>% radf() %>% datestamp() %>% autoplot() + ggplot2::scale_colour_manual(values = rep("black", 4))
radf_distr
objectTakes a radf_distr
object and returns a ggplot2 object.
## S3 method for class 'radf_distr' autoplot(object, ...)
## S3 method for class 'radf_distr' autoplot(object, ...)
object |
An object of class |
... |
Further arguments passed to methods, used only in |
radf
modelsautoplot.radf_obj
takes radf_obj
and radf_cv
and returns a faceted ggplot object.
shade
is used as an input to shape_opt
. shade
modifies the
geom_rect layer that demarcates the exuberance periods.
## S3 method for class 'radf_obj' autoplot( object, cv = NULL, sig_lvl = 95, option = c("gsadf", "sadf"), min_duration = 0L, select_series = NULL, nonrejected = FALSE, shade_opt = shade(), trunc = TRUE, include_negative = "DEPRECATED", ... ) ## S3 method for class 'radf_obj' autoplot2( object, cv = NULL, sig_lvl = 95, option = c("gsadf", "sadf"), min_duration = 0L, select_series = NULL, nonrejected = FALSE, trunc = TRUE, shade_opt = shade(), ... ) shade( fill = "grey55", fill_negative = fill, fill_ongoing = NULL, opacity = 0.3, ... )
## S3 method for class 'radf_obj' autoplot( object, cv = NULL, sig_lvl = 95, option = c("gsadf", "sadf"), min_duration = 0L, select_series = NULL, nonrejected = FALSE, shade_opt = shade(), trunc = TRUE, include_negative = "DEPRECATED", ... ) ## S3 method for class 'radf_obj' autoplot2( object, cv = NULL, sig_lvl = 95, option = c("gsadf", "sadf"), min_duration = 0L, select_series = NULL, nonrejected = FALSE, trunc = TRUE, shade_opt = shade(), ... ) shade( fill = "grey55", fill_negative = fill, fill_ongoing = NULL, opacity = 0.3, ... )
object |
An object of class |
cv |
An object of class |
sig_lvl |
Significance level. It could be one of 90, 95 or 99. |
option |
Whether to apply the "gsadf" or "sadf" methodology (default = "gsadf"). |
min_duration |
The minimum duration of an explosive period for it to be reported (default = 0). |
select_series |
A vector of column names or numbers specifying the series to be used in plotting. Note that the order of the series does not alter the order used in plotting. |
nonrejected |
If TRUE, plot all variables regardless of rejecting the NULL at the 5 percent significance level. |
shade_opt |
Shading options, typically set using |
trunc |
Whether to remove the period of the minimum window from the plot (default = TRUE). |
include_negative |
Argument name is deprecated and substituted with |
... |
Further arguments passed to |
fill |
The shade color that indicates the exuberance periods with positive signal |
fill_negative |
The shade color that indicates the exuberance periods with positive signal |
fill_ongoing |
The shade color that indicates the exuberance periods that are ongoing the null hypothesis. |
opacity |
The opacity of the shade color aka alpha. |
rsim_data <- radf(sim_data_wdate) autoplot(rsim_data) # Modify facet_wrap options through ellipsis autoplot(rsim_data, scales = "free_y", dir = "v") # Modify the shading options autoplot(rsim_data, shade_opt = shade(fill = "pink", opacity = 0.5)) # Allow for nonrejected series to be plotted autoplot(rsim_data, nonrejected = TRUE) # Remove the shading completely (2 ways) autoplot(rsim_data, shade_opt = NULL) autoplot(rsim_data, shade_opt = shade(opacity = 0)) # Plot only the series with the shading options autoplot2(rsim_data) autoplot2(rsim_data, trunc = FALSE) # keep the minw period # We will need ggplot2 from here on out library(ggplot2) # Change (overwrite) color, size or linetype autoplot(rsim_data) + scale_color_manual(values = c("black", "black")) + scale_size_manual(values = c(0.9, 1)) + scale_linetype_manual(values = c("solid", "solid")) # Change names through labeller (first way) custom_labels <- c("psy1" = "new_name_for_psy1", "psy2" = "new_name_for_psy2") autoplot(rsim_data, labeller = labeller(.default = label_value, id = as_labeller(custom_labels))) # Change names through labeller (second way) custom_labels2 <- series_names(rsim_data) names(custom_labels2) <- custom_labels2 custom_labels2[c(3,5)] <- c("Evans", "Blanchard") autoplot(rsim_data, labeller = labeller(id = custom_labels2)) # Or change names before plotting series_names(rsim_data) <- LETTERS[1:5] autoplot(rsim_data) # Change Theme options autoplot(rsim_data) + theme(legend.position = "right")
rsim_data <- radf(sim_data_wdate) autoplot(rsim_data) # Modify facet_wrap options through ellipsis autoplot(rsim_data, scales = "free_y", dir = "v") # Modify the shading options autoplot(rsim_data, shade_opt = shade(fill = "pink", opacity = 0.5)) # Allow for nonrejected series to be plotted autoplot(rsim_data, nonrejected = TRUE) # Remove the shading completely (2 ways) autoplot(rsim_data, shade_opt = NULL) autoplot(rsim_data, shade_opt = shade(opacity = 0)) # Plot only the series with the shading options autoplot2(rsim_data) autoplot2(rsim_data, trunc = FALSE) # keep the minw period # We will need ggplot2 from here on out library(ggplot2) # Change (overwrite) color, size or linetype autoplot(rsim_data) + scale_color_manual(values = c("black", "black")) + scale_size_manual(values = c(0.9, 1)) + scale_linetype_manual(values = c("solid", "solid")) # Change names through labeller (first way) custom_labels <- c("psy1" = "new_name_for_psy1", "psy2" = "new_name_for_psy2") autoplot(rsim_data, labeller = labeller(.default = label_value, id = as_labeller(custom_labels))) # Change names through labeller (second way) custom_labels2 <- series_names(rsim_data) names(custom_labels2) <- custom_labels2 custom_labels2[c(3,5)] <- c("Evans", "Blanchard") autoplot(rsim_data, labeller = labeller(id = custom_labels2)) # Or change names before plotting series_names(rsim_data) <- LETTERS[1:5] autoplot(rsim_data) # Change Theme options autoplot(rsim_data) + theme(legend.position = "right")
Computes the origination, termination and duration of episodes during which the time series display explosive dynamics.
datestamp(object, cv = NULL, min_duration = 0L, ...) ## S3 method for class 'radf_obj' datestamp( object, cv = NULL, min_duration = 0L, sig_lvl = 95, option = c("gsadf", "sadf"), nonrejected = FALSE, ... )
datestamp(object, cv = NULL, min_duration = 0L, ...) ## S3 method for class 'radf_obj' datestamp( object, cv = NULL, min_duration = 0L, sig_lvl = 95, option = c("gsadf", "sadf"), nonrejected = FALSE, ... )
object |
An object of class |
cv |
An object of class |
min_duration |
The minimum duration of an explosive period for it to be reported (default = 0). |
... |
further arguments passed to methods. |
sig_lvl |
logical. Significance level, one of 90, 95 or 99. |
option |
Whether to apply the "gsadf" or "sadf" methodology (default = "gsadf"). |
nonrejected |
logical. Whether to apply datestamping technique to the series that were not able to reject the Null hypothesis. |
Datestamp also stores a vector whose elements take the value of 1 when there is a period of explosive behaviour and 0 otherwise. This output can serve as a dummy variable for the occurrence of exuberance.
Return a table with the following columns:
Start:
Peak:
End:
Duration:
Signal:
Ongoing:
Returns a list containing the estimated origination and termination dates of episodes of explosive behaviour and the corresponding duration.
Phillips, P. C. B., Shi, S., & Yu, J. (2015). Testing for Multiple Bubbles: Historical Episodes of Exuberance and Collapse in the S&P 500. International Economic Review, 56(4), 1043-1078.
rsim_data <- radf(sim_data) ds_data <- datestamp(rsim_data) ds_data # Choose minimum window datestamp(rsim_data, min_duration = psy_ds(nrow(sim_data))) autoplot(ds_data)
rsim_data <- radf(sim_data) ds_data <- datestamp(rsim_data) ds_data # Choose minimum window datestamp(rsim_data, min_duration = psy_ds(nrow(sim_data))) autoplot(ds_data)
Provides information on whether the null hypothesis of a unit root is rejected against the alternative of explosive behaviour for each series in a dataset.
diagnostics(object, cv = NULL, ...) ## S3 method for class 'radf_obj' diagnostics(object, cv = NULL, option = c("gsadf", "sadf"), ...)
diagnostics(object, cv = NULL, ...) ## S3 method for class 'radf_obj' diagnostics(object, cv = NULL, option = c("gsadf", "sadf"), ...)
object |
An object of class |
cv |
An object of class |
... |
Further arguments passed to methods. |
option |
Whether to apply the "gsadf" or "sadf" methodology (default = "gsadf"). |
Diagnostics also stores a vector whose elements take the value of 1 when there is a period of explosive behaviour and 0 otherwise.
Returns a list with the series that reject (positive) and the series that do not reject (negative) the null hypothesis, and at what significance level.
rsim_data <- radf(sim_data) diagnostics(rsim_data) diagnostics(rsim_data, option = "sadf")
rsim_data <- radf(sim_data) diagnostics(rsim_data) diagnostics(rsim_data, option = "sadf")
Retrieve or replace the index of an object.
index(x, ...) index(x) <- value
index(x, ...) index(x) <- value
x |
An object. |
... |
Further arguments passed to methods. |
value |
An ordered vector of the same length as the ‘index’ attribute of x. |
If the user does not specify an index for the estimation a
pseudo-index is generated which is a sequential numeric series. After the estimation,
the user can use index
to retrieve or `index<-`
to replace the index.
The index can be either numeric or Date.
exuberdata
PackageThis function wraps the install.packages
function and offers a faster
and more convenient way to install exuberdata.
install_exuberdata()
install_exuberdata()
if("exuberdata" %in% loadedNamespaces()) { exuberdata::radf_crit2 }
if("exuberdata" %in% loadedNamespaces()) { exuberdata::radf_crit2 }
tb
from the Phillips and Shi (2020)This function helps to find the number of observations in the window over which size is to be controlled.
ps_tb(n, freq = c("monthly", "quarterly", "annual", "weekly"), size = 2)
ps_tb(n, freq = c("monthly", "quarterly", "annual", "weekly"), size = 2)
n |
A positive integer. The sample size. |
freq |
The type of date-interval. |
size |
The size to be controlled. |
Phillips, P. C., & Shi, S. (2020). Real time monitoring of asset markets: Bubbles and crises. In Handbook of Statistics (Vol. 42, pp. 61-80). Elsevier.
Shi, S., Hurn, S., Phillips, P.C.B., 2018. Causal change detection in possibly integrated systems: Revisiting the money-income relationship.
psy_minw
and psy_ds
use the rules-of- thumb proposed by
Phillips et al. (2015) to compute the minimum window size and the
minimum duration of an episode of exuberance, respectively.
psy_minw(n) psy_ds(n, rule = 1, delta = 1)
psy_minw(n) psy_ds(n, rule = 1, delta = 1)
n |
A positive integer. The sample size. |
rule |
Rule to compute the minimum duration of an episode (default: rule = 1, where T denotes the sample size). Rule 1 corresponds to log(T), while rule 2 to log(T)/T. |
delta |
Frequency-dependent parameter (default; delta = 1). See details. |
For the minimum duration period, psy_ds
allows the user to choose from two rules:
delta
depends on the frequency of the data and the minimal duration condition.
Phillips, P. C. B., Shi, S., & Yu, J. (2015). Testing for Multiple Bubbles: Historical Episodes of Exuberance and Collapse in the S&P 500. International Economic Review, 56(4), 1043-1078.
psy_minw(100) psy_ds(100)
psy_minw(100) psy_ds(100)
radf
returns the recursive univariate and panel Augmented Dickey-Fuller test statistics.
radf(data, minw = NULL, lag = 0L)
radf(data, minw = NULL, lag = 0L)
data |
A univariate or multivariate numeric time series object, a numeric vector or matrix, or a data.frame. The object should not have any NA values. |
minw |
A positive integer. The minimum window size (default =
|
lag |
A non-negative integer. The lag length of the Augmented Dickey-Fuller regression (default = 0L). |
The radf()
function is vectorized, i.e., it can handle multiple series
at once, to improve efficiency. This property also enables the computation of panel
statistics internally as a by-product of the univariate estimations with minimal
additional cost incurred.
A list that contains the unit root test statistics (sequence):
adf |
Augmented Dickey-Fuller |
badf |
Backward Augmented Dickey-Fuller |
sadf |
Supremum Augmented Dickey-Fuller |
bsadf |
Backward Supremum Augmented Dickey-Fuller |
gsadf |
Generalized Supremum Augmented Dickey-Fuller |
bsadf_panel |
Panel Backward Supremum Augmented Dickey-Fuller |
gsadf_panel |
Panel Generalized Supremum Augmented Dickey-Fuller |
And attributes:
mat |
The matrix used in the estimation. |
index |
The index parsed from the dataset. |
lag |
The lag used in the estimation. |
n |
The number of rows. |
minw |
The minimum window used in the estimation. |
series_names |
The series names. |
Phillips, P. C. B., Wu, Y., & Yu, J. (2011). Explosive Behavior in The 1990s Nasdaq: When Did Exuberance Escalate Asset Values? International Economic Review, 52(1), 201-226.
Phillips, P. C. B., Shi, S., & Yu, J. (2015). Testing for Multiple Bubbles: Historical Episodes of Exuberance and Collapse in the S&P 500. International Economic Review, 56(4), 1043-1078.
Pavlidis, E., Yusupova, A., Paya, I., Peel, D., Martínez-García, E., Mack, A., & Grossman, V. (2016). Episodes of exuberance in housing markets: in search of the smoking gun. The Journal of Real Estate Finance and Economics, 53(4), 419-449.
# We will use simulated data that are stored as data sim_data rsim <- radf(sim_data) str(rsim) # We would also use data that contain a Date column sim_data_wdate rsim_wdate <- radf(sim_data_wdate) tidy(rsim_wdate) augment(rsim_wdate) tidy(rsim_wdate, panel = TRUE) head(index(rsim_wdate)) # For lag = 1 and minimum window = 20 rsim_20 <- radf(sim_data, minw = 20, lag = 1)
# We will use simulated data that are stored as data sim_data rsim <- radf(sim_data) str(rsim) # We would also use data that contain a Date column sim_data_wdate rsim_wdate <- radf(sim_data_wdate) tidy(rsim_wdate) augment(rsim_wdate) tidy(rsim_wdate, panel = TRUE) head(index(rsim_wdate)) # For lag = 1 and minimum window = 20 rsim_20 <- radf(sim_data, minw = 20, lag = 1)
A dataset containing Monte Carlo critical values for up to 600 observations
generated using the default minimum window. The critical values have been simulated and
stored as data to save computation time for the user. The stored critical values
can be obtained with the radf_mc_cv()
function, using
nrep = 2000
and the seed = 123
.
radf_crit
radf_crit
A list with lower level lists that contain
Augmented Dickey-Fuller
Backward Augmented Dickey-Fuller
Supremum Augmented Dickey-Fuller
Backward Supremum Augmented Dickey-Fuller
Generalized Supremum Augmented Dickey Fuller
Simulated from exuber package function radf_mc_cv()
.
## Not run: all.equal(radf_crit[[50]], radf_mc_cv(50, nrep = 2000, seed = 123)) ## End(Not run)
## Not run: all.equal(radf_crit[[50]], radf_mc_cv(50, nrep = 2000, seed = 123)) ## End(Not run)
radf_mc_cv
computes Monte Carlo critical values for the recursive unit
root tests. radf_mc_distr
computes the distribution.
radf_mc_cv(n, minw = NULL, nrep = 1000L, seed = NULL) radf_mc_distr(n, minw = NULL, nrep = 1000L, seed = NULL)
radf_mc_cv(n, minw = NULL, nrep = 1000L, seed = NULL) radf_mc_distr(n, minw = NULL, nrep = 1000L, seed = NULL)
n |
A positive integer. The sample size. |
minw |
A positive integer. The minimum window size (default =
|
nrep |
A positive integer. The number of Monte Carlo simulations. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
For radf_mc_cv
a list that contains the critical values for ADF,
BADF, BSADF and GSADF test statistics. For radf_mc_distr
a list that
contains the ADF, SADF and GSADF distributions.
radf_wb_cv
for wild bootstrap critical values and
radf_sb_cv
for sieve bootstrap critical values
# Default minimum window mc <- radf_mc_cv(n = 100) tidy(mc) # Change the minimum window and the number of simulations mc2 <- radf_mc_cv(n = 100, nrep = 600, minw = 20) tidy(mc2) mdist <- radf_mc_distr(n = 100, nrep = 1000) autoplot(mdist)
# Default minimum window mc <- radf_mc_cv(n = 100) tidy(mc) # Change the minimum window and the number of simulations mc2 <- radf_mc_cv(n = 100, nrep = 600, minw = 20) tidy(mc2) mdist <- radf_mc_distr(n = 100, nrep = 1000) autoplot(mdist)
radf_sb_cv
computes critical values for the panel recursive unit root test using
the sieve bootstrap procedure outlined in Pavlidis et al. (2016). radf_sb_distr
computes the distribution.
radf_sb_cv(data, minw = NULL, lag = 0L, nboot = 500L, seed = NULL) radf_sb_distr(data, minw = NULL, lag = 0L, nboot = 500L, seed = NULL)
radf_sb_cv(data, minw = NULL, lag = 0L, nboot = 500L, seed = NULL) radf_sb_distr(data, minw = NULL, lag = 0L, nboot = 500L, seed = NULL)
data |
A univariate or multivariate numeric time series object, a numeric vector or matrix, or a data.frame. The object should not have any NA values. |
minw |
A positive integer. The minimum window size (default =
|
lag |
A non-negative integer. The lag length of the Augmented Dickey-Fuller regression (default = 0L). |
nboot |
A positive integer. Number of bootstraps (default = 500L). |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
For radf_sb_cv
A list A list that contains the critical values
for the panel BSADF and panel GSADF test statistics. For radf_wb_dist
a numeric vector
that contains the distribution of the panel GSADF statistic.
Pavlidis, E., Yusupova, A., Paya, I., Peel, D., Martínez-García, E., Mack, A., & Grossman, V. (2016). Episodes of exuberance in housing markets: In search of the smoking gun. The Journal of Real Estate Finance and Economics, 53(4), 419-449.
radf_mc_cv
for Monte Carlo critical values and
radf_wb_cv
for wild Bootstrap critical values
rsim_data <- radf(sim_data, lag = 1) # Critical vales should have the same lag length with \code{radf()} sb <- radf_sb_cv(sim_data, lag = 1) tidy(sb) summary(rsim_data, cv = sb) autoplot(rsim_data, cv = sb) # Simulate distribution sdist <- radf_sb_distr(sim_data, lag = 1, nboot = 1000) autoplot(sdist)
rsim_data <- radf(sim_data, lag = 1) # Critical vales should have the same lag length with \code{radf()} sb <- radf_sb_cv(sim_data, lag = 1) tidy(sb) summary(rsim_data, cv = sb) autoplot(rsim_data, cv = sb) # Simulate distribution sdist <- radf_sb_distr(sim_data, lag = 1, nboot = 1000) autoplot(sdist)
radf_wb_cv
performs the Harvey et al. (2016) wild bootstrap re-sampling
scheme, which is asymptotically robust to non-stationary volatility, to
generate critical values for the recursive unit root tests. radf_wb_distr
computes the distribution.
radf_wb_cv(data, minw = NULL, nboot = 500L, dist_rad = FALSE, seed = NULL) radf_wb_distr(data, minw = NULL, nboot = 500L, dist_rad = FALSE, seed = NULL)
radf_wb_cv(data, minw = NULL, nboot = 500L, dist_rad = FALSE, seed = NULL) radf_wb_distr(data, minw = NULL, nboot = 500L, dist_rad = FALSE, seed = NULL)
data |
A univariate or multivariate numeric time series object, a numeric vector or matrix, or a data.frame. The object should not have any NA values. |
minw |
A positive integer. The minimum window size (default =
|
nboot |
A positive integer. Number of bootstraps (default = 500L). |
dist_rad |
Logical. If TRUE then the Rademacher distribution will be used. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
This approach involves applying a wild bootstrap re-sampling scheme to construct the bootstrap analogue of the Phillips et al. (2015) test which is asymptotically robust to non-stationary volatility.
For radf_wb_cv
a list that contains the critical values for the ADF,
BADF, BSADF and GSADF tests. For radf_wb_distr
a list that
contains the ADF, SADF and GSADF distributions.
Harvey, D. I., Leybourne, S. J., Sollis, R., & Taylor, A. M. R. (2016). Tests for explosive financial bubbles in the presence of non-stationary volatility. Journal of Empirical Finance, 38(Part B), 548-574.
Phillips, P. C. B., Shi, S., & Yu, J. (2015). Testing for Multiple Bubbles: Historical Episodes of Exuberance and Collapse in the S&P 500. International Economic Review, 56(4), 1043-1078.
radf_mc_cv
for Monte Carlo critical values and
radf_sb_cv
for sieve bootstrap critical values.
# Default minimum window wb <- radf_wb_cv(sim_data) tidy(wb) # Change the minimum window and the number of bootstraps wb2 <- radf_wb_cv(sim_data, nboot = 600, minw = 20) tidy(wb2) # Simulate distribution wdist <- radf_wb_distr(sim_data) autoplot(wdist)
# Default minimum window wb <- radf_wb_cv(sim_data) tidy(wb) # Change the minimum window and the number of bootstraps wb2 <- radf_wb_cv(sim_data, nboot = 600, minw = 20) tidy(wb2) # Simulate distribution wdist <- radf_wb_distr(sim_data) autoplot(wdist)
radf_wb_cv
performs the Phillips & Shi (2020) wild bootstrap re-sampling
scheme, which is asymptotically robust to non-stationary volatility, to
generate critical values for the recursive unit root tests. radf_wb_distr2
computes the distribution.
radf_wb_cv2( data, minw = NULL, nboot = 500L, adflag = 0, type = c("fixed", "aic", "bic"), tb = NULL, seed = NULL ) radf_wb_distr2( data, minw = NULL, nboot = 500L, adflag = 0, type = c("fixed", "aic", "bic"), tb = NULL, seed = NULL )
radf_wb_cv2( data, minw = NULL, nboot = 500L, adflag = 0, type = c("fixed", "aic", "bic"), tb = NULL, seed = NULL ) radf_wb_distr2( data, minw = NULL, nboot = 500L, adflag = 0, type = c("fixed", "aic", "bic"), tb = NULL, seed = NULL )
data |
A univariate or multivariate numeric time series object, a numeric vector or matrix, or a data.frame. The object should not have any NA values. |
minw |
A positive integer. The minimum window size (default =
|
nboot |
A positive integer. Number of bootstraps (default = 500L). |
adflag |
A positive integer. Number of lags when type is "fixed" or number of max lags when type is either "aic" or "bic". |
type |
Character. "fixed" for fixed lag, "aic" or "bic" for automatic lag selection according to the criterion. |
tb |
A positive integer. The simulated sample size. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
For radf_wb_cv2
a list that contains the critical values for the ADF,
BADF, BSADF and GSADF tests. For radf_wb_distr
a list that
contains the ADF, SADF and GSADF distributions.
Phillips, P. C., & Shi, S. (2020). Real time monitoring of asset markets: Bubbles and crises. In Handbook of Statistics (Vol. 42, pp. 61-80). Elsevier.
Phillips, P. C. B., Shi, S., & Yu, J. (2015). Testing for Multiple Bubbles: Historical Episodes of Exuberance and Collapse in the S&P 500. International Economic Review, 56(4), 1043-1078.
radf_mc_cv
for Monte Carlo critical values and
radf_sb_cv
for sieve bootstrap critical values.
# Default minimum window wb <- radf_wb_cv2(sim_data) tidy(wb) # Change the minimum window and the number of bootstraps wb2 <- radf_wb_cv2(sim_data, nboot = 600, minw = 20) tidy(wb2) # Simulate distribution wdist <- radf_wb_distr(sim_data) autoplot(wdist)
# Default minimum window wb <- radf_wb_cv2(sim_data) tidy(wb) # Change the minimum window and the number of bootstraps wb2 <- radf_wb_cv2(sim_data, nboot = 600, minw = 20) tidy(wb2) # Simulate distribution wdist <- radf_wb_distr(sim_data) autoplot(wdist)
scale_exuber_manual
allows specifying the color, size and linetype in
autoplot.radf_obj
mappings. theme_exuber
is a complete theme which control
all non-data display.
scale_exuber_manual( color_values = c("red", "blue"), linetype_values = c(2, 1), size_values = c(0.8, 0.7) ) theme_exuber( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 )
scale_exuber_manual( color_values = c("red", "blue"), linetype_values = c(2, 1), size_values = c(0.8, 0.7) ) theme_exuber( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 )
color_values |
a set of color values to map data values to. |
linetype_values |
a set of linetype values to map data values to. |
size_values |
a set of size values to map data values to. |
base_size |
base font size, given in pts. |
base_family |
base font family |
base_line_size |
base size for line elements |
base_rect_size |
base size for rect elements |
Retrieve or replace the series names of an object.
series_names(x, ...) series_names(x) <- value ## S3 replacement method for class 'radf_obj' series_names(x) <- value ## S3 replacement method for class 'wb_cv' series_names(x) <- value ## S3 replacement method for class 'sb_cv' series_names(x) <- value
series_names(x, ...) series_names(x) <- value ## S3 replacement method for class 'radf_obj' series_names(x) <- value ## S3 replacement method for class 'wb_cv' series_names(x) <- value ## S3 replacement method for class 'sb_cv' series_names(x) <- value
x |
An object. |
... |
Further arguments passed to methods. |
value |
n ordered vector of the same length as the "index" attribute of x. |
# Simulate bubble processes dta <- data.frame(psy1 = sim_psy1(n = 100), psy2 = sim_psy2(n = 100)) rfd <- radf(dta) series_names(rfd) <- c("OneBubble", "TwoBubbles")
# Simulate bubble processes dta <- data.frame(psy1 = sim_psy1(n = 100), psy2 = sim_psy2(n = 100)) rfd <- radf(dta) series_names(rfd) <- c("OneBubble", "TwoBubbles")
Simulation of a Blanchard (1979) rational bubble process.
sim_blan(n, pi = 0.7, sigma = 0.03, r = 0.05, b0 = 0.1, seed = NULL)
sim_blan(n, pi = 0.7, sigma = 0.03, r = 0.05, b0 = 0.1, seed = NULL)
n |
A positive integer specifying the length of the simulated output series. |
pi |
A positive value in (0, 1) which governs the probability of the bubble continuing to grow. |
sigma |
A positive scalar indicating the standard deviation of the innovations. |
r |
A positive scalar that determines the growth rate of the bubble process. |
b0 |
The initial value of the bubble. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
Blanchard's bubble process has two regimes, which occur with probability and
.
In the first regime, the bubble grows exponentially, whereas in the second regime, the bubble
collapses to a white noise.
With probability :
With probability :
where r
is a positive constant and .
A numeric vector of length n
.
Blanchard, O. J. (1979). Speculative bubbles, crashes and rational expectations. Economics letters, 3(4), 387-389.
sim_blan(n = 100, seed = 123) %>% autoplot()
sim_blan(n = 100, seed = 123) %>% autoplot()
Simulate (log) dividends from a random walk with drift.
sim_div( n, mu, sigma, r = 0.05, log = FALSE, output = c("pf", "d"), seed = NULL )
sim_div( n, mu, sigma, r = 0.05, log = FALSE, output = c("pf", "d"), seed = NULL )
n |
A positive integer specifying the length of the simulated output series. |
mu |
A scalar indicating the drift. |
sigma |
A positive scalar indicating the standard deviation of the innovations. |
r |
A positive value indicating the discount factor. |
log |
Logical. If true dividends follow a lognormal distribution. |
output |
A character string giving the fundamental price("pf") or dividend series("d"). Default is ‘pf’. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
If log is set to FALSE (default value) dividends follow:
where . The default parameters
are
,
and
(the initial value of the dividend sequence).
The above equation can be solved to yield the fundamental price:
If log is set to TRUE then dividends follow a lognormal distribution or log(dividends) follow:
where . Default parameters are
,
. The fundamental price in this case is:
where .
All default parameter values are those suggested by West (1988).
A numeric vector of length n.
West, K. D. (1988). Dividend innovations and stock price volatility. Econometrica: Journal of the Econometric Society, p. 37-61.
# Price is the sum of the bubble and fundamental components # 20 is the scaling factor pf <- sim_div(100, r = 0.05, output = "pf", seed = 123) pb <- sim_evans(100, r = 0.05, seed = 123) p <- pf + 20 * pb autoplot(p)
# Price is the sum of the bubble and fundamental components # 20 is the scaling factor pf <- sim_div(100, r = 0.05, output = "pf", seed = 123) pb <- sim_evans(100, r = 0.05, seed = 123) p <- pf + 20 * pb autoplot(p)
Simulation of an Evans (1991) rational periodically collapsing bubble process.
sim_evans( n, alpha = 1, delta = 0.5, tau = 0.05, pi = 0.7, r = 0.05, b1 = delta, seed = NULL )
sim_evans( n, alpha = 1, delta = 0.5, tau = 0.05, pi = 0.7, r = 0.05, b1 = delta, seed = NULL )
n |
A positive integer specifying the length of the simulated output series. |
alpha |
A positive scalar, with restrictions (see details). |
delta |
A positive scalar, with restrictions (see details). |
tau |
The standard deviation of the innovations. |
pi |
A positive value in (0, 1) which governs the probability of the bubble continuing to grow. |
r |
A positive scalar that determines the growth rate of the bubble process. |
b1 |
A positive scalar, the initial value of the series. Defaults to |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
delta
and alpha
are positive parameters which satisfy .
delta
represents the size of the bubble after collapse.
The default value of r
is 0.05.
The function checks whether alpha
and delta
satisfy this condition and will return an error if not.
The Evans bubble has two regimes. If the bubble grows at an average rate of
:
When the bubble expands at the increased rate of
:
where theta is a binary variable that takes the value 0 with probability
and 1 with probability
.
In the second phase, there is a (
) probability of the bubble process collapsing to
delta
.
By modifying the values of delta
, alpha
and pi
the user can change the frequency at which bubbles appear, the mean duration of a bubble before collapse and the scale of the bubble.
A numeric vector of length n
.
Evans, G. W. (1991). Pitfalls in testing for explosive bubbles in asset prices. The American Economic Review, 81(4), 922-930.
sim_evans(100, seed = 123) %>% autoplot()
sim_evans(100, seed = 123) %>% autoplot()
The new generating process considered here differs from the sim_psy1
model in
three respects - Phillips and Shi (2018):
First, it includes an asymptotically negligible drift in the martingale path during normal periods. Second, the collapse process is modeled directly as a transient mildly integrated process that covers an explicit period of market collapse. Third, a market recovery date is introduced to capture the return to normal market behavior.
sudden:
with beta = 0.1
and tr = tf + 0.01*n
disturbing:
with beta = 0.5
and tr = tf + 0.1*n
smooth:
with beta = 0.9
and tr = tf + 0.2*n
In order to provide the duration of the collapse period tr
as tr = tf + 0.2n
,
you have to provide tf
as well.
sim_ps1( n, te = 0.4 * n, tf = te + 0.2 * n, tr = tf + 0.1 * n, c = 1, c1 = 1, c2 = 1, eta = 0.6, alpha = 0.6, beta = 0.5, sigma = 6.79, seed = NULL )
sim_ps1( n, te = 0.4 * n, tf = te + 0.2 * n, tr = tf + 0.1 * n, c = 1, c1 = 1, c2 = 1, eta = 0.6, alpha = 0.6, beta = 0.5, sigma = 6.79, seed = NULL )
n |
A positive integer specifying the length of the simulated output series. |
te |
A scalar in (0, tf) specifying the observation in which the bubble originates. |
tf |
A scalar in (te, n) specifying the observation in which the bubble collapses. |
tr |
A scalar in (tf, n) specifying the observation in which market recovers |
c |
A positive scalar determining the drift in the normal market periods. |
c1 |
A positive scalar determining the autoregressive coefficient in the explosive regime. |
c2 |
A positive scalar determining the autoregressive coefficient in the collapse regime. |
eta |
A positive scalar (>0.5) determining the drift in the normal market periods. |
alpha |
A positive scalar in (0, 1) determining the autoregressive coefficient in the bubble period. |
beta |
A positive scalar in (0, 1) determining the autoregressive coefficient in the collapse period. |
sigma |
A positive scalar indicating the standard deviation of the innovations. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
A numeric vector of length n
.
Phillips, Peter CB, and Shu-Ping Shi. "Financial bubble implosion and reverse regression." Econometric Theory 34.4 (2018): 705-753.
# Disturbing collapse (default) disturbing <- sim_ps1(100) autoplot(disturbing) # Sudden collapse sudden <- sim_ps1(100, te = 40, tf= 60, tr = 61, beta = 0.1) autoplot(sudden)
# Disturbing collapse (default) disturbing <- sim_ps1(100) autoplot(disturbing) # Sudden collapse sudden <- sim_ps1(100, te = 40, tf= 60, tr = 61, beta = 0.1) autoplot(sudden)
The following function generates a time series which switches from a martingale to a mildly explosive process and then back to a martingale.
sim_psy1( n, te = 0.4 * n, tf = 0.15 * n + te, c = 1, alpha = 0.6, sigma = 6.79, seed = NULL )
sim_psy1( n, te = 0.4 * n, tf = 0.15 * n + te, c = 1, alpha = 0.6, sigma = 6.79, seed = NULL )
n |
A positive integer specifying the length of the simulated output series. |
te |
A scalar in (0, tf) specifying the observation in which the bubble originates. |
tf |
A scalar in (te, n) specifying the observation in which the bubble collapses. |
c |
A positive scalar determining the autoregressive coefficient in the explosive regime. |
alpha |
A positive scalar in (0, 1) determining the value of the expansion rate in the autoregressive coefficient. |
sigma |
A positive scalar indicating the standard deviation of the innovations. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
The data generating process is described by the following equation:
where the autoregressive coefficient is given by:
with ,
,
and
with
,
dates the origination of the bubble,
and
dates the collapse of the bubble.
During the pre- and post- bubble periods,
,
is a pure random walk process. During the bubble expansion period
becomes a mildly explosive process with expansion rate
given by the autoregressive coefficient
; and, finally
during the post-bubble period,
reverts to a martingale.
For further details see Phillips et al. (2015) p. 1054.
A numeric vector of length n.
Phillips, P. C. B., Shi, S., & Yu, J. (2015). Testing for Multiple Bubbles: Historical Episodes of Exuberance and Collapse in the S&P 500. International Economic Review, 5 6(4), 1043-1078.
# 100 periods with bubble origination date 40 and termination date 55 sim_psy1(n = 100, seed = 123) %>% autoplot() # 200 periods with bubble origination date 80 and termination date 110 sim_psy1(n = 200, seed = 123) %>% autoplot() # 200 periods with bubble origination date 100 and termination date 150 sim_psy1(n = 200, te = 100, tf = 150, seed = 123) %>% autoplot()
# 100 periods with bubble origination date 40 and termination date 55 sim_psy1(n = 100, seed = 123) %>% autoplot() # 200 periods with bubble origination date 80 and termination date 110 sim_psy1(n = 200, seed = 123) %>% autoplot() # 200 periods with bubble origination date 100 and termination date 150 sim_psy1(n = 200, te = 100, tf = 150, seed = 123) %>% autoplot()
The following data generating process is similar to sim_psy1
, with the difference that
there are two episodes of mildly explosive dynamics.
sim_psy2( n, te1 = 0.2 * n, tf1 = 0.2 * n + te1, te2 = 0.6 * n, tf2 = 0.1 * n + te2, c = 1, alpha = 0.6, sigma = 6.79, seed = NULL )
sim_psy2( n, te1 = 0.2 * n, tf1 = 0.2 * n + te1, te2 = 0.6 * n, tf2 = 0.1 * n + te2, c = 1, alpha = 0.6, sigma = 6.79, seed = NULL )
n |
A positive integer specifying the length of the simulated output series. |
te1 |
A scalar in (0, n) specifying the observation in which the first bubble originates. |
tf1 |
A scalar in (te1, n) specifying the observation in which the first bubble collapses. |
te2 |
A scalar in (tf1, n) specifying the observation in which the second bubble originates. |
tf2 |
A scalar in (te2, n) specifying the observation in which the second bubble collapses. |
c |
A positive scalar determining the autoregressive coefficient in the explosive regime. |
alpha |
A positive scalar in (0, 1) determining the value of the expansion rate in the autoregressive coefficient. |
sigma |
A positive scalar indicating the standard deviation of the innovations. |
seed |
An object specifying if and how the random number generator (rng)
should be initialized. Either NULL or an integer will be used in a call to
|
The two-bubble data generating process is given by (see also sim_psy1
):
where the autoregressive coefficient is:
with ,
,
,
,
,
,
,
,
where
is the last observation of the sample.
The observations
and
are the origination and termination dates of the first bubble;
and
are the origination and termination dates of the second bubble.
After the collapse of the first bubble,
resumes a martingale path until time
, and a second episode of exuberance begins at
.
Exuberance lasts lasts until
at which point the process collapses to a value of
. The process then continues on a martingale path until the end of the
sample period
. The duration of the first bubble is assumed to be longer than
that of the second bubble, i.e.
.
For further details you can refer to Phillips et al., (2015) p. 1055.
A numeric vector of length n
.
Phillips, P. C. B., Shi, S., & Yu, J. (2015). Testing for Multiple Bubbles: Historical Episodes of Exuberance and Collapse in the S&P 500. International Economic Review, 5 6(4), 1043-1078.
# 100 periods with bubble origination dates 20/60 and termination dates 40/70 sim_psy2(n = 100, seed = 123) %>% autoplot() # 200 periods with bubble origination dates 40/120 and termination dates 80/140 sim_psy2(n = 200, seed = 123) %>% autoplot()
# 100 periods with bubble origination dates 20/60 and termination dates 40/70 sim_psy2(n = 100, seed = 123) %>% autoplot() # 200 periods with bubble origination dates 40/120 and termination dates 80/140 sim_psy2(n = 200, seed = 123) %>% autoplot()
radf
modelssummary
method for radf models that consist of radf_obj
and radf_cv
.
## S3 method for class 'radf_obj' summary(object, cv = NULL, ...)
## S3 method for class 'radf_obj' summary(object, cv = NULL, ...)
object |
An object of class |
cv |
An object of class |
... |
Further arguments passed to methods. Not used. |
Returns a list of summary statistics, which include the estimated ADF, SADF, and GSADF test statistics and the corresponding critical values
# Simulate bubble processes, compute the test statistics and critical values rsim_data <- radf(sim_data) # Summary, diagnostics and datestamp (default) summary(rsim_data) #Summary, diagnostics and datestamp (wild bootstrap critical values) wb <- radf_wb_cv(sim_data) summary(rsim_data, cv = wb)
# Simulate bubble processes, compute the test statistics and critical values rsim_data <- radf(sim_data) # Summary, diagnostics and datestamp (default) summary(rsim_data) #Summary, diagnostics and datestamp (wild bootstrap critical values) wb <- radf_wb_cv(sim_data) summary(rsim_data, cv = wb)
Tidy or augment and then join objects.
tidy_join(x, y, ...) augment_join(x, y, ...)
tidy_join(x, y, ...) augment_join(x, y, ...)
x |
An object of class |
y |
An object of class |
... |
Further arguments passed to methods. |
Tidy or augment and then join objects of class radf_obj
and radf_cv
. The
object of reference is the radf_cv
. For example, if panel critical values
are provided the function will return the panel test statistic.
## S3 method for class 'radf_obj' tidy_join(x, y = NULL, ...) ## S3 method for class 'radf_obj' augment_join(x, y = NULL, trunc = TRUE, ...)
## S3 method for class 'radf_obj' tidy_join(x, y = NULL, ...) ## S3 method for class 'radf_obj' augment_join(x, y = NULL, trunc = TRUE, ...)
x |
An object of class |
y |
An object of class |
... |
Further arguments passed to methods. Not used. |
trunc |
Whether to remove the period of the minimum window from the plot (default = TRUE). |
tidy_join
also calls augment_join
when cv
is of class sb_cv
.
ds_radf
objectSummarizes information about ds_radf
object.
## S3 method for class 'ds_radf' tidy(x, ...)
## S3 method for class 'ds_radf' tidy(x, ...)
x |
An object of class |
... |
Further arguments passed to methods. Not used. |
radf_cv
objectSummarizes information about radf_cv
object.
## S3 method for class 'radf_cv' tidy(x, format = c("wide", "long"), ...) ## S3 method for class 'radf_cv' augment(x, format = c("wide", "long"), trunc = TRUE, ...)
## S3 method for class 'radf_cv' tidy(x, format = c("wide", "long"), ...) ## S3 method for class 'radf_cv' augment(x, format = c("wide", "long"), trunc = TRUE, ...)
x |
An object of class |
format |
Long or wide format (default = "wide"). |
... |
Further arguments passed to methods. Not used. |
trunc |
Whether to remove the period of the minimum window from the plot (default = TRUE). |
id: The series names.
sig: The significance level.
name: The name of the series (when format is "long").
crit: The critical value (when format is "long").
mc <- radf_mc_cv(100) # Get the critical values tidy(mc) # Get the critical value sequences augment(mc)
mc <- radf_mc_cv(100) # Get the critical values tidy(mc) # Get the critical value sequences augment(mc)
radf_distr
objectSummarizes information about radf_distr
object.
## S3 method for class 'radf_distr' tidy(x, ...)
## S3 method for class 'radf_distr' tidy(x, ...)
x |
An object of class |
... |
Further arguments passed to methods. Not used. |
## Not run: mc <- mc_cv(n = 100) tidy(mc) ## End(Not run)
## Not run: mc <- mc_cv(n = 100) tidy(mc) ## End(Not run)
radf_obj
objectSummarizes information about radf_obj
object.
## S3 method for class 'radf_obj' tidy(x, format = c("wide", "long"), panel = FALSE, ...) ## S3 method for class 'radf_obj' augment(x, format = c("wide", "long"), panel = FALSE, trunc = TRUE, ...)
## S3 method for class 'radf_obj' tidy(x, format = c("wide", "long"), panel = FALSE, ...) ## S3 method for class 'radf_obj' augment(x, format = c("wide", "long"), panel = FALSE, trunc = TRUE, ...)
x |
An object of class |
format |
Long or wide format (default = "wide"). |
panel |
If TRUE then returns the panel statistics |
... |
Further arguments passed to methods. Not used. |
trunc |
Whether to remove the period of the minimum window from the plot (default = TRUE). |
dta <- data.frame(psy1 = sim_psy1(n = 100), psy2 = sim_psy2(n = 100)) rfd <- radf(dta) # Get the test statistic tidy(rfd) # Get the test statisticsequences augment(rfd) # Get the panel test statistic tidy(rfd, panel = TRUE)
dta <- data.frame(psy1 = sim_psy1(n = 100), psy2 = sim_psy2(n = 100)) rfd <- radf(dta) # Get the test statistic tidy(rfd) # Get the test statisticsequences augment(rfd) # Get the panel test statistic tidy(rfd, panel = TRUE)