hystar_sim {hystar} | R Documentation |
Simulate data from the HysTAR model
Description
With this function, you can simulate observations from the HysTAR model, given its parameter values.
Usage
hystar_sim(z, r, d, phi_R0, phi_R1, resvar = c(1, 1), start_regime = NULL)
Arguments
z |
A numeric vector representing the observed threshold variable.
You can simulate |
r |
A numeric vector of length 2, representing the threshold values
|
d |
A positive whole number representing the value of the
delay parameter. It must be smaller than |
phi_R0 |
A vector containing the constant and autoregressive parameters
|
phi_R1 |
The same as |
resvar |
A numeric vector of length 2 representing the variances of the
residuals |
start_regime |
Optionally, a 0 or 1 that indicates which regime should be the
first, in case the |
Details
Some details:
To simulate
y
, 50 burn-in samples according the starting regime are used.The coefficients imply a stationary process of
if
and
. See Zhu, Yu and Li (2013), p5.
Value
A list of class hystar_sim
with elements
-
$data
, adata.frame
withlength(z)
rows and 4 columns:-
y
, the outcome variable -
z
, the threshold variable -
H
, a logical vector that indicates at which time points the hysteresis effect is happening. Note that this vector starts withNA
(s), since the firsttime points have no values observed for
.
-
R
, the regime indicator vector.
-
-
$r
, a numeric vector with the two threshold values, -
$d
, the delay parameter, -
$phi
, a numeric vector containing the coefficients. The names are such thatphi_R1_2
represents, the second lag autoregressive coefficient in Regime 1,
-
$orders
, a numeric vector containing the two orders, and -
$resvar
, a numeric vector with the residual variances of both regimes.
Implemented generics for the hystar_sim
class:
-
plot()
plots thez
variable and they
variable above one another. Shading of the background visualizes the regimes. Thresholds are drawn as horizontal lines in thez
plot. You can provide regime_names (char vector of 2), main (char vector of 1), xlab (char vector of 1) and ylab (char vector of 2). -
summary()
gives an overview of the true parameter values that were used. -
print()
prints the parameter values within the mathematical representation of the model. Note that the scalar multiplied withe[t]
is the standard deviation of the residuals, not the variance. See also the model definition above.
The HysTAR model
The HysTAR model is defined as:
with
where denotes the order of regime
with
coefficients
,
is the standard deviation of the residuals, and
is a delay parameter. The parameters of primary interest are
the thresholds
. We let
, where
is the number of observations.
Author(s)
Daan de Jong.
References
Li, Guodong, Bo Guan, Wai Keung Li, en Philip L. H. Yu. ‘Hysteretic Autoregressive Time Series Models’. Biometrika 102, nr. 3 (september 2015): 717–23.
Zhu, Ke, Philip L H Yu, en Wai Keung Li. ‘Testing for the Buffered Autoregressive Process’. Munich Personal RePEc Archive, (november 2013).
Examples
z <- z_sim(n_t = 200, n_switches = 5, start_regime = 1)
sim <- hystar_sim(z = z, r = c(-.5, .5), d = 2, phi_R0 = c(0, .6), phi_R1 = 1)
plot(sim)
fit <- hystar_fit(sim$data)
summary(fit)