---------------------------------------------------------------------------------

name:  <unnamed>

> logs\class11.log

log type:  text

opened on:  27 Oct 2014, 10:47:26

. use "C:\Users\Michael\Documents\newer web pages\soc_meth_proj3\fifty_state_dataset.dta", clear

. twoway (scatter incwage  NH_White_proportion, mlabel(statefip)) (lfit incwage NH_White_proportion)

*Make a graph of state average incwage against state average white proportion.

. summarize  NH_White_proportion

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

NH_White_p~n |        51    .7626632    .1633623   .2354178   .9835737

. regress incwage  NH_White_proportion

Source |       SS       df       MS              Number of obs =      51

-------------+------------------------------           F(  1,    49) =    2.14

Model |  18878316.5     1  18878316.5           Prob > F      =  0.1500

Residual |   432407199    49  8824636.71           R-squared     =  0.0418

Total |   451285515    50   9025710.3           Root MSE      =  2970.6

----------------------------------------------------------------------------------

incwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]

-----------------+----------------------------------------------------------------

NH_White_propo~n |   -3761.36   2571.649    -1.46   0.150    -8929.282    1406.562

_cons |   22161.23   2004.928    11.05   0.000     18132.18    26190.29

----------------------------------------------------------------------------------

* This is the regression that corresponds to the line that stata put in the graph (the “lfit”)

. predict M1_predicted

(option xb assumed; fitted values)

. gen residual=incwage- M1_predicted

. gen abs_residual=abs(residual)

. gsort -abs_residual

* generate the predicted values, then the residuals, then the absolute value residuals, then sort the 51 states by the absolute value residuals from the above model.

. dfbeta( NH_White_proportion)

_dfbeta_1: dfbeta(NH_White_proportion)

* dfbetas are another post-estimation variable we can get, it tells us how each observation (in this case, each state) influences the slope line, in units of the standard error of the slope.

. gen abs_dfbeta=abs( _dfbeta_1)

. list statefip abs_residual residual  abs_dfbeta  _dfbeta_1

* First, we list the states by larges absolute value residual (our last sort):

+--------------------------------------------------------------------+

|             statefip   abs_re~l    residual   abs_df~a   _dfbeta_1 |

|--------------------------------------------------------------------|

1. |          Connecticut   5617.314    5617.314   .0487289    .0487289 |

2. |           New Jersey   5432.736    5432.736   .1172426   -.1172426 |

3. |           New Mexico   5139.932   -5139.932   .5375599    .5375599 |

4. |              Montana   5024.921   -5024.921   .2145686   -.2145686 |

5. |          Mississippi   5009.293   -5009.293   .2366829    .2366829 |

|--------------------------------------------------------------------|

6. |             Maryland   4840.275    4840.275   .1743481   -.1743481 |

7. |        West Virginia   4798.199   -4798.199   .2921322   -.2921322 |

8. |        Massachusetts   4666.598    4666.598    .098265     .098265 |

9. |             Arkansas   4460.403   -4460.403   .0185422   -.0185422 |

10. |             Colorado   4390.833    4390.833   .0056333    .0056333 |

|--------------------------------------------------------------------|

11. |         North Dakota   4204.203   -4204.203    .192666    -.192666 |

12. |            Minnesota    4187.81     4187.81   .1740437    .1740437 |

13. |               Alaska   3780.312    3780.312   .0506594   -.0506594 |

14. |            Louisiana   3555.554   -3555.554   .1484154    .1484154 |

15. |              Alabama   3416.563   -3416.563   .0482474    .0482474 |

|--------------------------------------------------------------------|

16. | District of Columbia   3381.999    3381.999   .5903278   -.5903278 |

17. |             Michigan   3208.876    3208.876   .0356351    .0356351 |

18. |        New Hampshire   3021.199    3021.199   .1813799    .1813799 |

19. |         South Dakota   2937.162   -2937.162   .1303558   -.1303558 |

20. |             Virginia   2706.413    2706.413   .0332524   -.0332524 |

|--------------------------------------------------------------------|

