-------------------------------------------------------------------------------- log: C:\Documents and Settings\Patricia_Anderson\My Documents\ECON 20\In > Class\oct21.log log type: text opened on: 21 Oct 2002, 11:09:51 . use campus . desc Contains data from campus.dta obs: 97 vars: 7 16 May 2002 23:24 size: 2,328 (100.0% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- enroll float %9.0g total enrollment priv byte %9.0g =1 if private college police byte %9.0g employed officers crime int %9.0g total campus crimes lcrime float %9.0g log(crime) lenroll float %9.0g log(enroll) lpolice float %9.0g log(police) ------------------------------------------------------------------------------- Sorted by: . reg lcrime lpolice lenroll Source | SS df MS Number of obs = 97 -------------+------------------------------ F( 2, 94) = 80.72 Model | 115.732673 2 57.8663366 Prob > F = 0.0000 Residual | 67.3868053 94 .716880908 R-squared = 0.6320 -------------+------------------------------ Adj R-squared = 0.6242 Total | 183.119479 96 1.90749457 Root MSE = .84669 ------------------------------------------------------------------------------ lcrime | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lpolice | .5163558 .1486583 3.47 0.001 .2211913 .8115203 lenroll | .9234745 .1439888 6.41 0.000 .6375813 1.209368 _cons | -4.793824 1.112043 -4.31 0.000 -7.00181 -2.585837 ------------------------------------------------------------------------------ . **predicted crimes . predict lcrimehat (option xb assumed; fitted values) . **take the exponent . gen explcrimehat=exp(lcrimehat) . **see it's an underestimate . sum *crime* Variable | Obs Mean Std. Dev. Min Max -------------+----------------------------------------------------- crime | 97 394.4536 460.7839 1 2052 lcrime | 97 5.277149 1.381121 0 7.62657 lcrimehat | 97 5.277149 1.097975 2.847806 7.352715 explcrimehat | 97 333.0518 344.9416 17.2499 1560.427 . **let's get an estimate of how much to scale up . reg crime explcrimehat, nocons Source | SS df MS Number of obs = 97 -------------+------------------------------ F( 1, 96) = 543.60 Model | 30150863.4 1 30150863.4 Prob > F = 0.0000 Residual | 5324610.59 96 55464.6937 R-squared = 0.8499 -------------+------------------------------ Adj R-squared = 0.8483 Total | 35475474.0 97 365726.536 Root MSE = 235.51 ------------------------------------------------------------------------------ crime | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- explcrimehat | 1.165865 .0500042 23.32 0.000 1.066608 1.265123 ------------------------------------------------------------------------------ . predict crimehat (option xb assumed; fitted values) . sum *crime* Variable | Obs Mean Std. Dev. Min Max -------------+----------------------------------------------------- crime | 97 394.4536 460.7839 1 2052 lcrime | 97 5.277149 1.381121 0 7.62657 lcrimehat | 97 5.277149 1.097975 2.847806 7.352715 explcrimehat | 97 333.0518 344.9416 17.2499 1560.427 crimehat | 97 388.2936 402.1555 20.11106 1819.247 . **compare a levels model . reg crime police enroll Source | SS df MS Number of obs = 97 -------------+------------------------------ F( 2, 94) = 127.85 Model | 14903894.4 2 7451947.22 Prob > F = 0.0000 Residual | 5478995.60 94 58287.1873 R-squared = 0.7312 -------------+------------------------------ Adj R-squared = 0.7255 Total | 20382890.0 96 212321.771 Root MSE = 241.43 ------------------------------------------------------------------------------ crime | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- police | 7.570163 2.255043 3.36 0.001 3.092723 12.0476 enroll | .0244432 .0028659 8.53 0.000 .0187529 .0301335 _cons | -153.6529 42.59608 -3.61 0.000 -238.2285 -69.07744 ------------------------------------------------------------------------------ . **make a constructed R-sq for the log model . cor crimehat crime (obs=97) | crimehat crime -------------+------------------ crimehat | 1.0000 crime | 0.8597 1.0000 . **square this correlation . display .8597^2 .73908409 . use gpa1, clear . reg colGPA hsGPA skipped Source | SS df MS Number of obs = 141 -------------+------------------------------ F( 2, 138) = 19.77 Model | 4.32237812 2 2.16118906 Prob > F = 0.0000 Residual | 15.0837213 138 .109302328 R-squared = 0.2227 -------------+------------------------------ Adj R-squared = 0.2115 Total | 19.4060994 140 .138614996 Root MSE = .33061 ------------------------------------------------------------------------------ colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hsGPA | .4588039 .0876908 5.23 0.000 .2854125 .6321952 skipped | -.0774349 .0257646 -3.01 0.003 -.1283792 -.0264905 _cons | 1.579167 .3033669 5.21 0.000 .9793183 2.179015 ------------------------------------------------------------------------------ . **prediction for a B student who doesn't skip . display 1.579167 + (.4588039*3) 2.9555787 . **get the std erro . gen hsGPA3=hsGPA-3 . reg colGPA hsGPA3 skipped Source | SS df MS Number of obs = 141 -------------+------------------------------ F( 2, 138) = 19.77 Model | 4.32237812 2 2.16118906 Prob > F = 0.0000 Residual | 15.0837213 138 .109302328 R-squared = 0.2227 -------------+------------------------------ Adj R-squared = 0.2115 Total | 19.4060994 140 .138614996 Root MSE = .33061 ------------------------------------------------------------------------------ colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hsGPA3 | .4588039 .0876908 5.23 0.000 .2854125 .6321952 skipped | -.0774349 .0257646 -3.01 0.003 -.1283792 -.0264905 _cons | 2.955578 .0544325 54.30 0.000 2.847949 3.063208 ------------------------------------------------------------------------------ . reg colGPA hsGPA skipped, robust Regression with robust standard errors Number of obs = 141 F( 2, 138) = 20.90 Prob > F = 0.0000 R-squared = 0.2227 Root MSE = .33061 ------------------------------------------------------------------------------ | Robust colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hsGPA | .4588039 .0941514 4.87 0.000 .2726379 .6449698 skipped | -.0774349 .0253855 -3.05 0.003 -.1276297 -.02724 _cons | 1.579167 .3252499 4.86 0.000 .9360492 2.222285 ------------------------------------------------------------------------------ . reg colGPA hsGPA skipped Source | SS df MS Number of obs = 141 -------------+------------------------------ F( 2, 138) = 19.77 Model | 4.32237812 2 2.16118906 Prob > F = 0.0000 Residual | 15.0837213 138 .109302328 R-squared = 0.2227 -------------+------------------------------ Adj R-squared = 0.2115 Total | 19.4060994 140 .138614996 Root MSE = .33061 ------------------------------------------------------------------------------ colGPA | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hsGPA | .4588039 .0876908 5.23 0.000 .2854125 .6321952 skipped | -.0774349 .0257646 -3.01 0.003 -.1283792 -.0264905 _cons | 1.579167 .3033669 5.21 0.000 .9793183 2.179015 ------------------------------------------------------------------------------ . predict uhat, r . gen uhatsq=uhat^2 . reg uhatsq hsGPA skipped Source | SS df MS Number of obs = 141 -------------+------------------------------ F( 2, 138) = 1.63 Model | .055433464 2 .027716732 Prob > F = 0.2000 Residual | 2.34889811 138 .017021001 R-squared = 0.0231 -------------+------------------------------ Adj R-squared = 0.0089 Total | 2.40433158 140 .017173797 Root MSE = .13046 ------------------------------------------------------------------------------ uhatsq | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hsGPA | .0488627 .0346044 1.41 0.160 -.0195608 .1172861 skipped | -.0100926 .0101672 -0.99 0.323 -.0301962 .010011 _cons | -.0483981 .1197143 -0.40 0.687 -.2851097 .1883134 ------------------------------------------------------------------------------ . log close log: C:\Documents and Settings\Patricia_Anderson\My Documents\ECON 20\I > nClass\oct21.log log type: text closed on: 21 Oct 2002, 12:23:18 -------------------------------------------------------------------------------