Learn R Programming

quantspec (version 1.0-0)

ts-models-AR2: Simulation of an AR(2) time series.

Description

Returns a simulated time series $(Y_t)$ that fulfills the following equation: $$Y_t = a_1 Y_{t-1} + a_2 Y_{t-2} + \epsilon_t,$$ where $a_1$ and $a_2$ are parameters and $\epsilon_t$ is independent white noise with marginal distribution specified by the parameter innov.

Usage

AR2(n, a1, a2, overhead = 500, innov = rnorm)

Arguments

n
length of the time series to be returned
a1
parameter
a2
parameter
overhead
an integer specifying the ``warmup'' period to reach an approximate stationary start for the times series
innov
a function with one parameter n that yields n independent pseudo random numbers each time it is called.

Value

  • Return an AR(2) time series with specified parameters.

Examples

Run this code
plot(AR2(100, a1=0, a2=0.5), type="l")

Run the code above in your browser using DataLab