- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想用不同的方式模拟 ARIMA(1,1,0)
:
我很欣赏下面的 r
代码是如何模拟一个 ARIMA(1,1,0)
我想按照格式来模拟许多 ARIMA (1,1,0)
具有不同的样本大小、phi 值 和标准差值
wn <- rnorm(10, mean = 0, sd = 1)
ar <- wn[1:2]
for (i in 3:10){
ar<- arima.sim(n=10,model=list(ar=-0.7048,order=c(1,1,0)),start.innov=4.1,n.start=1,innov=wn)
}
我问过类似的问题here并根据我的问题给出了一个很好的答案,但现在我看到 arima.sim()
函数在模拟 ARIMA
时间序列中是不可或缺的,因此想将它合并到我的模拟 ARIMA
时间序列的风格。我想出了这个试验,它使用 arima.sim()
函数来模拟 N=c(15, 20) ARIMA(1,1,0)
具有不同样本大小、标准差值 和phi 值 的时间序列,首先生成N 随机数然后使用初始的两个随机数作为前两个 ARIMA(1,1,0)。第 3 到 **n** 是遵循
ARIMA(1,1,0)`。这是我在下面尝试过的:
N <- c(15L, 20L)
SD = c(1, 2) ^ 2
phi = c(0.2, 0.4)
res <- vector('list', length(N))
names(res) <- paste('N', N, sep = '_')
set.seed(123L)
for (i in seq_along(N)){
res[[i]] <- vector('list', length(SD))
names(res[[i]]) <- paste('SD', SD, sep = '_')
ma <- matrix(NA_real_, nrow = N[i], ncol = length(phi))
for (j in seq_along(SD)){
wn <- rnorm(N[i], mean = 0, sd = SD[j])
ar[[1:2, ]] <- wn[[1:2]]
for (k in 3:N[i]){
ar[k, ] <- arima.sim(n=N[[i]],model=list(ar=phi[[k]],order=c(1,1,0)),start.innov=4.1,n.start=1,innov=wn)
}
colnames(ar) <- paste('ar_theta', phi, sep = '_')
res[[i]][[j]] <- ar
}
}
res1 <- lapply(res, function(dat) do.call(cbind, dat))
sapply(names(res1), function(nm) write.csv(res1[[nm]],
file = paste0(nm, ".csv"), row.names = FALSE, quote = FALSE))
最后两行将时序数据写入.csv,保存在我的工作目录下。
最佳答案
这里可能是一个使用Map
的方法。如果这不符合您的要求,请编辑您的帖子以包含预期输出。
N <- c(15L, 20L)
SD <- c(1, 2) ^ 2
phi = c(0.2, 0.4)
## generate all combos
all_combos <- expand.grid(N = N, SD = SD, phi = phi)
## create function
fx_arima <- function(n, SD, phi) {
arima.sim(n = n,
model=list(ar=phi, order = c(1, 1, 0)),
start.innov = 4.1,
n.start = 1,
rand.gen = function(n) rnorm(n, mean = 0, sd = SD))[-1L]
}
## find arima for all combos using Map
set.seed(123L)
res = Map(fx_arima, all_combos[["N"]], all_combos[["SD"]], all_combos[["phi"]])
## or a little bit more work:
set.seed(123L)
res2 = by(all_combos, all_combos["N"],
function(DF) {
res = mapply(fx_arima, DF[["N"]], DF[["SD"]], DF[["phi"]])
colnames(res) = paste("SD", DF[["SD"]], "phi", DF[["phi"]], sep = "_")
res
})
res2
## write to csv
Map(function(file, DF) write.csv(DF, paste0("N_", file, ".csv")), names(res2), res2)
关于r - arima.sim() 函数具有不同的 : sample sizes, phi 值和 sd 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60970948/
这个问题在这里已经有了答案: How can I find the time complexity of an algorithm? (10 个答案) 关闭 10 个月前。 Fibonacci 的正
是否可以通过启动多个线程来使用至强融核, 还是需要使用至强融核的特殊编程类型? 最佳答案 英特尔有一些相当不错的数学库,IPP/MKL。在至强融核似乎是一字不漏的阅读中,我想象英特尔拥有这些库的一个版
最近在研究Linux phy driver,有一些问题需要帮助。 例如:我的以太网 phy 是 Marvell Alaska 88E1548 我如何知道内核是否支持此 phy? 我在driver/ne
没那么重要,但烦人到没完没了。为什么 matlab 没有小 phi (\varphi) 符号?它几乎具有 LaTeX 提供的所有其他符号,但不是这个。为什么? 我当然可能是错的,在这种情况下,如果有人
是否可以从标准计算机以太网接口(interface)直接从物理以太网连接接口(interface)读取位? 例如,假设我想将笔记本电脑的以太网插孔用作差分逻辑探头(使用标准以太网电缆)。我是否可以潜在
当我使用命令 clang -emit-llvm -S test.c -o test.ll 时,IR 文件中没有任何“phi”指令。我怎么才能得到它? 我知道我可以使用传递“-mem2reg”或“-gv
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
我想获取 xeon phi 上字符串的所有子字符串 首先,我从 args 读取一个 txt 文件并将其存储到这样的指针数组中 char *temp_string[N_ELEMENT]; 其次,我想使用
我正在通过 Stampede 使用 Xeon Phi 解决 Collatz 猜想问题。我已经测试过我的代码,对于高达 100,000 的值可以正常工作,但是测试高达 100 万的值时,我几乎立即收
我正在使用带卸载功能的 cilk plus 在 Xeon phi 上进行一些性能测试。 在一个简单的 vector 加法程序中,我有两种方法: 使用 cilk_for 将任务拆分到 Xeon phi
我想构建一个应用程序,用户可以在其中将多个标签(字符串)分配给一个日期(YYYY-MM-DD 字符串)。主要用例是计算 Phi coefficient对于两个标签(A 和 B)的组合,需要将每个日期放
我必须在 Linux 中编写以太网 PHY 环回测试。我以前从未做过,也不知道从哪里开始。经过一番研究,我想出了测试的方案,不知道有没有人能帮我验证一下,给我一些问题的指点。 这是一个外部环回设置。它
考虑购买一对 Xeon Phi 5110P,但试图估计我需要更改多少代码或需要其他软件。 目前我善用R在多核 Windows 机器(24 核)上使用 foreach包,传递给其他包forecast ,
在 Nvidia GPU 上,我们可以通过使用 Streams 让多个内核同时运行。至强 Phi 怎么样?如果我通过不同的线程卸载两部分计算代码,它们会在至强融核上并发运行吗? 最佳答案 是的,您可以
LLVM 有 phi带有相当奇怪解释的指令: The 'phi' instruction is used to implement the φ node in the SSA graph repres
当只有一个可能的前任时,使用 phi 节点有什么好处?例如,当我运行 opt -loop- some-cool-file.ll -S , 如果我还没有添加的话,输出将经常包括一个只有一个可能的前任的
当我在计算器 Cos45 上书写时,我得到一个小数 = 0.707 如何在 C 中生成这样的数字。 我测试了这个: printf ("type a degree between 0 - 360:\n"
从这里https://software.intel.com/en-us/videos/purpose-of-the-mic-architecture我了解具有复杂或大量随机内存访问的应用程序不太适合
在修复上一个问题 (Python AttributeError:cos) 中的导入并使用 sympy 函数稍作更改后: from sympy import * from sympy import Sy
对于一个学校项目,我需要找到球形纹理贴图的 theta 和 phi。许多用于纹理的实际 OpenGL 已经完成(带有起始代码)。起始代码提供了以下功能和注释。代码是我到目前为止所做的(除了给定的 x
我是一名优秀的程序员,十分优秀!