简体   繁体   English

使用`gmm`(GMM Estimation)时“系统是计算奇异的”错误

[英]“system is computationally singular” error when using `gmm` (GMM Estimation)

Trying to use the GMM package in R to estimate the parameters (af) of a linear model: 尝试使用R中的GMM包来估计线性模型的参数(af):

LEV1 = a*Macro + b*Firm + c*Sector + d*qtr + e*fqtr + f*tax

Macro, Firm and Sector are matrices with n number of rows. Macro,Firm和Sector是具有n行的矩阵。 qtr, fqtr and tax are vectors with n members. qtr,fqtr和tax是具有n个成员的向量。

I have one large data frame called unconstrd that has all of the data. 我有一个名为unconstrd的大型数据框,它包含所有数据。 First, I break that data into separate matrices: 首先,我将数据分解为单独的矩阵:

v_LEV1 <- as.matrix(unconstrd$LEV1)
Macro <- as.matrix(cbind(unconstrd$Agg_Corp_Prof,unconstrd$R1000_TR, unconstrd$CP_Spread))
Firm <- as.matrix(cbind(unconstrd$ppe_ratio, unconstrd$op_inc_ratio_avg, unconstrd$selling_exp_avg,
                  unconstrd$tax_avg, unconstrd$Mark_to_Bk, unconstrd$mc_ratio))
Sector <- as.matrix(cbind(unconstrd$Sect_Flag03,
                  unconstrd$Sect_Flag04, unconstrd$Sect_Flag05, unconstrd$Sect_Flag06,
                  unconstrd$Sect_Flag07, unconstrd$Sect_Flag08, unconstrd$Sect_Flag12,
                  unconstrd$Sect_Flag13, unconstrd$Sect_Flag14, unconstrd$Sect_Flag15,
                  unconstrd$Sect_Flag17))
v_qtr <- as.matrix(unconstrd$qtr)
v_fqtr <- as.matrix(unconstrd$fqtr)
v_tax <- as.matrix(unconstrd$tax_dummy)

Then, I bind the data together for the x variable called by gmm: 然后,我将数据绑定在一起,用于gmm调用的x变量:

h=cbind(Macro,Firm,Sector,v_qtr, v_fqtr, v_tax)

Then, I invoke gmm: 然后,我调用gmm:

gmm1 <- gmm(v_LEV1 ~ Macro + Firm + Sector + v_qtr + v_fqtr + v_tax, x=h)

I get the message: 我收到消息:

Error in solve.default(crossprod(hm, xm), crossprod(hm, ym)) : 
  system is computationally singular: reciprocal condition number = 1.10214e-18

I apologize in advance and admit that I'm a neophyte at R and I've never used GMM before. 我提前道歉并承认我是R的初学者,我之前从未使用过GMM。 The GMM function is so general, I've looked at the examples available on the web but nothing seems specific enough to help my situation. GMM功能如此通用,我已经查看了网络上可用的示例,但似乎没有什么特别足以帮助我的情况。

You are trying to fit onto a matrix which does not have full rank---try excluding some of the variable and/or look for errors. 你试图适应一个没有完整排名的矩阵---尝试排除一些变量和/或寻找错误。 We cannot say much more without your data, or at least a sample. 没有您的数据,或者至少是样本,我们不能说更多。

That's more of a modelling question for Crossvalidated.com than a programming question for StackOverflow. 这更像是Crossvalidated.com的建模问题, 不是StackOverflow的编程问题。

I was pretty certain there was no linear dependency between my variables but I went through the exercise of adding one variable at a time to see what was causing the errors. 我很确定我的变量之间没有线性相关性,但我一次完成了添加一个变量的练习,以查看导致错误的原因。 In the end, I asked a colleague to run GMM on SAS and it ran perfectly, no error messages. 最后,我让一位同事在SAS上运行GMM,它运行完美,没有错误信息。 I'm not sure what the problem is with the R version is but at this point I have a solution and give u on GMM on R. 我不确定R版本的问题是什么,但此时我有一个解决方案,并在R上给你GMM。

Thanks to everyone who tried to help. 感谢所有试图提供帮助的人。

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

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