找回密码
 注册
查看: 319|回复: 0

R语言 sfsmisc包 nearcor()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 01:38:41 | 显示全部楼层 |阅读模式
nearcor(sfsmisc)
nearcor()所属R语言包:sfsmisc

                                        Find the Nearest Proper Correlation Matrix
                                         最近的适当的相关性矩阵

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This function smooths an improper correlation matrix as it can result from cor with use="pairwise.complete.obs" or hetcor.
此功能平滑处理不当的相关矩阵,因为它可以导致coruse="pairwise.complete.obs"或hetcor。


用法----------Usage----------


nearcor(R, eig.tol = 1e-06, conv.tol = 1e-07, posd.tol = 1e-08,
        maxits = 100, verbose = FALSE)



参数----------Arguments----------

参数:R
a square symmetric approximate correlation matrix
一个正方形的对称近似相关矩阵


参数:eig.tol
defines relative positiveness of eigenvalues compared to largest, default=1.0e-6.
定义了相对积极性的特征值相比,最大的,默认值= 1.0E-6。


参数:conv.tol
convergence tolerance for algorithm, default=1.0e-7   
收敛公差算法,默认值= 1.0E-7


参数:posd.tol
tolerance for enforcing positive definiteness, default=1.0e-8
容忍执行的正定性,默认值= 1.0E-8


参数:maxits
maximum number of iterations
最大迭代次数


参数:verbose
logical specifying if convergence monitoring should be verbose.
逻辑指定收敛监测应提供详细内容。


Details

详细信息----------Details----------

This implements the algorithm of Higham (2002), then forces symmetry, then forces positive definiteness using code from posdefify.  This implementation does not make use of direct LAPACK access for tuning purposes as in the MATLAB code of Lucas (2001).  The algorithm of Knol DL and ten Berge (1989) (not implemented here) is more general in (1) that it allows contraints to fix some rows (and columns) of the matrix and (2) to force the smallest eigenvalue to have a certain value.
这实现了,海厄姆(2002年)的算法,然后势力对称正定性,然后强制使用代码posdefify。此实现不使使用LAPACK进入调整的目的直接在MATLAB代码卢卡斯(2001年)。的算法的Knol的DL和Berge的10(1989)(此处未实现)是更一般的,在(1),它允许约束上修复的某些行(列)的矩阵,和(2)来强制的最小特征值,有一个一定的价值。


值----------Value----------

A list, with components
Alist,组件


参数:cor
resulting correlation matrix
得到的相关矩阵


参数:fnorm
Froebenius norm of difference of input and output
froebenius范数的不同的输入和输出


参数:iterations
number of iterations used
使用的迭代的数量


参数:converged
logical
逻辑


(作者)----------Author(s)----------


Jens Oehlschl盲gel



参考文献----------References----------



参见----------See Also----------

the slightly more flexible nearPD which also returns a classed matrix (class dpoMatrix); hetcor, eigen; posdefify for a simpler algorithm.
更灵活一点nearPD这也返回一个类矩阵(类dpoMatrix),“hetcor,eigenposdefify一个简单的算法。


实例----------Examples----------


cat("pr is the example matrix used in Knol DL, ten Berge (1989)\n")
pr <- matrix(c(1,     0.477, 0.644, 0.478, 0.651, 0.826,
                0.477, 1,     0.516, 0.233, 0.682, 0.75,
                0.644, 0.516, 1,     0.599, 0.581, 0.742,
                0.478, 0.233, 0.599, 1,     0.741, 0.8,
                0.651, 0.682, 0.581, 0.741, 1,     0.798,
                0.826, 0.75,  0.742, 0.8,   0.798, 1),
              nrow = 6, ncol = 6)

ncr <- nearcor(pr)
nr <- ncr$cor

plot(pr[lower.tri(pr)],
      nr[lower.tri(nr)]); abline(0,1, lty=2)
round(cbind(eigen(pr)$values, eigen(nr)$values), 8)

cat("The following will fail:\n")
try(factanal(cov=pr, factors=2))
cat("and this should work\n")
try(factanal(cov=nr, factors=2))

if(require("polycor")) {

    n <- 400
    x <- rnorm(n)
    y <- rnorm(n)

    x1 <- (x + rnorm(n))/2
    x2 <- (x + rnorm(n))/2
    x3 <- (x + rnorm(n))/2
    x4 <- (x + rnorm(n))/2

    y1 <- (y + rnorm(n))/2
    y2 <- (y + rnorm(n))/2
    y3 <- (y + rnorm(n))/2
    y4 <- (y + rnorm(n))/2

    dat <- data.frame(x1, x2, x3, x4, y1, y2, y3, y4)

    x1 <- ordered(as.integer(x1 > 0))
    x2 <- ordered(as.integer(x2 > 0))
    x3 <- ordered(as.integer(x3 > 1))
    x4 <- ordered(as.integer(x4 > -1))

    y1 <- ordered(as.integer(y1 > 0))
    y2 <- ordered(as.integer(y2 > 0))
    y3 <- ordered(as.integer(y3 > 1))
    y4 <- ordered(as.integer(y4 > -1))

    odat <- data.frame(x1, x2, x3, x4, y1, y2, y3, y4)

    xcor <- cor(dat)
    pcor &lt;- cor(data.matrix(odat)) # cor() no longer works for factors[COR()不再起作用的因素]
    hcor <- hetcor(odat, ML=TRUE, std.err=FALSE)$correlations
    ncor <- nearcor(hcor)$cor

    try(factanal(covmat=xcor, factors=2, n.obs=n))
    try(factanal(covmat=pcor, factors=2, n.obs=n))
    try(factanal(covmat=hcor, factors=2, n.obs=n))
    try(factanal(covmat=ncor, factors=2, n.obs=n))
  }

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-5-21 05:31 , Processed in 0.030084 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表