rar1 | R Documentation |

Generates a random realization of an AR(1) sequence

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

`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 |

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]*

Matthew Clegg matthewcleggphd@gmail.com

`rcoint`

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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.