I would like to use seemingly unrelated regressions to estimate a single equation repeatedly over cross-sections, but always receive the error "Error in LU.dgC(a) : cs_lu(A) failed: near-singular A (or out of memory)".
The reason is my data/setting, where each equation estimates the difference between two cross-sections (see example below).
A reproducible example to make this clear: The standard SUR works (1), then I simulate my setting, which boils down to a diff-in-diff approach (2), on which estimating equations seperately works (3), but jointly using SUR (4) gives me the error.
Any idea's on how to solve it? Or on other easy-to-implement ways to estimate this simultaneously?
1. SUR - Standard setting ==> No Error
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)
2. Adaptation of dataset to my setting
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" ) )
3. Seperate equations on my setting ==> No error
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)
4. SUR on my setting ==> Error
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 )