尝试使用R中的GMM包来估计线性模型的参数(a-f):
LEV1 = a*Macro + b*Firm + c*Sector + d*qtr + e*fqtr + f*tax宏、固和扇区是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)然后,我将gmm调用的x变量的数据绑定在一起:
h=cbind(Macro,Firm,Sector,v_qtr, v_fqtr, v_tax)然后,我调用gmm:
gmm1 <- gmm(v_LEV1 ~ Macro + Firm + Sector + v_qtr + v_fqtr + v_tax, x=h)我明白了:
Error in solve.default(crossprod(hm, xm), crossprod(hm, ym)) :
system is computationally singular: reciprocal condition number = 1.10214e-18我提前道歉,并承认我是R的新手,我以前从未使用过GMM。GMM函数是如此通用,我已经查看了web上可用的示例,但似乎没有足够具体的东西来帮助我的情况。
发布于 2013-01-11 01:09:49
我非常确定我的变量之间没有线性依赖关系,但我通过一次添加一个变量的练习来查看是什么导致了错误。最后,我请一位同事在SAS上运行GMM,它运行得很好,没有错误消息。我不确定R版本的问题是什么,但在这一点上,我有一个解决方案,并在R上的GMM上给你。
感谢每一个想要帮助我的人。
发布于 2013-01-05 04:38:49
您正在尝试适合不具有满秩的矩阵-尝试排除一些变量和/或查找错误。没有你的数据,我们不能说更多,或者至少是一个样本。
这更像是Crossvalidated.com的建模问题,而不是StackOverflow的编程问题。
https://stackoverflow.com/questions/14164514
复制相似问题