* * Example HETER.DAT from pp 430-433 * open data heter.dat data(format=free,org=columns) 1 50 mo x1 x2 y * scatter(hlabel="X1",vlabel="Y") # x1 y scatter(hlabel="X2",vlabel="Y") # x2 y * linreg y # constant x1 x2 * scatter(footer="Figure 10-19 Heteroscedasticity of residuals for X1 using OLS",hlabel="X1",vlabel="Residuals") # x1 %resids * * Weighted least squares is done with LINREG with the option SPREAD=series to * which variances are assumed proportional. Here, that's the square of x1. Note * that the "weighting" is all done internally. * linreg(spread=x1**2) y # constant x1 x2 * * However, the residuals are in the natural scale, so they have to be scaled to * get figure 10-20. * set uscaled = %resids/x1 * scatter(footer="Figure 10-20 Residuals vs X1 with weighted least squares",hlabel="X1",vlabel="Residuals") # x1 uscaled