rar1: Random AR(1) vector

Description Usage Arguments Value Author(s) See Also Examples

View source: R/egcm_base.R

Description

Generates a random realization of an AR(1) sequence

Usage

1
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 [email protected]

See Also

rcoint

Examples

1
2
3
4
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

egcm documentation built on Sept. 18, 2017, 5:03 p.m.