/* PREDICTING MALE WAGES */ /* Load Data and Define Variables */ load path=c:\gauss35\classes\econ5340\data\; load x[1001,12]=cps88.asc; data = x[2:1001,.]; age = data[.,1]; age2 = age^2; grade = data[.,3]; lnwage = data[.,6]; potexp = data[.,9]; married = data[.,5]; union1 = data[.,10]; nobs = rows(data); constant = ones(nobs,1); xmat = constant~age~age2~grade~married~union1; k = cols(xmat); /* Least Squares Estimation */ urb = inv(xmat'*xmat)*(xmat'*lnwage); urerr = lnwage - xmat*urb; s2 = (urerr'*urerr)/(nobs - k); varb = s2*inv(xmat'*xmat); /* Predicting the Wage */ xo = {1 34 1156 22 1 0}; lnwagehat = xo*urb; wagehat = exp(lnwagehat); print "Predicted ln(wage) = " lnwagehat; print "Predicted wage = " wagehat; /* Confidence Interval for the Forecast */ tcrit = 1.96; varwagehat = s2*(1+ xo*inv(xmat'*xmat)*xo'); lb = lnwagehat - tcrit*sqrt(varwagehat); ub = lnwagehat + tcrit*sqrt(varwagehat); print "Lower Bound of 95% Confidence Interval for ln(wage) = " lb; print "Upper Bound of 95% Confidence Interval for ln(wage) = " ub;