I am estimating a system of seemingly unrelated regressions (SUR) using the systemfit
package in R. Each of the equations has one unique regressor and one common regressor. I use two alternative estimation methods: ordinary least squares, OLS (method="OLS"
) and weighted least squares, WLS (method="WLS"
), as discussed in section 2.1 (p. 3-4) of the systemfit
vignette. I get the same point estimates and standard errors from both. The covariance matrices of coefficients are also identical. That puzzles me. Shouldn't the standard errors and more generally, the covariance matrices of coefficients differ?
Question: Why does systemfit
yield identical results for method="OLS"
and method="WLS"
?
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 eqations
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 - just what WLS is made for
}
data1 <- as.data.frame(cbind(y, x)) # create a data frame of all data (y and x)
# Create the model equations
eqSystem <- list()
for (i in 1:N) {
eqSystem[[i]] <-
as.formula(assign(paste0("eq", i),
value=paste0("y", i, " ~ x", i, " + dummy"))) # define linear equations of SUR
}
# Estimate the model with `method="OLS"` and `method="WLS"`
m1 <- systemfit(formula=eqSystem, method="OLS", data=data1)
m2 <- systemfit(formula=eqSystem, method="WLS", data=data1)
summary(m1, residCov=FALSE, equations=FALSE)
summary(m2, residCov=FALSE, equations=FALSE)
m1$coefCov # covariance matrix of coefficients
m2$coefCov # covariance matrix of coefficients
A follow-up question: "Why does systemfit
yield different results for OLS and WLS under cross-equation restrictions?"
eqSystem
to check what they are. There may be a typo (please let me know where), but I got the same paradoxical results with real data. This is where the question originated. I only use simulated data for reproducibility. $\endgroup$y[,i]
toy[,i]
, but it was the concise coding. You usedy[,i]
as the error to be added toy[,i]
which was confusing. (also, I am reading this from a phone so scrolling the lines is nog so easy). $\endgroup$