Table 9.1, page 302.
use https://stats.idre.ucla.edu/stat/stata/examples/smss/crime, clear list sid state crime murder pctmetro pctwhite pcths poverty single 1. 1 ak 761 9 41.8 75.2 86.6 9.1 14.3 2. 2 al 780 11.6 67.4 73.5 66.9 17.4 11.5 3. 3 ar 593 10.2 44.7 82.9 66.3 20 10.7 4. 4 az 715 8.6 84.7 88.6 78.7 15.4 12.1 5. 5 ca 1078 13.1 96.7 79.3 76.2 18.2 12.5 6. 6 co 567 5.8 81.8 92.5 84.4 9.9 12.1 7. 7 ct 456 6.3 95.7 89 79.2 8.5 10.1 (data omitted) 48. 48 wi 264 4.4 68.1 92.1 78.6 12.6 10.4 49. 49 wv 208 6.9 41.8 96.3 66 22.2 9.4 50. 50 wy 286 3.4 29.7 95.9 83 13.3 10.8 51. 51 dc 2922 78.5 100 31.8 73.1 26.4 22.1
Figure 9.4, page 308.
graph twoway (scatter murder poverty if state ~= "md") /// (scatter murder poverty if state == "md", mlabel(state))
Table 9.2, page 310.
summarize murder poverty Variable | Obs Mean Std. Dev. Min Max -------------+----------------------------------------------------- murder | 51 8.727451 10.71758 1.6 78.5 poverty | 51 14.25882 4.584242 8 26.4 regress murder poverty Source | SS df MS Number of obs = 51 -------------+------------------------------ F( 1, 49) = 23.08 Model | 1839.06931 1 1839.06931 Prob > F = 0.0000 Residual | 3904.25223 49 79.6786169 R-squared = 0.3202 -------------+------------------------------ Adj R-squared = 0.3063 Total | 5743.32154 50 114.866431 Root MSE = 8.9263 ------------------------------------------------------------------------------ murder | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- poverty | 1.32296 .2753711 4.80 0.000 .7695805 1.876338 _cons | -10.1364 4.120616 -2.46 0.017 -18.41708 -1.855707 ------------------------------------------------------------------------------
Table 9.2, page 312.
regress murder poverty if state~="dc" Source | SS df MS Number of obs = 50 -------------+------------------------------ F( 1, 48) = 31.36 Model | 307.342297 1 307.342297 Prob > F = 0.0000 Residual | 470.406476 48 9.80013492 R-squared = 0.3952 -------------+------------------------------ Adj R-squared = 0.3826 Total | 777.748773 49 15.8724239 Root MSE = 3.1305 ------------------------------------------------------------------------------ murder | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- poverty | .5842405 .104327 5.60 0.000 .3744771 .7940039 _cons | -.8567153 1.527798 -0.56 0.578 -3.92856 2.215129 ------------------------------------------------------------------------------ predict p2 predict resid, resid sort sid list murder p2 resid in 1/6 murder p2 resid 1. 9 4.459874 4.540126 2. 11.6 9.30907 2.290931 3. 10.2 10.8281 -.6280956 4. 8.6 8.140589 .4594117 5. 13.1 9.776463 3.323538 6. 5.8 4.927266 .8727344
Figure 9.6, page 311.
graph twoway (scatter murder poverty) (lfit murder poverty) (lfit murder poverty if state ~= "dc")
Figure 9.7, page 312.
graph twoway (scatter murder poverty if state ~= "dc") (lfit murder poverty if state ~= "dc") /// (scatter murder poverty if state == "la", mlabel(state))
Example 9.9, page 325.
regress murder poverty if state~="dc" Source | SS df MS Number of obs = 50 -------------+------------------------------ F( 1, 48) = 31.36 Model | 307.342297 1 307.342297 Prob > F = 0.0000 Residual | 470.406476 48 9.80013492 R-squared = 0.3952 -------------+------------------------------ Adj R-squared = 0.3826 Total | 777.748773 49 15.8724239 Root MSE = 3.1305 ------------------------------------------------------------------------------ murder | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- poverty | .5842405 .104327 5.60 0.000 .3744771 .7940039 _cons | -.8567153 1.527798 -0.56 0.578 -3.92856 2.215129 ------------------------------------------------------------------------------
Table 9.4, page 329.
use https://stats.idre.ucla.edu/stat/stata/examples/smss/hsales, clear list price size bdrms bathrms new 1. 48.5 1.1 3 1 no 2. 55 1.01 3 2 no 3. 68 1.45 3 2 no (data omitted) 90. 150 2.04 3 3 no 91. 172.9 2.25 4 2 yes 92. 190 2.57 4 3 yes 93. 280 3.85 4 3 no
Tables 9.5 and 9.6, page 331; Example 9.11, page 332.
regress price size Source | SS df MS Number of obs = 93 -------------+------------------------------ F( 1, 91) = 382.63 Model | 145097.459 1 145097.459 Prob > F = 0.0000 Residual | 34508.4029 91 379.213218 R-squared = 0.8079 -------------+------------------------------ Adj R-squared = 0.8058 Total | 179605.862 92 1952.23763 Root MSE = 19.473 ------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- size | 75.60684 3.865208 19.56 0.000 67.92908 83.2846 _cons | -25.19356 6.68845 -3.77 0.000 -38.47935 -11.90778 ------------------------------------------------------------------------------
Figure 9.15, page 330.
graph twoway (scatter price size) (lfit price size), ylabel(0(50)300)
Table 9.7, page 335.
correlate crime murder poverty single if state~="dc" (obs=50) | crime murder poverty single -------------+------------------------------------ crime | 1.0000 murder | 0.7815 1.0000 poverty | 0.3688 0.6286 1.0000 single | 0.6487 0.7281 0.4303 1.0000 pwcorr crime murder poverty single if state~="dc", sig | crime murder poverty single -------------+------------------------------------ crime | 1.0000 | | murder | 0.7815 1.0000 | 0.0000 | poverty | 0.3688 0.6286 1.0000 | 0.0084 0.0000 | single | 0.6487 0.7281 0.4303 1.0000 | 0.0000 0.0000 0.0018