21. |             Illinois   2687.422    2687.422     .04929     -.04929 |

22. |           Washington   2536.313    2536.313   .0665131    .0665131 |

23. |             Oklahoma   2383.868   -2383.868   .0102179   -.0102179 |

24. |                Idaho   2289.952   -2289.952    .070259    -.070259 |

25. |             Kentucky   2257.391   -2257.391    .075205    -.075205 |

|--------------------------------------------------------------------|

26. |            Wisconsin   2079.558    2079.558   .0656909    .0656909 |

27. |       South Carolina    1986.75    -1986.75    .022419     .022419 |

28. |             Delaware   1970.206    1970.206   .0329438   -.0329438 |

29. |              Wyoming   1860.133   -1860.133   .0957266   -.0957266 |

30. |              Florida   1833.188   -1833.188   .0603009    .0603009 |

|--------------------------------------------------------------------|

31. |              Arizona    1755.73    -1755.73    .062599     .062599 |

32. |               Hawaii   1728.106   -1728.106   .3419163    .3419163 |

33. |         Rhode Island   1562.148    1562.148   .0499289    .0499289 |

34. |             Missouri   1460.693    1460.693   .0429018    .0429018 |

35. |             Nebraska     1231.4     -1231.4   .0429309   -.0429309 |

|--------------------------------------------------------------------|

36. |                 Ohio   1017.316    1017.316    .024228     .024228 |

37. |               Kansas   1001.302   -1001.302    .021283    -.021283 |

38. |             New York   998.9494    998.9494   .0335865   -.0335865 |

39. |              Georgia   939.2884   -939.2884   .0433774    .0433774 |

40. |                Texas    873.475    -873.475   .0654734    .0654734 |

|--------------------------------------------------------------------|

41. |                 Utah   544.7642   -544.7642   .0203697   -.0203697 |

42. |                Maine    536.482    -536.482   .0362305   -.0362305 |

43. |               Nevada   347.9611    347.9611   .0080656   -.0080656 |

44. |              Vermont   328.0741   -328.0741   .0203959   -.0203959 |

45. |           California   294.7873    294.7873   .0240138   -.0240138 |

|--------------------------------------------------------------------|

46. |               Oregon   241.7805    241.7805   .0072873    .0072873 |

47. |         Pennsylvania    230.294    -230.294   .0063625   -.0063625 |

48. |              Indiana   165.3883   -165.3883   .0053708   -.0053708 |

49. |            Tennessee   89.31062    89.31062   .0009869    .0009869 |

50. |       North Carolina   46.82497   -46.82497   .0009033    .0009033 |

|--------------------------------------------------------------------|

51. |                 Iowa   17.83441    17.83441   .0008664    .0008664 |

+--------------------------------------------------------------------+

. gsort - abs_dfbeta

*The we sort by absolute value dfbeta (negative sort order means largest to smallest), and list again. Note that the states with largest residuals are not the states with most influence on the slope of the line. States with most influence on the slope of the line are outliers in X, DC, New Mexico, Hawaii, W. Virginia.

. list statefip abs_dfbeta  _dfbeta_1 abs_residual residual

+--------------------------------------------------------------------+

|             statefip   abs_df~a   _dfbeta_1   abs_re~l    residual |

|--------------------------------------------------------------------|

1. | District of Columbia   .5903278   -.5903278   3381.999    3381.999 |

2. |           New Mexico   .5375599    .5375599   5139.932   -5139.932 |

3. |               Hawaii   .3419163    .3419163   1728.106   -1728.106 |

4. |        West Virginia   .2921322   -.2921322   4798.199   -4798.199 |

5. |          Mississippi   .2366829    .2366829   5009.293   -5009.293 |

|--------------------------------------------------------------------|

6. |              Montana   .2145686   -.2145686   5024.921   -5024.921 |

7. |         North Dakota    .192666    -.192666   4204.203   -4204.203 |

8. |        New Hampshire   .1813799    .1813799   3021.199    3021.199 |

9. |             Maryland   .1743481   -.1743481   4840.275    4840.275 |

