繁体   English   中英

在R中的RSSA包中访问特征值

[英]accessing eigenvalues in RSSA package in R

我在R中使用RSSA包,并且需要访问特征值。

使用以下代码,我可以绘制组件。 但是,我需要以数字形式访问所有特征值。

require(Rssa)
t=ssa(co2)
plot(t)

特征值图

我对此包裹几乎一无所知。 我是从上下文中获取的,您需要在该图形的y轴上绘制的值。 缺少可复制的示例,我转到?ssa帮助页面并使用第一个示例:

> s <- ssa(co2)
> 
> plot(s)

这样看起来就像您的情节:然后我看一下代码

> getAnywhere(plot.ssa)
A single object matching ‘plot.ssa’ was found
It was found in the following places
  registered S3 method for plot from namespace Rssa
  namespace:Rssa
with value

function (x, type = c("values", "vectors", "paired", "series", 
    "wcor"), ..., vectors = c("eigen", "factor"), plot.contrib = TRUE, 
    numvalues = nsigma(x), numvectors = min(nsigma(x), 10), idx = 1:numvectors, 
    idy, groups) 
{
    type <- match.arg(type)
    vectors <- match.arg(vectors)
    if (identical(type, "values")) {
        .plot.ssa.values(x, ..., numvalues = numvalues)
    }
    else if (identical(type, "vectors")) {
        .plot.ssa.vectors(x, ..., what = vectors, plot.contrib = plot.contrib, 
            idx = idx)
    }
    else if (identical(type, "paired")) {
        if (missing(idy)) 
            idy <- idx + 1
        .plot.ssa.paired(x, ..., what = vectors, plot.contrib = plot.contrib, 
            idx = idx, idy = idy)
    }
    else if (identical(type, "series")) {
        if (missing(groups)) 
            groups <- as.list(1:min(nsigma(x), nu(x)))
        .plot.ssa.series(x, ..., groups = groups)
    }
    else if (identical(type, "wcor")) {
        if (missing(groups)) 
            groups <- as.list(1:min(nsigma(x), nu(x)))
        plot(wcor(x, groups = groups), ...)
    }
    else {
        stop("Unsupported type of SSA plot!")
    }
}
<environment: namespace:Rssa>

因此,接下来我看一下使用默认参数时调用的函数:

> getAnywhere(.plot.ssa.values)
A single object matching ‘.plot.ssa.values’ was found
It was found in the following places
  namespace:Rssa
with value

function (x, ..., numvalues, plot.type = "b") 
{
    dots <- list(...)
    d <- data.frame(A = 1:numvalues, B = x$sigma[1:numvalues])
    dots <- .defaults(dots, type = plot.type, xlab = "Index", 
        ylab = "norms", main = "Component norms", grid = TRUE, 
        scales = list(y = list(log = TRUE)), par.settings = list(plot.symbol = list(pch = 20)))
    do.call("xyplot", c(list(x = B ~ A, data = d, ssaobj = x), 
        dots))
}
<environment: namespace:Rssa>

因此,答案似乎是:

s$sigma
 [1] 78886.190749   329.031810   327.198387   184.659743    88.695271    88.191805
 [7]    52.380502    40.527875    31.329930    29.409384    27.157698    22.334446
[13]    17.237926    14.175096    14.111402    12.976716    12.943775    12.216524
[19]    11.830642    11.614243    11.226010    10.457529    10.435998     9.774000
[25]     9.710220     9.046872     8.995923     8.928725     8.809155     8.548962
[31]     8.358872     7.699094     7.266915     7.243014     7.164837     6.203210
[37]     6.085105     6.064150     6.035110     6.028446     5.845783     5.808865
[43]     5.770708     5.753422     5.680897     5.672330     5.650324     5.612606
[49]     5.599314     5.572931

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM