set.seed(12345)
# Function to generate an AR(1) series
ar.series <- function(phi,epsilon) {
n <- length(epsilon)
series <- numeric(n)
series[1] <- epsilon[1]/(1-phi)
for(i in 2:n) {
series[i] <- phi*series[i-1] + epsilon[i]
}
return(series)
}
yt <- ar.series(0.1,rnorm(10000))
b.star(yt,round=TRUE)
yt <- ar.series(0.9,rnorm(10000))
b.star(yt,round=TRUE)
Run the code above in your browser using DataLab