SAMPLE 1 40 READ (GHJ.txt) FOOD INCOME * Construct the weight variable GENR W=1/INCOME * Weighted Least Squares OLS FOOD INCOME / WEIGHT=W RESID=V0 PREDICT=YHAT0 * * Now use a manual approach to get the WLS estimates * Transform the data - normalize the weights ?STAT W / MEAN=WMEAN GENR WFOOD=FOOD*SQRT(W/WMEAN) GENR WINC=INCOME*SQRT(W/WMEAN) GENR CONST=SQRT(W/WMEAN) * Estimate the transformed model by OLS OLS WFOOD WINC CONST / NOCONSTANT RESID=V1 PREDICT=YHAT1 COEF=BETA * * Verify that the two estimation approaches give the same results * for the weighted residuals and the weighted predicted values. PRINT V0 V1 FOOD YHAT0 YHAT1 * * R-square calculation based on the original data GENR E2=V1*V1 ?STAT E2 / SUMS=WSSE ?STAT FOOD / WEIGHT=W CPDEV=WSST MEAN=YMEAN GEN1 R2 = 1 - WSSE/WSST PRINT R2 * To compute elasticities at the mean we must also use the original data. ?STAT INCOME / WEIGHT=W MEAN=XMEAN GEN1 ELAS=BETA(1)*XMEAN/YMEAN PRINT ELAS STOP