10. |            Minnesota   .1740437    .1740437    4187.81     4187.81 |

|--------------------------------------------------------------------|

11. |            Louisiana   .1484154    .1484154   3555.554   -3555.554 |

12. |         South Dakota   .1303558   -.1303558   2937.162   -2937.162 |

13. |           New Jersey   .1172426   -.1172426   5432.736    5432.736 |

14. |        Massachusetts    .098265     .098265   4666.598    4666.598 |

15. |              Wyoming   .0957266   -.0957266   1860.133   -1860.133 |

|--------------------------------------------------------------------|

16. |             Kentucky    .075205    -.075205   2257.391   -2257.391 |

17. |                Idaho    .070259    -.070259   2289.952   -2289.952 |

18. |           Washington   .0665131    .0665131   2536.313    2536.313 |

19. |            Wisconsin   .0656909    .0656909   2079.558    2079.558 |

20. |                Texas   .0654734    .0654734    873.475    -873.475 |

|--------------------------------------------------------------------|

21. |              Arizona    .062599     .062599    1755.73    -1755.73 |

22. |              Florida   .0603009    .0603009   1833.188   -1833.188 |

23. |               Alaska   .0506594   -.0506594   3780.312    3780.312 |

24. |         Rhode Island   .0499289    .0499289   1562.148    1562.148 |

25. |             Illinois     .04929     -.04929   2687.422    2687.422 |

|--------------------------------------------------------------------|

26. |          Connecticut   .0487289    .0487289   5617.314    5617.314 |

27. |              Alabama   .0482474    .0482474   3416.563   -3416.563 |

28. |              Georgia   .0433774    .0433774   939.2884   -939.2884 |

29. |             Nebraska   .0429309   -.0429309     1231.4     -1231.4 |

30. |             Missouri   .0429018    .0429018   1460.693    1460.693 |

|--------------------------------------------------------------------|

31. |                Maine   .0362305   -.0362305    536.482    -536.482 |

32. |             Michigan   .0356351    .0356351   3208.876    3208.876 |

33. |             New York   .0335865   -.0335865   998.9494    998.9494 |

34. |             Virginia   .0332524   -.0332524   2706.413    2706.413 |

35. |             Delaware   .0329438   -.0329438   1970.206    1970.206 |

|--------------------------------------------------------------------|

36. |                 Ohio    .024228     .024228   1017.316    1017.316 |

37. |           California   .0240138   -.0240138   294.7873    294.7873 |

38. |       South Carolina    .022419     .022419    1986.75    -1986.75 |

39. |               Kansas    .021283    -.021283   1001.302   -1001.302 |

40. |              Vermont   .0203959   -.0203959   328.0741   -328.0741 |

|--------------------------------------------------------------------|

41. |                 Utah   .0203697   -.0203697   544.7642   -544.7642 |

42. |             Arkansas   .0185422   -.0185422   4460.403   -4460.403 |

43. |             Oklahoma   .0102179   -.0102179   2383.868   -2383.868 |

44. |               Nevada   .0080656   -.0080656   347.9611    347.9611 |

45. |               Oregon   .0072873    .0072873   241.7805    241.7805 |

|--------------------------------------------------------------------|

46. |         Pennsylvania   .0063625   -.0063625    230.294    -230.294 |

47. |             Colorado   .0056333    .0056333   4390.833    4390.833 |

48. |              Indiana   .0053708   -.0053708   165.3883   -165.3883 |

49. |            Tennessee   .0009869    .0009869   89.31062    89.31062 |

50. |       North Carolina   .0009033    .0009033   46.82497   -46.82497 |

|--------------------------------------------------------------------|

51. |                 Iowa   .0008664    .0008664   17.83441    17.83441 |

+--------------------------------------------------------------------+

. clear all

. *(8 variables, 11 observations pasted into data editor)

* Then we copied data from the Anscombe excel file into Stata, and ran some graphs.

. twoway (scatter y2 x2) (lfit y2 x2)

. twoway (scatter y1 x1) (lfit y1 x1)

. log close

name:  <unnamed>