Skip to content
exuber

Simulation

Simulation of a two-bubble process

sim_psy2
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
)

This data generating process is similar to sim_psy1, with the difference that there are two episodes of mildly explosive dynamics.

Arguments

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. It is either NULL or an integer, which is passed to set.seed before the simulation. If you set it, the value is saved as the "seed" attribute of the returned value. The default, NULL, leaves the state of the rng unchanged and returns .Random.seed as the "seed" attribute. Results are reproducible across the parallel and the non-parallel option when you use the same seed.

Value

A numeric vector of length n.

Details

The two-bubble data generating process is given by (see also sim_psy1):

Xt=Xt−11{t∈N0}+δTXt−11{t∈B1∪B2}+(∑k=τ1f+1tϵk+Xτ1f)1{t∈N1}+(∑l=τ2f+1tϵl+Xτ2f)1{t∈N2}+ϵt1{t∈N0∪B1∪B2}\begin{aligned} X_t = {} & X_{t-1}1\{t \in N_0\}+ \delta_T X_{t-1}1\{t \in B_1 \cup B_2\} + \left(\sum_{k=\tau_{1f}+1}^t \epsilon_k + X_{\tau_{1f}}\right) 1\{t \in N_1\} \\ & + \left(\sum_{l=\tau_{2f}+1}^t \epsilon_l + X_{\tau_{2f}}\right) 1\{t \in N_2\} + \epsilon_t 1\{t \in N_0 \cup B_1 \cup B_2\} \end{aligned}

where the autoregressive coefficient δT\delta_T is:

δT=1+cT−a\delta_T = 1 + cT^{-a}

with c>0c>0, α∈(0,1)\alpha \in (0,1), ϵ∼iid(0,σ2)\epsilon \sim iid(0, \sigma^2), N0=[1,τ1e)N_0 = [1, \tau_{1e}), B1=[τ1e,τ1f]B_1 = [\tau_{1e}, \tau_{1f}], N1=(τ1f,τ2e)N_1 = (\tau_{1f}, \tau_{2e}), B2=[τ2e,τ2f]B_2 = [\tau_{2e}, \tau_{2f}], N2=(τ2f,τ]N_2 = (\tau_{2f}, \tau], where τ\tau is the last observation of the sample. The observations τ1e=[Tr1e]\tau_{1e} = [T r_{1e}] and τ1f=[Tr1f]\tau_{1f} = [T r_{1f}] are the origination and termination dates of the first bubble; τ2e=[Tr2e]\tau_{2e} = [T r_{2e}] and τ2f=[Tr2f]\tau_{2f} = [T r_{2f}] are the origination and termination dates of the second bubble. After the collapse of the first bubble, XtX_t resumes a martingale path until time τ2e−1\tau_{2e}-1, and a second episode of exuberance begins at τ2e\tau_{2e}. Exuberance lasts until τ2f\tau_{2f}, at which point the process collapses to a value of Xτ2fX_{\tau_{2f}}. The process then continues on a martingale path until the end of the sample period τ\tau. The duration of the first bubble is assumed to be longer than that of the second bubble, i.e. τ1f−τ1e>τ2f−τ2e\tau_{1f}-\tau_{1e}>\tau_{2f}-\tau_{2e}.

For further details you can refer to Phillips et al., (2015) p. 1055.

Examples

These examples are copied from the package's own documentation and are run by R CMD check on every release. The printed output (after #>) and the plots were produced by running them against the current package source.

# 100 periods with bubble origination dates 20/60 and termination dates 40/70
sim_psy2(n = 100, seed = 123) %>%
 autoplot()
Plot from the sim_psy2 example
# 200 periods with bubble origination dates 40/120 and termination dates 80/140
sim_psy2(n = 200, seed = 123) %>%
  autoplot()
Plot from the sim_psy2 example

See also

sim_psy1, sim_blan, sim_evans

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. 10.1111/iere.12132