简体   繁体   English

当我使用 'winsorize' 时出现“系统在计算上是单一的”错误

[英]"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 .这样做的原因是在winsorizerobustHD使用了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:您可以执行以下几项操作:

  1. Remove one of the highly correlated variables and try again.删除高度相关的变量之一,然后重试。
  2. Check out a different package to use winsorize from.查看一个不同的包来使用winsorize
  3. Write your own winsorize function.编写自己的 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.

相关问题 系统是计算奇异误差 - system is computationally singular error 系统是 R 中的计算奇异错误 - System is computationally singular error in R 当鼠标返回“系统在计算上是奇异的”错误时,在 R 中进行插补 - Do imputation in R when mice returns error that “system is computationally singular” 尝试运行面板数据回归时出现错误“系统在计算上是单一的” - Error "system is computationally singular" when trying to run panel data regression 使用`gmm`(GMM Estimation)时“系统是计算奇异的”错误 - “system is computationally singular” error when using `gmm` (GMM Estimation) 计算矩阵的逆矩阵:系统是计算奇异的[错误] - Calculate the inverse of a matrix : system is computationally singular [error] Sleuth R错误:系统在计算上是奇异的 - Sleuth R Error: System is computationally singular R中的马哈洛诺比斯距离,误差:系统在计算上是奇异的 - Mahalonobis distance in R, error: system is computationally singular 错误:系统在计算上是奇异的-&gt;使用pgmm进行系统GMM回归 - Error: System is computationally singular -> Using pgmm for System GMM regression mlogit R-package中的“系统在计算上是奇异的”错误 - “system is computationally singular” error in mlogit R-package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM