私の R バージョンは 2.15.1 です。Luis Torgo による「株式市場のリターンの予測」に関するケース スタディに従っています。csv ファイルまたは Web からデータセットをインポートしようとすると、両方の方法で失敗します
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
利用可能な .RData ファイルを引き続き使用します。ただし、 T.ind 関数を実行しようとすると同じエラーが発生します
> T.ind <- function(quotes, tgt.margin = 0.025, n.days = 10) {
+ v <- apply(HLC(quotes), 1, mean)
+ r <- matrix(NA, ncol = n.days, nrow = NROW(quotes))
+ for (x in 1:n.days) r[, x] <- Next(Delt(v, k = x), x)
+ x <- apply(r, 1, function(x) sum(x[x > tgt.margin | x <
+ -tgt.margin]))
+ if (is.xts(quotes))
+ xts(x, time(quotes))
+ else x
+ }
そのため、各コマンドを 1 行ずつ手動で実行し、パラメーターをそれぞれの値に置き換えて、エラーを次の行まで追跡しました。
>xts(x,time(GSPC)) #'quote' replaced with 'GSPC'
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
驚いたことに、多くの試行錯誤の後、2 行を削除すると機能することがわかりました。:
> GSPC_new<-GSPC[-c(1073,1325),]
> x_new<-x[-c(1073,1325)]
> xts_obj<-xts(x_new,time(GSPC_new))
以前にこの現象に遭遇した人はいますか? これについて何が説明できるでしょうか?これを読んで、おそらく答えてくれてありがとう!