R中的时间序列模型

问题描述 投票:0回答:2

我想回答以下问题,我知道我可以使用arima.sim函数,但不确定如何模拟所问的模型:

我想模拟以下内容:

yt =α+βt+φyt-1+εt,εt〜IIDN(0,1)

当:alpha = 1,beta = 0和theta = 0.8

在每次模拟之前,我们应将种子设置为100,000。假设y0 = 0的初始值并获得500个观测值。我已经尝试了以下方法,但似乎不起作用:

set.seed(seed = 100000)
e <- rnorm(500)
m1 <- arima.sim(model = list(c(ma=0.8,alpha=1,beta=0)),n=500)

我必须针对4个不同的beta,theta和alpha值模拟4个不同的模型。有什么建议吗?

提前感谢。

time-series simulation alpha arima beta
2个回答
0
投票

1。 (α,β,φ)=(1,0,0.8)

set.seed(seed = 1232020)
e <- rnorm(500,mean=0,sd=1)

alpha <- 1
beta <- 0
theta <- 0.8
m_1 <- 0
for(i in 2:length(e)){
  m_1[i] <- alpha+beta*i+theta*m_1[i-1]+e[i]
}

认为这应该可以解决问题:)


0
投票

由于您尝试使用arima.sim,因此这里是arima.sim选项:

set.seed(100000)
t <- 1:500
alpha <- 1
beta <- 0
theta <- 0.8
ts <- alpha + beta * t + arima.sim(list(ma = theta), n = length(t))

因为beta = 0,所以没有确定的时间相关趋势,并且该过程对应于均值alpha为非零的MA(1)过程。

分解为确定性和随机项对应于将等式重写为

enter image description here

使用MA(1)过程

enter image description here

其中are是i.i.d. N(0,1)个残差。

我们可以可视化数据

library(forecast)
autoplot(ts)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.