/* COMPARISON OF SIMULTANEOUS EQUATION ESTIMATION TECHNIQUES */ /* Load Data */ load path = c:\gauss8.0\classes\econ5360\data\; load data[229,5] = macro2.txt; /* Define Variables */ y = data[2:229,1]; g = data[2:229,2]; i = data[2:229,3]; nx = data[2:229,4]; c = data[2:229,5]; nobs = rows(c); constant = ones(nobs,1); xmat = constant~y; k = cols(xmat); /* ************** */ /* OLS Estimation */ /* ************** */ b = inv(xmat'*xmat)*(xmat'*c); resids = c - xmat*b; s2 = (resids'*resids)/(nobs - k); varb = s2*inv(xmat'*xmat); tols = b ./ diag(sqrt(varb)); print "OLS Estimates tstats"; print b~tols; print; /* *************** */ /* 2SLS Estimation */ /* *************** */ wmat = constant~i~g~nx; yhat = wmat*inv(wmat'*wmat)*(wmat'*y); zmat = constant~yhat; betahat = inv(zmat'*zmat)*(zmat'*C); resids = c - xmat*betahat; sigma2hat = (1/nobs)*(resids'*resids); varbetahat = sigma2hat*inv(zmat'*zmat); t2sls = betahat ./ diag(sqrt(varbetahat)); print "2SLS Estimates tstats"; print betahat~t2sls; print;