# sim_psy1: Simulation of a single-bubble process In kvasilopoulos/exuber: Econometric Analysis of Explosive Time Series

## Description

The following function generates a time series which switches from a martingale to a mildly explosive process and then back to a martingale.

## Usage

 ```1 2 3 4 5 6 7 8 9``` ```sim_psy1( n, te = 0.4 * n, tf = 0.15 * n + te, c = 1, alpha = 0.6, sigma = 6.79, seed = NULL ) ```

## Arguments

 `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 `set.seed` before simulation. If set, the value is saved as "seed" attribute of the returned value. The default, NULL, will not change rng state, and return .Random.seed as the "seed" attribute. Results are different between the parallel and non-parallel option, even if they have the same seed.

## Details

The data generating process is described by the following equation:

X[t] = X[t-1] 1{t < te}+ δ[T] * X[t-1] 1{te ≤ t ≤ tf} + (∑ [k=tf+1]^t ε[k] + X[tf]) 1{t > tf} + ε[t] 1{t ≤ tf},

where the autoregressive coefficient δ[T] is given by:

δ[T] = 1 + c*T^{-a}

with c>0, α in (0,1), ε - iid(0, σ^2) and X[tf] = X[te] + X' with X'= 0p(1), te = [T re] dates the origination of the bubble, and tf = [T rf] dates the collapse of the bubble. During the pre- and post- bubble periods, [1, te), Xt is a pure random walk process. During the bubble expansion period [te,tf] becomes a mildly explosive process with expansion rate given by the autoregressive coefficient δ[T]; and, finally during the post-bubble period, (tf, t] Xt reverts to a martingale.

For further details see Phillips et al. (2015) p. 1054.

## Value

A numeric vector of length n.

## References

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.

`sim_psy2`, `sim_blan`, `sim_evans`
 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```# 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() ```