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

eqs*_*qsf 6 r

尝试使用R中的GMM包来估计线性模型的参数(af):

LEV1 = a*Macro + b*Firm + c*Sector + d*qtr + e*fqtr + f*tax
Run Code Online (Sandbox Code Playgroud)

Macro,Firm和Sector是具有n行的矩阵.qtr,fqtr和tax是具有n个成员的向量.

我有一个名为unconstrd的大型数据框,它包含所有数据.首先,我将数据分解为单独的矩阵:

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)
Run Code Online (Sandbox Code Playgroud)

然后,我将数据绑定在一起,用于gmm调用的x变量:

h=cbind(Macro,Firm,Sector,v_qtr, v_fqtr, v_tax)
Run Code Online (Sandbox Code Playgroud)

然后,我调用gmm:

gmm1 <- gmm(v_LEV1 ~ Macro + Firm + Sector + v_qtr + v_fqtr + v_tax, x=h)
Run Code Online (Sandbox Code Playgroud)

我收到消息:

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

我提前道歉并承认我是R的初学者,我之前从未使用过GMM.GMM功能如此通用,我查看了网络上可用的示例,但似乎没有什么特别足以帮助我的情况.

Dir*_*tel 6

你试图适应一个没有完整排名的矩阵---尝试排除一些变量和/或寻找错误.没有您的数据,或者至少是样本,我们不能说更多.

这更像是Crossvalidated.com的建模问题,不是StackOverflow的编程问题.


eqs*_*qsf 3

我非常确定我的变量之间不存在线性依赖性,但我进行了一次添加一个变量的练习,以查看导致错误的原因。最后,我让同事在SAS上运行GMM,运行得很完美,没有错误信息。我不确定 R 版本的问题是什么,但此时我有一个解决方案并给你关于 R 上的 GMM 的信息。

感谢所有试图提供帮助的人。