[問題] 時間序列資料篩選

看板R_Language作者 (閃斌)時間6年前 (2017/12/08 10:27), 編輯推噓0(008)
留言8則, 3人參與, 6年前最新討論串1/1
[問題類型]: 請把以下不需要的部份刪除 程式諮詢(我想用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

12/08 10:54, 6年前 , 1F
不能這樣篩資料啊 你要寫x[col>=as.Date('2008-01-03') &
12/08 10:54, 1F

12/08 10:54, 6年前 , 2F
col<=as.Date('2008-12-31'),] 類似這樣的code吧?,,,
12/08 10:54, 2F

12/08 11:40, 6年前 , 3F
先感謝樓上,不過很奇怪的是garchfit 的時候,此資料
12/08 11:40, 3F

12/08 11:40, 6年前 , 4F
型態是可以的,所以我才納悶如果用此方法篩出來的資
12/08 11:40, 4F

12/08 11:40, 6年前 , 5F
料有啥不同
12/08 11:40, 5F

12/08 13:55, 6年前 , 6F
目前還無解,希望有大大能解惑
12/08 13:55, 6F

12/08 14:53, 6年前 , 7F
"2017-12-08" > "2017-12-07" ;"14:25:36" > "03:14:25"
12/08 14:53, 7F

12/08 14:54, 6年前 , 8F
也可判斷...
12/08 14:54, 8F
文章代碼(AID): #1QAVY4TQ (R_Language)