Learn R Programming

pRSR (version 3.1.1)

SimulateAR1: Simulate AR(1) series

Description

An AR(1) series with mean zero and variance 1 and with autocorrelation paramater phi is simulated.

Usage

SimulateAR1(n, phi)

Arguments

n
length of series
phi
autocorrelation parameter

Value

autocorrelated time series of length n

Details

The model equation is: z[t] = phi*z[t-1]+a[t], where z[1] is N(0,1) and a[t] are NID(0, siga), $siga=\sqrt(1/(1-phi^2))$.

See Also

FitHReg, SimulateHReg

Examples

Run this code
e<-SimulateAR1(10^4, phi=0.8)
mean(e)
sd(e)
acf(e, lag.max=5, plot=FALSE)

Run the code above in your browser using DataLab