* * Example from chapter 8, starting on page 199 * open data food.dat data(format=free,org=columns) 1 40 food income * linreg food # constant income * * The LINES option on SCATTER allows you to add one or more y=a+bx lines to a * scatter plot. In this case, it takes the 2-vector with the intercept and slope * from the previous LINREG. * scatter(style=dots,lines=%beta,vmin=0.0,$ footer="Figure 8.2 LS estimated expenditure function and observed data points",$ hlabel="x = weekly income in $100",vlabel="y = weekly food expenditures in $") # income food * * LINREG with ROBUST does a standard LS estimation, but with a * heteroscedasticity-robust covariance matrix. * linreg(robust) food # constant income @regconfidence(conf=.95) * * LINREG with the SPREAD option does weighted least squares with a variance series * proportional to the series given by the SPREAD option. * linreg(spread=income) food # constant income @regconfidence(conf=.95) * linreg food # constant income * * This sequence does feasible GLS. This first runs a regression of log(e^2) on the * log of income. * set esq = log(%resids^2) set z = log(income) * linreg esq # constant z * * PRJ then computes the fitted values from the above regression, which are then * "exp"ed to give the estimated variances. That constructed series is fed into * LINREG with SPREAD to correct for heteroscedasticity. * prj vhat set vhat = exp(vhat) linreg(spread=vhat) food # constant income