Re: [問題] 迴圈不會跑...
: [程式範例]:
: garch <- garchFit(~garch(1,1),data=r.ts, trace=F)
: magarch <- garchFit(~arma(0,1)+garch(1,1),data=r.ts, trace=F)
: resgarch <-residuals(garch)
: resmagarch <-residuals(magarch)
: resgarch2 <-resgarch^2
: resmagarch2 <-resmagarch^2
把result用list存起來即可,之後要看在一抓出來慢慢看
resgarch.res.l = as.list(NULL)
resmagarch.res.l = as.list(NULL)
resgarch2.res.l = as.list(NULL)
resmagarch2.res.l = as.list(NULL)
for (i in 1:20) {
resgarch.res.l[[i]] = Box.test(resgarch, lag = i, type = "Ljung-Box")
resmagarch.res.l[[i]] = Box.test(resmagarch, lag = i, type = "Ljung-Box")
resgarch2.res.l[[i]] = Box.test(resgarch2, lag = i, type = "Ljung-Box")
resmagarch2.res.l[[i]] = Box.test(resmagarch2, lag = i, type = "Ljung-Box")
}
: [關鍵字]:
: Box.test, Ljung-Box, for loop, GARCH
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.152.191
→
06/18 20:00, , 1F
06/18 20:00, 1F
討論串 (同標題文章)
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章