Learn R Programming

gmm (version 1.4-2)

tsls: Two stage least squares estimation

Description

Function to estimate a linear model by the two stage least squares method.

Usage

tsls(g,x,data)

Arguments

g
A formula describing the linear regression model (see details below).
x
The matrix of instruments (see details below).
data
A data.frame or a matrix with column names (Optionnal).

Value

  • 'tsls' returns an object of 'class' '"tsls"' which inherits from class '"gmm"'.

    The functions 'summary' is used to obtain and print a summary of the results. It also compute the J-test of overidentying restriction

    The object of class "gmm" is a list containing at least:

  • coefficients$k\times 1$ vector of coefficients
  • residualsthe residuals, that is response minus fitted values if "g" is a formula.
  • fitted.valuesthe fitted mean values if "g" is a formula.
  • vcovthe covariance matrix of the coefficients
  • objectivethe value of the objective function $\| var(\bar{g})^{-1/2}\bar{g}\|^2$
  • termsthe terms object used when g is a formula.
  • callthe matched call.
  • yif requested, the response used (if "g" is a formula).
  • xif requested, the model matrix used if "g" is a formula or the data if "g" is a function.
  • modelif requested (the default), the model frame used if "g" is a formula.
  • algoInfoInformation produced by either optim or nlminb related to the convergence if "g" is a function. It is printed by the summary.gmm method.

Details

The function just calls gmm with the option vcov="iid". It just simplifies the the implementation of 2SLS. The users don't have to worry about all the options offered in gmm. The model is $$Y_i = X_i\beta + u_i$$ In the first step, lm is used to regress $X_i$ on the set of instruments $Z_i$. The second step also uses lm to regress $Y_i$ on the fitted values of the first step.

References

Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators. Econometrica, 50, 1029-1054,

Examples

Run this code
n <- 1000
e <- arima.sim(n,model=list(ma=.9))
C <- runif(n,0,5)
Y <- rep(0,n)
Y[1] = 1 + 2*C[1] + e[1]
for (i in 2:n){
Y[i] = 1 + 2*C[i] + 0.9*Y[i-1] + e[i]
}
Yt <- Y[5:n]
X <- cbind(C[5:n],Y[4:(n-1)])
Z <- cbind(C[5:n],Y[3:(n-2)],Y[2:(n-3)],Y[1:(n-4)]) 

res <- tsls(Yt~X,~Z)
res

Run the code above in your browser using DataLab