R_Language 板


LINE

[問題類型]: 程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來) 效能諮詢(我想讓R 跑更快) [軟體熟悉度]: 入門(寫過其他程式,只是對語法不熟悉) [問題敘述]: 最近在用rugarch pkg中的ugarchroll做模型回測 是用過去1000天的time window為建模樣本 預測隔天(t+1)的波動度 每天都會重新fit一個新的模型 圖示如下 T daily returns: |---------|--|--------| 1 t t+1 T 1000 daily returns to fit AR(1)-GARCH(1,1): |-----------| t-999 t 1-step forecast: |---| t t+1 圖如果不好理解我再做修改 假設某指數有10000天日報酬率 每天用過去1000天的moving window做1-step forecast 就會有9900筆預測值 但可能是因為這樣就要重新fit 9900次AR(1)-GARCH(1,1) 所以跑很慢 但ugarchroll裡有一個參數可以設cluster 所以我參考這個網站裡的方法: http://unstarched.net/2012/12/26/rolling-garch-forecasts/ 在本機上跑是ok的 用RStudio runApp也沒問題 速度大概快了3~4倍 但一發布到Shiny Server上就直接斷掉(網頁變成灰色) 想請問是什麼原因 或是有沒有什麼建議的替代方法 現在沒加cluster的情況下 要跑快5分鐘... [程式範例]: Server部分比較精簡 :http://pastie.org/10641054 cluster部分在server的backtest最後幾行 目前是可執行狀況 只是因為server有省略一些 所以基本上跑不出圖 若需要完整版code我再提供 沒有加cluster部分會如下網址的輸出 http://naturalsmen.shinyapps.io/shinyTry 加了cluster後 切到Backtesting頁籤會直接灰屏... 現在只是跑比較久 問題主要是「在shiny上加快ugarchroll的處理速度」 怕講太多背景會模糊掉焦點@@ 如果有需要補充什麼再請告知 謝謝各位大大<(_ _)> PS. 我一個禮拜後可能會把shiny先關掉 因為免費帳戶一個月有時數限制... 怕直接被耗光囧 [環境敘述]: R version 3.2.1 (2015-06-18) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 8 x64 (build 9200) locale: [1] LC_COLLATE=Chinese (Traditional)_Taiwan.950 LC_CTYPE=Chinese (Traditional )_ [3] LC_MONETARY=Chinese (Traditional)_Taiwan.950 LC_NUMERIC=C [5] LC_TIME=Chinese (Traditional)_Taiwan.950 attached base packages: [1] parallel stats graphics grDevices utils datasets methods base other attached packages: [1] xtable_1.7-4 rugarch_1.3-6 fExtremes_3010.81 fTrading_3010.78 [5] fGarch_3010.82 fBasics_3011.87 timeSeries_3012.99 timeDate_3012.10 0 [9] quantmod_0.4-5 TTR_0.23-0 Quandl_2.7.0 xts_0.9-7 [13] zoo_1.7-12 shiny_0.12.2 loaded via a namespace (and not attached): [1] codetools_0.2-11 digest_0.6.8 htmltools_0.2.6 [4] R6_2.1.0 SkewHyperbolic_0.3-2 expm_0.999-0 [7] DistributionUtils_0.5-1 Rsolnp_1.15 grid_3.2.1 [10] stringr_1.0.0 numDeriv_2014.2-1 httr_1.0.0 [13] GeneralizedHyperbolic_0.8-1 rgl_0.95.1429 httpuv_1.3.3 [16] lattice_0.20-31 mime_0.3 Matrix_1.2-1 [19] KernSmooth_2.23-14 rstudioapi_0.3.1 jsonlite_0.9.16 [22] rsconnect_0.4.1.4 multicool_0.1-9 spd_2.0-1 [25] stringi_0.5-5 magrittr_1.5 tools_3.2.1 [28] mvtnorm_1.0-3 truncnorm_1.0-7 ks_1.10.0 [31] nloptr_1.0.4 Rcpp_0.12.2 misc3d_0.8-4 [關鍵字]: shiny, parallel, rugarch --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.136.217
※ 文章網址: https://webptt.com/m.aspx?n=bbs/R_Language/M.1450496557.A.FB5.html
1F:→ naturalsmen: 補充:灰屏沒有顯示任何警告或錯誤訊息 12/19 11:47
2F:→ naturalsmen: 啊範例程式的ugarchroll忘了加cluster進去 晚點修改 12/19 11:57
3F:→ naturalsmen: 抱歉 12/19 11:57
4F:→ cywhale: and what you mean "data = -data()$r" ? 12/19 13:18
5F:→ cywhale: Igot "Error in -data()$r : invalid argument to unary" 12/19 13:19
6F:→ naturalsmen: cywhale: data is the DAX index loaded from 'quand 12/19 14:10
7F:→ naturalsmen: l' and r is the daily log return calculated from 12/19 14:10
8F:→ naturalsmen: the DAX data, containing Date, Open Price, Close 12/19 14:10
9F:→ naturalsmen: Price, and so on. i put them in the reactive var 12/19 14:10
10F:→ naturalsmen: iable 'data', i.e., i make a list to contain the 12/19 14:10
11F:→ naturalsmen: variables i need in 'data'. In my computer, i ca12/19 14:10
12F:→ naturalsmen: n use data()$r to call the log return in the reac12/19 14:10
13F:→ naturalsmen: tive variable 'data'. The negative sign represent12/19 14:10
14F:→ naturalsmen: s the 'negative' log return. i'll check it later,12/19 14:10
15F:→ naturalsmen: and thanks for replying:)12/19 14:10
※ 編輯: naturalsmen (42.70.107.229), 12/19/2015 15:00:33
16F:→ naturalsmen: I have just checked the problem and the data()$r 12/19 16:36
17F:→ naturalsmen: works fine as usual. Maybe u can re-confirm if t 12/19 16:36
18F:→ naturalsmen: he quandl function works. Many thanks:) 12/19 16:36
19F:推 cywhale: ya.. the issue is my fault when try and 12/19 17:30
20F:→ cywhale: It' ok to use cluster and get result on shiny-server 12/19 17:31
21F:→ cywhale: on linux, but I got troubles to deploy shinyapps.io 12/19 17:32
22F:→ cywhale: At least, I have no error runing code on shiny-server 12/19 17:32
23F:→ cywhale: (and also no error on local computer). What message 12/19 17:34
24F:→ cywhale: when your app crash and press F-12 & select "console" 12/19 17:35
25F:→ naturalsmen: Maybe I mixed up the definition of the "shiny ser 12/19 21:02
26F:→ naturalsmen: ver" and the "shiny apps.io", sorry about that. W 12/19 21:02
27F:→ naturalsmen: hat I mean "shiny server" in the article is the " 12/19 21:02
28F:→ naturalsmen: shiny apps.io". I'll fix it as soon as possible. 12/19 21:02
29F:→ naturalsmen: I can run my app locally but run into trouble on 12/19 21:02
30F:→ naturalsmen: shinyapps.io. Anyways, thanks a lot:) 12/19 21:02
31F:→ naturalsmen: I may give it a shot using your method to see if 12/19 21:04
32F:→ naturalsmen: I can get any warning message. 12/19 21:04
hey, thanks for the advice. i just got these messages: http://imgur.com/8zYVcMo ※ 編輯: naturalsmen (114.43.220.140), 12/19/2015 22:13:29
33F:推 cywhale: I deploy it:https://cywhale.shinyapps.io/test_rugarch 12/19 23:17
34F:→ cywhale: but only no error if I change code to: 12/19 23:18
35F:→ cywhale: cluster = makePSOCKcluster(4). If using (10),it crash 12/19 23:20
36F:→ cywhale: and got error: server responded with a status of 500 12/19 23:26
37F:→ naturalsmen: so maybe it's due to the constraints as a free 12/20 00:03
38F:→ naturalsmen: user? 12/20 00:04







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Soft_Job站內搜尋

TOP