rar1: Random AR(1) vector

rar1R Documentation

Random AR(1) vector

Description

Generates a random realization of an AR(1) sequence

Usage

rar1(n, a0 = 0, a1 = 1, trend = 0, sd = 1, x0 = 0)

Arguments

n

Length of vector to produce

a0

Constant term in AR(1) sequence

a1

Coefficient of mean-reversion

trend

Linear trend

sd

Standard deviation of sequence of innovations

x0

Starting value of sequence

Value

If trend=0, returns a vector of length n representing a simulation of an AR(1) process

X[k] = a_0 + a_1 * X[k-1] + ε[t]

where ε[t] is a sequence of independent and identically distributed samples from a normal distribution with mean zero and standard deviation sd.

If trend != 0, returns a vector of length n representing a simulation of a trend-stationary AR(1) process

R[k] = a_0 + a_1 * R[k-1] + ε[t]

X[k] = k * trend + R[k]

Author(s)

Matthew Clegg matthewcleggphd@gmail.com

See Also

rcoint

Examples

rar1(100, 0, 0)          # Equivalent to rnorm(100)
rar1(100, 0, 1)          # Equivalent to cumsum(rnorm(100))
acor(rar1(100, 1, .5))   # Should be about 0.5
tseries::adf.test(rar1(100, 0, .5))  # Should have a low p-value

matthewclegg/egcm documentation built on March 5, 2023, 6:33 a.m.