I am estimating a system of seemingly unrelated regressions (SUR) in R. Each of the equations has one unique regressor and one common regressor. I am using gmm::sysGmm and am experimenting with different weighting matrices. I get the same results (point estimates, standard errors and anything else that I can see (except for the value of the $J$-test) regardless of the weighting matrix. I do not think this is correct.
The phenomenon persists regardless of what type of covariance matrix estimator I use: MDS, CondHom or HAC.
It also persists regardless of whether I use unrestricted estimation or restrict the coefficients on one of the variables (the common regressor) to be equal across equations.

Question: Why does system GMM via gmm::sysGmm yield identical results for any weighting matrix? How can I make it yield proper results that vary with the weighting matrix (if that makes sense and I am not mistaken, of course)?


# Generate and prepare the data
n <- 1000 # sample size
m <- 100  # length of the "second part" of the sample
N <- 3    # number of equations
set.seed(321); x <- matrix(rnorm(n*N),ncol=N); colnames(x) <- paste0("x",1:N) # generate regressors
dummy <- c( rep(0,n-m), rep(1,m) ) # generate a common regressor
x <- cbind(x,dummy)                # include the common regressor with the rest of the regressors
set.seed(123); y <- matrix(rnorm(n*N),ncol=N); colnames(y) <- paste0("y",1:N) # a placeholder for dependent variables
for(i in 1:N){
 y[,i] <- i + sqrt(i)*x[,i] - i*dummy + y[,i]*15*sqrt(i)   
 # y[,i] is a linear function of x[,i] and dummy, 
 # plus an error term with equation-specific variance
data1 <- as.data.frame(cbind(y,x)) # create a data frame of all data (y and x)

# Create the model equations and moment conditions
ES_g = ES_h <- list() # ES ~ equation system
for(i in 1:N){
 ES_g[[i]] <- as.formula(assign(paste0("eq",i), value=paste0("y",i," ~ x",i," + dummy"))) # define linear equations of SUR
 ES_h[[i]] <- as.formula(assign(paste0("eq",i), value=paste0(       "~ x",i," + dummy"))) # define the moment conditions for GMM

# Estimate a WLS-type weighting matrix to use as a user-specified weighting matrix in GMM
m0a <- systemfit(formula=ES_g, method="OLS", data=data1) 
OLSmat <- diag(diag(m0a$residCov)); Wmat <- solve(OLSmat)

# Choose the type of covariance matrix in GMM
vc1 <- "MDS"
vc1 <- "CondHom"
vc1 <- "HAC"
#vc1 <- "TrueFixed"

# Choose between restricted and unrestricted estimation
cec1 <- NULL # unrestricted
cec1 <- 3    # restrict the coefficient on the dummy to be equal across equations

# Estimate the model with `sysGmm` using different weighting matrices: identity, "optimal" and manually specified
m1a <- sysGmm(g=ES_g, h=ES_h, wmatrix="ident"  , weightsMatrix=NULL, vcov=vc1, crossEquConst=cec1, data=data1); summary(m1a) 
m1b <- sysGmm(g=ES_g, h=ES_h, wmatrix="optimal", weightsMatrix=NULL, vcov=vc1, crossEquConst=cec1, data=data1); summary(m1b)
m1c <- sysGmm(g=ES_g, h=ES_h,                    weightsMatrix=Wmat, vcov=vc1, crossEquConst=cec1, data=data1); summary(m1c)


The author of the gmm package has kindly suggested to me to try the momentfit package instead of gmm. Unfortunately, I believe I still get the same problem under unrestricted estimation (though not under restricted one).
Consider assuming i.i.d. errors (vcov="iid") and using the optimal weighting matrix (weights="optimal"). I expect the GMM estimates from momentfit to be the same as SUR estimates from systemfit. However, I do not get that. momentfit ignores the choice of the weighting matrix (weights="optimal" yields the same result as weights="ident"). The output of momentfit suggests one-step estimation has been carried out, as the equations are just identified (Estimation: One-Step, All equations are just-identified ).
However, the system of equations is overidentified, because the explanatory variables differ between equations. The two-step SUR estimation by systemfit exploits that; compare the results from method="OLS" to method="SUR".


# The OLS vs. SUR estimates from `systemfit` are different:
#m0a <- systemfit(formula=ES_g, method="OLS", data=data1) # already done above
summary(m0a, residCov=FALSE, equations=FALSE)
m0c <- systemfit(formula=ES_g, method="SUR", data=data1)
summary(m0c, residCov=FALSE, equations=FALSE)

# The GMM estimates from `momentfit` are forced to be one-step and thus fail 
# to exploit the fact that the regressors are different in different equations. 
# The results from `weights="ident"` and `weights="optimal"` are the same.
m1d <- gmm4(g=ES_g, x=ES_h, type="twostep", vcov="iid", weights="ident"  , cstLHS=NULL, cstRHS=NULL, data=data1)
m1f <- gmm4(g=ES_g, x=ES_h, type="twostep", vcov="iid", weights="optimal", cstLHS=NULL, cstRHS=NULL, data=data1)

* Why does system GMM fail due to computationally singular system in my setup?
* SUR estimated via systemfit vs sysGmm: different standard errors
* Why does systemfit yield identical results for OLS and WLS?
* Why does systemfit yield different results for OLS and WLS under cross-equation restrictions?

  • $\begingroup$ I do not want to bother you with Hayashi again, but if each equation is just-identified then weighting does not matter (his Proposition 4.2). That said, I do not know if your moment conditions are such that each eq. is exactly identified. $\endgroup$ Apr 23 at 13:16
  • $\begingroup$ @ChristophHanck, is that so even under cross-equation restrictions? Because I find this result even under linear cross-equation restrictions. $\endgroup$ Apr 23 at 13:21
  • 1
    $\begingroup$ Indeed, cross-equation restrictions should lead to overidentification $\endgroup$ Apr 23 at 13:29
  • $\begingroup$ I have experimented with momentfit package by the same author. momentfit is supposed to replace gmm but as of now it does not seem to be quite as mature as gmm. There, I found that in some cases when I explicitly set the estimation to be two-step estimation, it still does only one step. I was thinking maybe something like that is going on here, too, but I cannot quite track what is going on. $\endgroup$ Apr 23 at 13:36

1 Answer 1


Thanks for testing the sysGmm function of my package. Since I started to work on the momentfit package, I have not done much on the gmm package. I do, however, want to fix bugs.

Your restricted model is indeed overidentified, so a different weighting matrix should produce a different result. If you let the wmatrix as is (which is set by default to "optimal"), you do get different results by changing vcov. Therefore, the following leads to three different sets of estimates:

fit1 <- sysGmm(g=ES_g, h=ES_h, vcov="MDS",     crossEquConst=cec1, data=data1) 
fit2 <- sysGmm(g=ES_g, h=ES_h, vcov="HAC",     crossEquConst=cec1, data=data1)
fit3 <- sysGmm(g=ES_g, h=ES_h, vcov="condHom", crossEquConst=cec1, data=data1)

If we set wmatrix to "ident" for any of the above fit, it should also produce a different result, which is does not. I will investigate that and update the package on RForge.


First, the problem with wmatrix not having an effect on the estimates has been fixed on the 1.9 version available on RForge. Before answering you updated question, I just want to point out that the fixed weighting matrix Wmat you create has the wrong dimension. There was no error message before the update because both wmatrix and weightsMatrix were not used by sysGmm. The following works (it is the inverse of the variance of $\{e_{1i}Z_{1i}', e_{2i}Z_{2i}', e_{2i}Z_{2i}'\}'$:

m0a <- systemfit(formula=ES_g, method="OLS", data=data1)                                                                                                                                      
e <- residuals(m0a)                                                                                                                                                                           
eZ <- cbind(model.matrix(ES_h[[1]], data1)*e[,1],                                                                                                                                             
            model.matrix(ES_h[[2]], data1)*e[,2],                                                                                                                                             
            model.matrix(ES_h[[3]], data1)*e[,3])                                                                                                                                             
Wmat <- solve(crossprod(eZ)/nrow(eZ))         

In your update, you do not estimate an SUR. You are just estimating a system of equations with all equations being just identified. That's why it is a one step estimator because the weighting matrix has no effect in just identified models. If you look at the vignette gmmS4 on page 39, you will see how to get the SUR. You just have to set the second argument to NULL. When you do, all regressors are automatically selected as instruments. You code should therefore be

m1f <- gmm4(g=ES_g, x=NULL, type="twostep", vcov="iid", weights="optimal", cstLHS=NULL, cstRHS=NULL, data=data1)

This is an SUR. I need to add this info to the main manual. In the mean time, read the section system of equations in the vignette. It is well explained.

  • $\begingroup$ By the way, if momentfit estimates the model by one-step GMM even though you ask for two-step, there must be a reason. For example, if you provide the function with a fixed weighting matrix, there is no reason to have more than one step. Same happens for just identified models. $\endgroup$ Apr 25 at 19:12
  • $\begingroup$ Thank you! I look forward to downloading and using your updated package(s). I am not sure I follow you regarding the case of unrestricted estimation, though. As I now explain in the update to my post (see Update), under optimal weights I expect two-step estimation. This is because the regressors differ between equations, so efficient estimation is two step, not one step. I illustrate this with systemfit::systemfit with options method="OLS" vs. method="SUR". So I wonder if this is some form of conceptual misunderstanding on my side rather than a bug in the code. $\endgroup$ Apr 26 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.