open data4-1 matrix y = {price} matrix X = {const, sqft} matrix XTX = X'X matrix XTXi = inv(XTX) # get beta estimates matrix B = XTXi * X'y print B # compute residuals matrix u = y - X*B print u # get ESS, uu' and sigma-hat scalar ESS = u'u print ESS matrix uu = u*u' print uu scalar s = sqrt(ESS/($nobs-rows(B))) print s # get variance of beta and standard errors matrix VB = s^2 * XTXi print VB matrix se = sqrt(diag(VB)) print se # compare the canned command ols 1 0 2 --vcv # compute robust variance matrix and SEs matrix Omega = I(14) Omega[diag] = u.^2 print Omega matrix ham = X'*Omega*X matrix VB2 = XTXi*ham*XTXi print VB2 matrix se2 = sqrt(diag(VB2)) print se2 # again compare the canned command set hc_version 0 ols 1 0 2 --robust --vcv