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)?
library(gmm)
library(systemfit)
# 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)
Update:
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"
.
library(momentfit)
# 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)
summary(m1d)
m1f <- gmm4(g=ES_g, x=ES_h, type="twostep", vcov="iid", weights="optimal", cstLHS=NULL, cstRHS=NULL, data=data1)
summary(m1f)
Related:
* 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?
momentfit
package by the same author.momentfit
is supposed to replacegmm
but as of now it does not seem to be quite as mature asgmm
. 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$