作者circusbest (閃斌)
看板R_Language
標題[問題] 時間序列資料篩選
時間Fri Dec 8 10:27:12 2017
[問題類型]:
請把以下不需要的部份刪除
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
請把以下不需要的部份刪除
入門(寫過其他程式,只是對語法不熟悉)
[問題敘述]:
資料型態為時間序列資料,如果再沒有篩選特定時間範圍資料之前,可以順利完成
dccfit,但如果篩選出特定時間範圍資料後,跑dccfit時,就會出現
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'
[程式範例]:
請把以下不需要的部份刪除
原本可執行的程式碼為
etfdatatest<-etfret
garchmode<-ugarchspec(variance.model =list(model = "gjrGARCH",garchOrder=c(1,1
)),mean.model = list(armaOrder=c(1,0), arfima = FALSE),distribution
.model = "std")
y<-dccspec(uspec=multispec(replicate(ncol(etfdatatest), garchmode)),
dccOrder = c(1,1), distribution = "mvnorm")
z<-dccfit( y, data = etfdatatest, solver=c("hybrid", "solnp"))
但如果有篩選特定資料範圍時如
etfdatatest<-etfret["2008-01-03/2008-12-31",] 時 ,就會出現上面的錯誤
但如果是篩選特定欄時,卻又可以正常執行
etfdatatest<-etfret[,colnames(etfret) %in% colnames(tenmom)]
我在想是不是資料型態的問題
[環境敘述]:
請提供 sessionInfo() 的輸出結果,
裡面含有所有你使用的作業系統、R 的版本和套件版本資訊,
讓版友更容易找出錯誤
[關鍵字]:
選擇性,也許未來有用
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.138.23.232
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1512700036.A.75A.html
→ cywhale: 不能這樣篩資料啊 你要寫x[col>=as.Date('2008-01-03') & 12/08 10:54
→ cywhale: col<=as.Date('2008-12-31'),] 類似這樣的code吧?,,, 12/08 10:54
→ circusbest: 先感謝樓上,不過很奇怪的是garchfit 的時候,此資料 12/08 11:40
→ circusbest: 型態是可以的,所以我才納悶如果用此方法篩出來的資 12/08 11:40
→ circusbest: 料有啥不同 12/08 11:40
→ circusbest: 目前還無解,希望有大大能解惑 12/08 13:55
→ wayturn: "2017-12-08" > "2017-12-07" ;"14:25:36" > "03:14:25" 12/08 14:53
→ wayturn: 也可判斷... 12/08 14:54