2014-10-02 36 views
1

我正在使用Rssa包來分解時間序列,巫婆工作正常,但我無法從每個特徵向量中獲得已解釋方差的百分比(如果這些是正確的單詞來解釋這一點)。但是,這些百分比在我可以用這個軟件包繪製的圖表之一的頂部標出。 讓我舉一個例子:提取百分比解釋方差在ssa結果(Rssa)

d=rnorm(200,10,3) 
plot(d,type="l") 
ssa=ssa(d, L = 100,digits=0) 
plot(ssa,type="vector") #the percentage I want is in the title of each individual graph 

# to reconstruct the trend and the residuals 
res <- reconstruct(ssa, groups = list(1)) 
trend <- res$F1 

我如何在矢量這些百分比?特別是因爲我想循環多個系列。 謝謝!

回答

2

似乎組件中加權規範的代碼隱藏在包中。 我提取Rssa:::.plot.ssa.vectors.1d.ssa代碼和包裹它的一小函數:

component_wnorm <- 
function(x) { 
    idx <- seq_len(min(nsigma(x), 10)) 
    x <- ssa 
    total <- wnorm(x)^2 
    round(100*x$sigma[idx]^2/total, digits = 2) 
} 

component_wnorm(ssa) 
[1] 92.02 0.35 0.34 0.27 0.27 0.25 0.22 0.20 0.20 0.18 

enter image description here