* OLS Model for US Coffee Consumption * * Keywords: * regression, ols, log, coffee, r, squared * * Description: * We illustrate how to estimate Linear and Log OLS Regression Models for * US Coffee Consumption and make comparable R squared values * * Author(s): * Skif Pankov * * Source: * Damodar N. Gujarati and Dawn C. Porter, Basic Econometrics - 5th Edition * McGraw-Hill International Edition, Chapter 7, Example 7.2 (page 198) * sample 1 11 * Reading the datafile and naming the variables read(data_7.2.shd) y x * Generating logs of x and y genr lnx = log(x) genr lny = log(y) * Running an OLS regression of y on x, stating to display residual statistics and to * save predicted values into a variable py ols y x / rstat predict = py * Storing the R squared of the previous regression as rlin gen1 rlin = $r2 * Running an OLS regression of lny on lnx, stating to display residual statistics * and to save predicted values into a variable plny ols lny lnx / rstat predict = plny * Storing the R squared of the previous regression as rlog gen1 rlog = $r2 * Generating the exponent of predicted logs of coffee consumption and a log * of predicred coffee consumption genr invplny = exp(plny) genr lnpy = log(py) * Running OLS models of the actual on estimated coffee consumptions and * saving R squared ols y invplny gen1 arlog = $R2 ols lny lnpy gen1 arlin = $R2 * Displaying the values of R squared, which can be compared print rlin arlin print rlog arlog stop