[英]"system is computationally singular" error when I use 'winsorize'
I am going to winsorize
my dataset to get rid of some outliers with the package robustHD
.我将使用包
robustHD
对我的数据集进行winsorize
以消除一些异常值。 It is the first time I ran into this error.这是我第一次遇到这个错误。 The dataset contains 50+ variables and 100+ observations.
该数据集包含 50 多个变量和 100 多个观测值。
How can I fix this?我怎样才能解决这个问题? And why matrix singularity matters for a calculation like
winsorize
?为什么矩阵奇异性对于像
winsorize
这样的计算winsorize
? Thanks.谢谢。
df_win<-winsorize(df,prob=0.95)
Error in solve.default(R) : system is computationally singular: reciprocal condition number = 1.26103e-18
The reason for this is that winsorize
in robustHD
uses solve
.这样做的原因是在
winsorize
中robustHD
使用了solve
。 If you look deeper into the code, winsorize
on a data frame calls the winsorize.data.frame
method, which is simply a script that runs as.matrix
and then uses the winsorize.matrix
method.如果你更深入的代码,
winsorize
数据帧上调用winsorize.data.frame
方法,它仅仅是运行一个脚本as.matrix
,然后使用winsorize.matrix
方法。 This in turns does a bunch of things, but the problem here is that it uses the solve
function.这反过来做了很多事情,但这里的问题是它使用了
solve
函数。
The error you get is from solve
.你得到的错误来自
solve
。 The error probably occurs because you included some variables/columns that are very highly correlated, or rather, they are linear combinations of each other.该错误可能是因为您包含了一些高度相关的变量/列,或者更确切地说,它们是彼此的线性组合。 You may want to check if you have duplicated variables or variables that are transformations of each other.
您可能想检查是否有重复的变量或相互转换的变量。
There are several things you can do:您可以执行以下几项操作:
winsorize
from.winsorize
。 The quickest way to do the second step:执行第二步的最快方法:
require(sos)
findFn("winsorize")
This will produce an overview of all functions that have the word "winsorize" in their description.这将生成在其描述中包含“winsorize”一词的所有函数的概述。 Just look for functions that are described to be used for winsorization.
只需查找描述为用于 winsorization 的函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.