partialAR (version 1.0.12)

rpar: Random partially autoregressive sequence

Description

Random partially autoregressive sequence

Usage

rpar(n, rho, sigma_M, sigma_R, M0 = 0, R0 = 0, 
  include.state = FALSE, robust = FALSE, nu = par.nu.default())

Arguments

n

Length of sequence to generate

rho

The coefficient of mean reversion

sigma_M

The standard deviation of the innovations of the mean-reverting component

sigma_R

The standard deviation of the innovations of the random walk component

M0

Initial state of mean-reverting component

R0

Initial state of random walk component

include.state

If TRUE, a data.frame is returned containing the states of the mean-reverting and random walk components. Otherwise, a numeric vector is returned containing the state of the system. Default: FALSE.

robust

If TRUE, innovations are t-distributed. Otherwise, they are normally distributed. Default: FALSE.

nu

If robust is TRUE, then this is the degrees of freedom parameter to be used in the t-distributed innovations.

Value

If include.state is FALSE, then returns the sequence X[t]. Otherwise, returns a data.frame with the following columns:

X

State of the system

M

State of the mean-reverting component

R

State of the random walk component

eps_M

Innovations in the mean-reverting component

eps_R

Innovations in the random walk component

Details

Generates a random sequence according to the specification of the partially autoregressive model. The partially autoregressive model is given as $$X_t = M_t + R_t$$ $$M_t = \rho M_{t-1} + \epsilon_{M,t}$$ $$R_t = R_{t-1} + \epsilon_{R,t}$$ $$-1 < \rho < 1$$

To generate the random sequence, the sequences epsilon_M[t] and epsilon_R[t] are first generated. These are then used to build up the sequences M[t], R[t] and X[t].

References

Clegg, Matthew. Modeling Time Series with Both Permanent and Transient Components using the Partially Autoregressive Model. Available at SSRN: http://ssrn.com/abstract=2556957

See Also

fit.par

Examples

Run this code
# NOT RUN {
set.seed(1)
x <- rpar(10000, 0.5, 2, 1)
library(tseries)
adf.test(x)      # Seems to contain a unit root, as expected
estimate.par(x)  # Estimate parameters using lagged variances
fit.par(x)       # Maximum likelihood estimate
# }

Run the code above in your browser using DataLab