tsls.est(y,X,Z,SE=FALSE)The first-stage level of the model is given by a multivariate multiple regression. That is, this is a linear modle with a multivariate outcome variable, as well as multiple predictors. This first-stage model is represented in this manner, $$X = Z\Gamma + \Delta$$, where $X$ is the matrix of predictors from the second-stage equation, $Z$ is a matrix of instrumental variables (IVs) of order $n \times l$, $\Gamma$ is a matrix of unknown parameters of order $l\times k$; whereas $\Delta$ denotes an unknown matrix of order $n\times k$ of error terms.
Whenever certain variables in $X$ are assumed to be exogenous, these variables should be incorporated into $Z$. That is, all the exogneous variables are their own instruments. Moreover, it is also assumed that the model contains at least as many instruments as predictors, in the sense that $l\geq k$, as commonly donein practice (Wooldridge, 2002). Also, the matrices, $X^TX$, $Z^TX$, and $Z^TZ$ are all assumed to be full rank. Finally, both $X$ and $Z$ should comprise a column of one's, representing the intercept in each structural equation.
The formula for the TSLS estimator is then obtained in the standard fashion by the following equation, $$\hat\beta_{TSLS} := (\hat{X}^T\hat{X})^{-1}(\hat{X}^{T}y),$$ where $\hat{X}:=H_zX$, is the orthogonal projection of the matrix $X$, onto the vector space spanned by the columns of $Z$; and $H_{z}:=Z(Z^{T}Z)^{-1}Z^{T}$ is the hat matrix of the first-stage multivariate regression.
When requested by the user, the standard errors of each entry in $\hat\beta_{TSLS}$ are also provided, as a vector. These are computed by taking the squareroot of the diagonal entries of the sample asymptotic variance/covariance matrix, which is given by the following equation, $$\hat\Sigma_{TSLS} := \hat\sigma^{2}(\hat{X}^{T}\hat{X})^{-1},$$ in which the sample residual sum of squares is $\hat\sigma^{2}:=(y - X\hat\beta_{TSLS})^{T}(y - X\hat\beta_{TSLS})/(n-k)$.
Davidson, R. and MacKinnon, J.G. (1993). Estimation and inference in econometrics. OUP Catalogue. Wooldridge, J. (2002). Econometric analysis of cross-section and panel data. MIT press, London.
### Generate a simple example with synthetic data, and no intercept.
n <- 100; k <- 3; l <- 3;
Ga<- diag(rep(1,l)); be <- rep(1,k);
Z <- matrix(0,n,l); for(j in 1:l) Z[,j] <- rnorm(n);
X <- matrix(0,n,k); for(j in 1:k) X[,j] <- Z[,j]*Ga[j,j] + rnorm(n);
y <- X%*%be + rnorm(n);
### Compute TSLS estimator with SEs and variance/covariance matrix.
print(tsls.est(y,X,Z));
print(tsls.est(y,X,Z,SE=TRUE));Run the code above in your browser using DataLab