Skip to contents

This function generates synthetic time series data from an autoregressive (AR) model.

Usage

SimAR(time, burn_in, constant, coef, sd)

Arguments

time

Integer. Number of time points to simulate.

burn_in

Integer. Number of burn-in periods before recording data.

constant

Numeric. The constant term of the AR model.

coef

Numeric vector. Autoregressive coefficients.

sd

Numeric. The standard deviation of the random process noise.

Value

Numeric vector (column matrix) containing the simulated time series data.

Details

The SimAR() function generates synthetic time series data from an autoregressive (AR) model. The generated data follows the AR(p) model, where p is the number of coefficients specified in coef. The generated time series data includes a constant term and autoregressive terms based on the provided coefficients. Random noise, sampled from a normal distribution with mean 0 and standard deviation sd, is added to the time series. A burn-in period is specified to exclude initial data points from the output.

The steps in generating the autoregressive time series with burn-in are as follows:

  • Set the order of the AR model to p based on the length of coef.

  • Create a vector data of size time + burn_in to store the generated AR time series data.

  • Create a vector data of size time + burn_in of random process noise from a normal distribution with mean 0 and standard deviation sd.

  • Generate the autoregressive time series with burn-in using the formula: $$ Y_t = \mathrm{constant} + \sum_{i = 1}^{p} \left( \mathrm{coef}_i * Y_{t - i} \right) + \mathrm{noise}_t $$ where \(Y_t\) is the time series data at time \(t\), \(\mathrm{constant}\) is the constant term, \(\mathrm{coef}_i\) are the autoregressive coefficients, \(Y_{t - i}\) are the lagged data points up to order p, and \(\mathrm{noise}_t\) is the random noise at time \(t\).

  • Remove the burn-in period from the generated time series data.

See also

Other Simulation of Autoregressive Data Functions: CheckARCoef(), CheckVARCoef(), SimARCoef(), SimMVN(), SimPD(), SimVARCoef(), SimVARExo(), SimVARZIPExo(), SimVARZIP(), SimVAR(), SimVariance(), YXExo(), YX()

Author

Ivan Jacob Agaloos Pesigan

Examples

set.seed(42)
SimAR(time = 10, burn_in = 5, constant = 2, coef = c(0.5, -0.3), sd = 0.1)
#>           [,1]
#>  [1,] 2.266399
#>  [2,] 2.587045
#>  [3,] 2.871756
#>  [4,] 2.591727
#>  [5,] 2.787116
#>  [6,] 2.633457
#>  [7,] 2.470794
#>  [8,] 2.433327
#>  [9,] 2.615846
#> [10,] 2.359443