2016-09-15 7 views
1

内のオブジェクト。どのように作成FTSは、私はこの質問はすでにここに存在していることを承知しているR

library(ftsa) 
library(fts) 

fts1 <- as.fts(data.frame(asofdate=data$date,data[,-1])) 
class(fts1) 
[1] "fts" "zoo" 

ftsm(fts1, order=3) 
Error in 1:ncol(y$y) : argument of length 0 

is.fts(fts1) 
[1] FALSE 

すべてのヘルプFALSE

私は ftsmを実行することができFTS /動物園ではなくであることを主張FTS1オブジェクトを作成することができるよ
> data 
     date GDBR2 GDBR5 GDBR10 GDBR30 
1 2015-10-15 -0.261 -0.032 0.550 1.310 
2 2015-11-15 -0.370 -0.107 0.558 1.414 
3 2015-12-15 -0.339 -0.049 0.641 1.411 
4 2016-01-15 -0.394 -0.158 0.540 1.314 
5 2016-02-15 -0.521 -0.312 0.237 0.928 
6 2016-03-15 -0.453 -0.243 0.316 1.062 
7 2016-04-15 -0.510 -0.382 0.127 0.805 
8 2016-05-15 -0.513 -0.381 0.124 0.829 
9 2016-06-15 -0.594 -0.483 -0.010 0.542 
10 2016-07-15 -0.652 -0.551 0.006 0.530 
11 2016-08-15 -0.613 -0.521 -0.074 0.433 
12 2016-09-15 -0.640 -0.478 0.047 0.654 

is.ftsとして返します:私のデータは、以下になりますftsm関数で使用するftsオブジェクトを作成することができます。データのdputここ

> dput(data) 
structure(list(date = structure(c(16723L, 16754L, 16784L, 16815L, 
16846L, 16875L, 16906L, 16936L, 16967L, 16997L, 17028L, 17059L 
), class = "Date"), GDBR2 = c(-0.261, -0.37, -0.339, -0.394, 
-0.521, -0.453, -0.51, -0.513, -0.594, -0.652, -0.613, -0.64), 
    GDBR5 = c(-0.032, -0.107, -0.049, -0.158, -0.312, -0.243, 
    -0.382, -0.381, -0.483, -0.551, -0.521, -0.478), GDBR10 = c(0.55, 
    0.558, 0.641, 0.54, 0.237, 0.316, 0.127, 0.124, -0.01, 0.006, 
    -0.074, 0.047), GDBR30 = c(1.31, 1.414, 1.411, 1.314, 0.928, 
    1.062, 0.805, 0.829, 0.542, 0.53, 0.433, 0.654)), row.names = c(NA, 
-12L), class = "data.frame", .Names = c("date", "GDBR2", "GDBR5", 
"GDBR10", "GDBR30")) 
+0

再現可能な例には、使用されるすべてのパッケージが含まれます。 – Roland

+0

あなたは絶対に正しいです – Viitama

答えて

1

クラス「FTS」を定義し、あなたは間違ったものを使用している別のパッケージがあります。

library(ftsa) 

#see the link in the documentation for the correct constructor 
fts1 <- rainbow::fts(x = data$date, y = as.matrix(data[,-1])) 

#apparently colnames must be numbers of the given frequency 
#this appears to be at least an documentation bug 
#but I know nothing about this kind of analysis 
colnames(fts1$y) <- seq_along(colnames(fts1$y)) 

ftsm(fts1, order=3) 
#Functional time series model 
# 
#Call: ftsm(y = fts1, order = 3) 
# 
#Main effects: Mean 
#Order of interaction: 3 
# y: as.matrix(data[, -1]) 
# x: data$date 
+0

ありがとう、深く掘るでしょう! – Viitama

関連する問題