* * HETERO.RPF * Estimation of linear model with heteroscedasticity * * RATS User's Guide, Example from Section 2.3. * Adapted from Hill, Griffiths, & Lim, Principles of Econometrics, 3rd edition, * 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,\$ hlabel="x = weekly income in \$100",\$ vlabel="y = weekly food expenditures in \$") # income food * * 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 with ROBUST does a standard LS estimation, but with a * heteroscedasticity-robust covariance matrix. * linreg(robust) 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 linreg(spread=exp(vhat)) food # constant income