模拟具有统一创新的 AR(1) 过程 [英] Simulate an AR(1) process with uniform innovations

查看:27
本文介绍了模拟具有统一创新的 AR(1) 过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为过程绘制一个 AR(1)

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

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

假设 e[k] 在区间 [-0.5, 0.5] 上均匀分布.

Assume that e[k] is uniformly distributed on the interval [-0.5, 0.5].

我正在尝试使用 arima.sim:

library(tseries)
y.0 <- arima.sim(model=list(ar=.75), n=100)
plot(y.0)

这似乎不正确.另外,如果 y[0] = 10,我要更改哪些参数?

It does not seem correct. Also, what parameters do I change if y[0] = 10?

推荐答案

我们想使用 R 基础函数 arima.sim 来完成这个任务,不需要额外的库.

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

默认情况下,arima.sim 生成具有创新性的 ARIMA ~ N(0,1).如果我们想改变这一点,我们需要控制 rand.geninnov 参数.例如,您想从均匀分布U[-0.5, 0.5] 中进行创新,我们可以执行以下任一操作:

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

<小时>

示例

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

如果我们想对 y[0] 进行显式控制,我们可以移动上述时间序列,使其从 y[0] 开始.假设 y0 是我们想要的起始值,我们可以这样做

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

例如从y0 = 1开始:

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

这篇关于模拟具有统一创新的 AR(1) 过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