/* TESTING LINEAR RESTRICTIONS */ /* Load Data and Define Variables */ load path=c:\gauss\classes\econ5340\; 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); rb = inv(constant'*constant)*(constant'*lnwage); urerr = lnwage - xmat*urb; rerr = lnwage - constant*rb; s2 = (urerr'*urerr)/(nobs - k); print "Unrestricted Coefficient Vector = " urb; print "Restricted Coefficient Vector = " rb; /* Testing Restriction #1 */ R1 = {0 0 0 1 0 0}; q1 = 0; F1 = (R1*urb - q1)'*inv(R1*inv(xmat'*xmat)*R1')*(R1*urb - q1)/s2; print "F statistic for Restriction #1 = " F1; /* Testing Restriction #2 */ J = k - 1; urerrsq = urerr'*urerr; rerrsq = rerr'*rerr; F2 = ((rerrsq - urerrsq)/J)/(urerrsq/(nobs - k)); print "F statistic for Restriction #2 = " F2;