我想使用看似无关的回归来重复估计横截面上的单个方程,但始终收到错误“LU.dgC中的错误(a):cs_lu(A)失败:近似单数A(或出记忆)“。
原因是我的数据/设置,其中每个等式估计两个横截面之间的差异(参见下面的示例)。
这是一个可以重现的例子: 标准SUR工作(1),然后我模拟我的设置,归结为diff-in-diff方法(2),估计方程单独工作(3),但联合使用SUR(4)给我错误
关于如何解决它的任何想法?或者以其他易于实施的方式同时估算这一点?
library ("systemfit")
library( "plm" )
library("broom")
library("data.table")
data( "GrunfeldGreene" )
GGPanel <- pdata.frame( GrunfeldGreene, c( "firm", "year" ) )
formulaGrunfeld <- invest ~ value + capital
greeneSur <- systemfit( formulaGrunfeld, "SUR",data = GGPanel,methodResidCov = "noDfCor" )
summary(greeneSur)
data( "GrunfeldGreene" )
setDT(GrunfeldGreene)
GrunfeldGreene[, dummy_time := ifelse(year>1945, 1, 0),]
GrunfeldGreene[, dummy_group := ifelse(firm=="General Motors"|firm=="Chrysler", 1, 0),]
GrunfeldGreene <- subset(GrunfeldGreene, firm!="US Steel")
GrunfeldGreene[, id := ifelse(firm=="General Motors" | firm=="General Electric", 1, 0),]
GrunfeldGreene[, id := ifelse(firm=="Chrysler" | firm=="Westinghouse", 2, id),]
GGPanel <- pdata.frame( GrunfeldGreene, c( "id", "year" ) )
GGPanel_id1 <- subset(GGPanel, id==1)
reg <- lm(invest ~ value + capital + dummy_time + dummy_group + dummy_time*dummy_group, data=GGPanel_id1)
summary(reg)
GGPanel_id2 <- subset(GGPanel, id==2)
reg <- lm(invest ~ value + capital + dummy_time + dummy_group + dummy_time*dummy_group, data=GGPanel_id2)
summary(reg)
GGPanel <- pdata.frame( GrunfeldGreene, c( "id", "year" ) )
formulaGrunfeld <- invest ~ value + capital + dummy_time + dummy_group + dummy_time*dummy_group
greeneSur2 <- systemfit( formulaGrunfeld, "SUR",data = GGPanel, methodResidCov = "noDfCor" )
summary( greeneSur2 )