Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想写一个关于时间迭代方差的代码。该函数应如下所示:
sigma(t)=alpha x(t-1)+beta sigma(t-1)
不幸的是,我无法弄清楚如何在我的 for 循环中引入这个时间组件。有谁知道如何处理这种问题?
你是这个意思吗??
alpha <- 2; beta <- .1 x <- 1:5 sigma <- numeric(length(x)) sigma[1] <- 1 for (t in 2:length(x)) sigma[t] <- alpha*x[t-1] + beta*sigma[t-1] sigma # [1] 1.0000 2.1000 4.2100 6.4210 8.6421