Simulate an AR(1) process with uniform innovations

前端 未结 1 1524
旧时难觅i
旧时难觅i 2020-12-11 19:57

I need to plot an AR(1) graph for the process

y[k] = 0.75 * y[k-1] + e[k] for y0 = 1. 

Assume that e[k] is unifor

相关标签:
1条回答
  • 2020-12-11 20:44

    We want to use R base function arima.sim for this task, and no extra libraries are required.

    By default, arima.sim generates ARIMA with innovations ~ N(0,1). If we want to change this, we need to control the rand.gen or innov argument. For example, you want innovations from uniform distributions U[-0.5, 0.5], we can do either of the following:

    arima.sim(model=list(ar=.75), n=100, rand.gen = runif, min = -0.5, max = 0.5)
    
    arima.sim(model=list(ar=.75), n = 100, innov = runif(100, -0.5, 0.5))
    

    Example

    set.seed(0)
    y <- arima.sim(model=list(ar=.75), n = 100, innov = runif(100, -0.5, 0.5))
    ts.plot(y)
    


    In case we want to have explicit control on y[0], we can just shift the above time series such that it starts from y[0]. Suppose y0 is our desired starting value, we can do

    y <- y - y[1] + y0
    

    For example, starting from y0 = 1:

    y <- y - y[1] + 1
    ts.plot(y)
    

    0 讨论(0)
提交回复
热议问题