* * Example 7.2, page 220 * cal 1970 open data table7-1.prn data(format=prn,org=columns) 1970:1 1980:1 * linreg y # constant x * set logy = log(y) set logx = log(x) * linreg logy # constant logx * * Computing R**2 comparable to the linear regression * * Get fitted values for the log model and compute the adjusted residuals: * y-exp(logfit). The R**2 can be computed by taking 1 minus the ratio of the * sample variances of the adjusted residuals and the dependent variable. (The * adjusted residuals, in general, won't have a zero mean - this calculation will * use the deviations of the adjusted residuals from their mean). * prj logfit set adjresid = y-exp(logfit) stats(noprint) adjresid compute resvar=%variance stats(noprint) y disp "R**2 Adjusted" 1-resvar/%variance * * Analogous calculation, computing an R**2 for the linear regression comparable * to the one reported for the log-log regression. (The result here differs from * that cited in the text) * linreg y # constant x prj levfit set adjresid = logy-log(levfit) stats(noprint) adjresid compute resvar=%variance stats(noprint) logy disp "R**2 Adjusted" 1-resvar/%variance