* ASS5W07.DO clear capture log close log using ass5w07.txt, text replace ** Program ass5w07.do Feb 2007 for 240A ********** SETUP set more off version 9.0 ********** READ IN DATA, TRANSFORM AND SUMMARIZE * See end of program for data description * Read in data insheet using herschdataextract.csv summarize drop if _n > 150 summarize lnwage jirate exper expersq educ union nonwhite correlate lnwage jirate exper expersq educ union nonwhite regress lnwage jirate exper expersq educ union nonwhite * Here we save the OLS estimates and variance matrix matrix b = e(b)' // Transpose as Stata stores as 1xk not usual kx1 matrix V = e(V) * The following code tests that union and nonwhite are jointly zero * using the Wald test statistic * W = (Rb-r)' [RV[b]R']_inv (Rb-r)/q * Note that Stata stores the intercept as the last coefficient * Note that matrix is declared with , meaning new column and / meaning new row matrix R = (0,0,0,0,1,0,0 \ 0,0,0,0,0,1,0) matrix r = (0 \ 0) scalar q = rowsof(R) matrix W = (R*b-r)'*syminv(R*V*R')*(R*b-r)/q scalar Wald = W[1,1] scalar k = colsof(R) display "Wald test statistic: " Wald " with p-value: " Ftail(q,_N-k,Wald) * Note that easiest way to adapt this code is to use the same names as above * To reuse these names, first drop them * e.g. matrix drop R r W * e.g. scalar drop q Wald k ********** CLOSE OUTPUT log close * clear * exit