Stata Commands, Class #4 Eco 721

. use "K:\DATA\Eco721\rand7.dta", clear

. sum
    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        year |     20186    2.420044    1.217237          1          5
       black |     20186    .1815343    .3827365          0          1
      female |     20186    .5169424    .4997252          0          1
     educdec |     20186    11.96661    2.805737          0         25
     outpdol |     20186    51.13055    94.93485          0   2599.902
-------------+--------------------------------------------------------
     mentdol |     20186    6.871708    58.41869          0   1340.834
      inpdol |     20186    100.4893    655.6849          0   38649.81
      meddol |     20186    171.5892    698.2689          0   39182.02
       disea |     20186     11.2445    6.741647          0       58.6
      physlm |     20186    .1235247    .3220437          0          1
-------------+--------------------------------------------------------
       child |     20186    .4014168    .4901972          0          1
         lpi |     20186    4.708827    2.697293          0   7.163699
         idp |     20186    .2203012      .41446          0          1
        logc |     20186    1.709992    1.962516          0   4.564348
        fmde |     20186    3.152552    3.641392          0   8.294049
-------------+--------------------------------------------------------
       hlthg |     20186    .3620826    .4806144          0          1
       hlthf |     20186    .0772813    .2670439          0          1
       hlthp |     20186    .0149609    .1213992          0          1
     xghindx |     20186    73.23609    14.23376        3.7        100
         inc |     20186    8038.025    4058.647          1   29238.54
-------------+--------------------------------------------------------
         fam |     20186     3.95482    1.852751          1         14
         age |     20186    25.71129    16.77899          0         64

. gen lnmeddol=ln(meddol+1)

. regress  lnmeddol age black female educdec

      Source |       SS       df       MS              Number of obs =   20186
-------------+------------------------------           F(  4, 20181) =  624.41
       Model |  10161.5809     4  2540.39523           Prob > F      =  0.0000
    Residual |  82106.4545 20181  4.06850277           R-squared     =  0.1101
-------------+------------------------------           Adj R-squared =  0.1100
       Total |  92268.0354 20185  4.57111892           Root MSE      =  2.0171

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0249719   .0008519    29.31   0.000     .0233021    .0266418
       black |  -1.159347   .0386388   -30.00   0.000    -1.235083   -1.083612
      female |   .5651415   .0284844    19.84   0.000     .5093098    .6209732
     educdec |   .0229826   .0052521     4.38   0.000      .012688    .0332772
       _cons |   2.235344   .0728748    30.67   0.000     2.092503    2.378185
------------------------------------------------------------------------------

. regress  lnmeddol c.age##c.age black female educdec

      Source |       SS       df       MS              Number of obs =   20186
-------------+------------------------------           F(  5, 20180) =  512.67
       Model |  10399.3524     5  2079.87047           Prob > F      =  0.0000
    Residual |  81868.6831 20180  4.05692186           R-squared     =  0.1127
-------------+------------------------------           Adj R-squared =  0.1125
       Total |  92268.0354 20185  4.57111892           Root MSE      =  2.0142

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |    .002175   .0030969     0.70   0.483    -.0038953    .0082452
             |
 c.age#c.age |    .000391   .0000511     7.66   0.000     .0002909    .0004911
             |
       black |  -1.159794   .0385838   -30.06   0.000    -1.235422   -1.084167
      female |   .5690183   .0284483    20.00   0.000     .5132573    .6247794
     educdec |   .0273559   .0052757     5.19   0.000     .0170151    .0376966
       _cons |   2.398656   .0758333    31.63   0.000     2.250016    2.547295
------------------------------------------------------------------------------

. regress  lnmeddol c.age##c.age black female educdec if female==1
note: female omitted because of collinearity

      Source |       SS       df       MS              Number of obs =   10435
-------------+------------------------------           F(  4, 10430) =  394.62
       Model |   6173.2239     4  1543.30597           Prob > F      =  0.0000
    Residual |   40789.938 10430  3.91082819           R-squared     =  0.1314
-------------+------------------------------           Adj R-squared =  0.1311
       Total |  46963.1619 10434  4.50097392           Root MSE      =  1.9776

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0508255   .0042481    11.96   0.000     .0424983    .0591526
             |
 c.age#c.age |  -.0002909   .0000692    -4.21   0.000    -.0004265   -.0001554
             |
       black |  -1.125687    .051313   -21.94   0.000     -1.22627   -1.025104
      female |  (omitted)
     educdec |   .0368272   .0076622     4.81   0.000      .021808    .0518465
       _cons |   2.230214   .1075148    20.74   0.000     2.019465    2.440964
------------------------------------------------------------------------------

. regress  lnmeddol c.age##c.age black female educdec if female==0
note: female omitted because of collinearity

      Source |       SS       df       MS              Number of obs =    9751
-------------+------------------------------           F(  4,  9746) =  229.73
       Model |  3761.48081     4  940.370204           Prob > F      =  0.0000
    Residual |  39893.9499  9746   4.0933665           R-squared     =  0.0862
-------------+------------------------------           Adj R-squared =  0.0858
       Total |  43655.4307  9750  4.47748008           Root MSE      =  2.0232

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |  -.0473015   .0044656   -10.59   0.000    -.0560549   -.0385481
             |
 c.age#c.age |   .0010969   .0000747    14.68   0.000     .0009505    .0012434
             |
       black |  -1.204053   .0575074   -20.94   0.000     -1.31678   -1.091327
      female |  (omitted)
     educdec |   .0227443   .0071978     3.16   0.002      .008635    .0368535
       _cons |   3.057828   .1022575    29.90   0.000     2.857382    3.258274
------------------------------------------------------------------------------

. regress  lnmeddol c.age##c.age black female c.educdec#i.female

      Source |       SS       df       MS              Number of obs =   20186
-------------+------------------------------           F(  6, 20179) =  428.21
       Model |  10421.1266     6  1736.85444           Prob > F      =  0.0000
    Residual |  81846.9088 20179  4.05604385           R-squared     =  0.1129
-------------+------------------------------           Adj R-squared =  0.1127
       Total |  92268.0354 20185  4.57111892           Root MSE      =   2.014

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0022255   .0030967     0.72   0.472    -.0038442    .0082953
             |
 c.age#c.age |   .0003911   .0000511     7.66   0.000      .000291    .0004913
             |
       black |   -1.15749   .0385925   -29.99   0.000    -1.233134   -1.081845
      female |   .2874579   .1248057     2.30   0.021     .0428286    .5320872
             |
      female#|
   c.educdec |
          0  |   .0166744   .0070057     2.38   0.017     .0029426    .0304061
          1  |   .0402001   .0076523     5.25   0.000      .025201    .0551992
             |
       _cons |   2.525801    .093599    26.99   0.000     2.342339    2.709263
------------------------------------------------------------------------------

. regress  lnmeddol c.age##c.age black female educdec c.educdec#i.female

      Source |       SS       df       MS              Number of obs =   20186
-------------+------------------------------           F(  6, 20179) =  428.21
       Model |  10421.1266     6  1736.85444           Prob > F      =  0.0000
    Residual |  81846.9088 20179  4.05604385           R-squared     =  0.1129
-------------+------------------------------           Adj R-squared =  0.1127
       Total |  92268.0354 20185  4.57111892           Root MSE      =   2.014

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0022255   .0030967     0.72   0.472    -.0038442    .0082953
             |
 c.age#c.age |   .0003911   .0000511     7.66   0.000      .000291    .0004913
             |
       black |   -1.15749   .0385925   -29.99   0.000    -1.233134   -1.081845
      female |   .2874579   .1248057     2.30   0.021     .0428286    .5320872
     educdec |   .0166744   .0070057     2.38   0.017     .0029426    .0304061
             |
      female#|
   c.educdec |
          1  |   .0235257   .0101536     2.32   0.021     .0036237    .0434276
             |
       _cons |   2.525801    .093599    26.99   0.000     2.342339    2.709263
------------------------------------------------------------------------------

. regress  lnmeddol c.age##c.age black female educdec

      Source |       SS       df       MS              Number of obs =   20186
-------------+------------------------------           F(  5, 20180) =  512.67
       Model |  10399.3524     5  2079.87047           Prob > F      =  0.0000
    Residual |  81868.6831 20180  4.05692186           R-squared     =  0.1127
-------------+------------------------------           Adj R-squared =  0.1125
       Total |  92268.0354 20185  4.57111892           Root MSE      =  2.0142

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |    .002175   .0030969     0.70   0.483    -.0038953    .0082452
             |
 c.age#c.age |    .000391   .0000511     7.66   0.000     .0002909    .0004911
             |
       black |  -1.159794   .0385838   -30.06   0.000    -1.235422   -1.084167
      female |   .5690183   .0284483    20.00   0.000     .5132573    .6247794
     educdec |   .0273559   .0052757     5.19   0.000     .0170151    .0376966
       _cons |   2.398656   .0758333    31.63   0.000     2.250016    2.547295
------------------------------------------------------------------------------

. regress  lnmeddol i.age black female educdec

      Source |       SS       df       MS              Number of obs =   20186
-------------+------------------------------           F( 67, 20118) =   43.55
       Model |  11686.8085    67  174.429978           Prob > F      =  0.0000
    Residual |  80581.2269 20118  4.00542931           R-squared     =  0.1267
-------------+------------------------------           Adj R-squared =  0.1238
       Total |  92268.0354 20185  4.57111892           Root MSE      =  2.0014

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |
          1  |  -.2492624   .1733156    -1.44   0.150    -.5889751    .0904504
          2  |   -.608198   .1732404    -3.51   0.000    -.9477635   -.2686326
          3  |  -.7658004   .1722628    -4.45   0.000     -1.10345   -.4281513
          4  |  -.8717943   .1711414    -5.09   0.000    -1.207246   -.5363431
          5  |  -.8700001   .1701614    -5.11   0.000     -1.20353   -.5364699
          6  |  -.9939977   .1687638    -5.89   0.000    -1.324788   -.6632069
          7  |  -1.185262   .1671842    -7.09   0.000    -1.512956   -.8575669
          8  |  -1.242488   .1671828    -7.43   0.000    -1.570179   -.9147956
          9  |  -1.206133    .167028    -7.22   0.000    -1.533522   -.8787446
         10  |  -1.295357   .1674403    -7.74   0.000    -1.623554   -.9671604
         11  |  -1.315568   .1678137    -7.84   0.000    -1.644497   -.9866398
         12  |  -1.193345   .1678768    -7.11   0.000    -1.522398    -.864293
         13  |  -1.179381   .1678427    -7.03   0.000    -1.508366   -.8503954
         14  |   -.946547   .1671718    -5.66   0.000    -1.274217   -.6188766
         15  |  -1.067461    .167072    -6.39   0.000    -1.394936   -.7399864
         16  |   -.926286   .1677468    -5.52   0.000    -1.255083   -.5974886
         17  |  -.8433831   .1689951    -4.99   0.000    -1.174627   -.5121389
         18  |  -.6640284   .1714867    -3.87   0.000    -1.000156   -.3279005
         19  |  -.7674016   .1748789    -4.39   0.000    -1.110179   -.4246246
         20  |  -.7433817   .1790784    -4.15   0.000     -1.09439   -.3923734
         21  |  -.7187727    .183907    -3.91   0.000    -1.079246      -.3583
         22  |  -.5245395   .1825649    -2.87   0.004    -.8823817   -.1666972
         23  |  -.4136782   .1818174    -2.28   0.023    -.7700553   -.0573011
         24  |  -.4026362   .1800603    -2.24   0.025    -.7555692   -.0497031
         25  |   -.431097   .1763837    -2.44   0.015    -.7768235   -.0853705
         26  |  -.4532923   .1720594    -2.63   0.008    -.7905427   -.1160418
         27  |  -.5834966   .1706248    -3.42   0.001    -.9179352    -.249058
         28  |  -.5929105   .1713696    -3.46   0.001     -.928809   -.2570121
         29  |  -.4324236   .1700356    -2.54   0.011    -.7657073   -.0991399
         30  |   -.488074   .1710028    -2.85   0.004    -.8232536   -.1528945
         31  |   -.418645   .1718321    -2.44   0.015    -.7554499   -.0818401
         32  |  -.3837224   .1728793    -2.22   0.026    -.7225799   -.0448648
         33  |  -.4575651   .1734915    -2.64   0.008    -.7976225   -.1175076
         34  |  -.2269231   .1751532    -1.30   0.195    -.5702377    .1163915
         35  |   -.428515   .1768695    -2.42   0.015    -.7751938   -.0818363
         36  |   -.386375   .1785307    -2.16   0.030    -.7363099   -.0364401
         37  |  -.2052891   .1794656    -1.14   0.253    -.5570564    .1464782
         38  |  -.3224677   .1829336    -1.76   0.078    -.6810326    .0360972
         39  |   -.385791   .1841321    -2.10   0.036    -.7467051   -.0248769
         40  |  -.4357506   .1888729    -2.31   0.021    -.8059571   -.0655442
         41  |  -.5045162   .1941511    -2.60   0.009    -.8850684   -.1239641
         42  |  -.1772562   .1970379    -0.90   0.368    -.5634666    .2089543
         43  |  -.1523871   .1968036    -0.77   0.439    -.5381382     .233364
         44  |   -.118148   .1987129    -0.59   0.552    -.5076415    .2713456
         45  |   .1673818   .2012923     0.83   0.406    -.2271676    .5619311
         46  |   .0080932   .2004856     0.04   0.968     -.384875    .4010614
         47  |   .2600414   .2005154     1.30   0.195    -.1329851     .653068
         48  |   .2417977    .202433     1.19   0.232    -.1549876     .638583
         49  |   .0298166   .2041479     0.15   0.884    -.3703301    .4299632
         50  |   .1693368   .2018648     0.84   0.402    -.2263347    .5650084
         51  |   .4958145   .2021346     2.45   0.014     .0996141    .8920149
         52  |   .5843385    .201351     2.90   0.004      .189674    .9790031
         53  |    .331307   .2005409     1.65   0.099    -.0617696    .7243836
         54  |    .680365   .1980415     3.44   0.001     .2921874    1.068543
         55  |    .407978   .1985238     2.06   0.040     .0188551    .7971009
         56  |   .3899584   .2019459     1.93   0.053     -.005872    .7857889
         57  |    .251681   .2033961     1.24   0.216    -.1469919     .650354
         58  |   -.139513   .2094707    -0.67   0.505    -.5500927    .2710667
         59  |   .3058383   .2097863     1.46   0.145    -.1053599    .7170366
         60  |   .2857576   .2127162     1.34   0.179    -.1311836    .7026987
         61  |   .2463408   .2171663     1.13   0.257    -.1793229    .6720044
         62  |   .3645515   .2275714     1.60   0.109    -.0815071    .8106102
         63  |   .5180205   .2731681     1.90   0.058    -.0174114    1.053452
         64  |   1.790573   .4691828     3.82   0.000     .8709361    2.710209
             |
       black |  -1.166894   .0384115   -30.38   0.000    -1.242184   -1.091605
      female |   .5590283   .0283164    19.74   0.000     .5035259    .6145307
     educdec |    .021351   .0053429     4.00   0.000     .0108786    .0318235
       _cons |   3.434798   .1563338    21.97   0.000     3.128371    3.741226
------------------------------------------------------------------------------

. tab age

     age in |
      years |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        204        1.01        1.01
          1 |        385        1.91        2.92
          2 |        386        1.91        4.83
          3 |        399        1.98        6.81
          4 |        415        2.06        8.86
          5 |        430        2.13       10.99
          6 |        453        2.24       13.24
          7 |        482        2.39       15.62
          8 |        482        2.39       18.01
          9 |        485        2.40       20.42
         10 |        477        2.36       22.78
         11 |        470        2.33       25.11
         12 |        469        2.32       27.43
         13 |        470        2.33       29.76
         14 |        483        2.39       32.15
         15 |        485        2.40       34.55
         16 |        472        2.34       36.89
         17 |        450        2.23       39.12
         18 |        411        2.04       41.16
         19 |        367        1.82       42.98
         20 |        323        1.60       44.58
         21 |        283        1.40       45.98
         22 |        293        1.45       47.43
         23 |        299        1.48       48.91
         24 |        314        1.56       50.47
         25 |        350        1.73       52.20
         26 |        403        2.00       54.20
         27 |        424        2.10       56.30
         28 |        413        2.05       58.34
         29 |        434        2.15       60.49
         30 |        419        2.08       62.57
         31 |        407        2.02       64.58
         32 |        392        1.94       66.53
         33 |        384        1.90       68.43
         34 |        364        1.80       70.23
         35 |        345        1.71       71.94
         36 |        328        1.62       73.57
         37 |        319        1.58       75.15
         38 |        290        1.44       76.58
         39 |        281        1.39       77.97
         40 |        250        1.24       79.21
         41 |        222        1.10       80.31
         42 |        209        1.04       81.35
         43 |        210        1.04       82.39
         44 |        202        1.00       83.39
         45 |        192        0.95       84.34
         46 |        195        0.97       85.31
         47 |        195        0.97       86.27
         48 |        188        0.93       87.20
         49 |        182        0.90       88.11
         50 |        190        0.94       89.05
         51 |        189        0.94       89.98
         52 |        192        0.95       90.93
         53 |        195        0.97       91.90
         54 |        205        1.02       92.92
         55 |        203        1.01       93.92
         56 |        190        0.94       94.86
         57 |        185        0.92       95.78
         58 |        166        0.82       96.60
         59 |        165        0.82       97.42
         60 |        157        0.78       98.20
         61 |        146        0.72       98.92
         62 |        125        0.62       99.54
         63 |         73        0.36       99.90
         64 |         20        0.10      100.00
------------+-----------------------------------
      Total |     20,186      100.00

. regress  lnmeddol c.age##c.age black female educdec c.educdec#i.female

      Source |       SS       df       MS              Number of obs =   20186
-------------+------------------------------           F(  6, 20179) =  428.21
       Model |  10421.1266     6  1736.85444           Prob > F      =  0.0000
    Residual |  81846.9088 20179  4.05604385           R-squared     =  0.1129
-------------+------------------------------           Adj R-squared =  0.1127
       Total |  92268.0354 20185  4.57111892           Root MSE      =   2.014

------------------------------------------------------------------------------
    lnmeddol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0022255   .0030967     0.72   0.472    -.0038442    .0082953
             |
 c.age#c.age |   .0003911   .0000511     7.66   0.000      .000291    .0004913
             |
       black |   -1.15749   .0385925   -29.99   0.000    -1.233134   -1.081845
      female |   .2874579   .1248057     2.30   0.021     .0428286    .5320872
     educdec |   .0166744   .0070057     2.38   0.017     .0029426    .0304061
             |
      female#|
   c.educdec |
          1  |   .0235257   .0101536     2.32   0.021     .0036237    .0434276
             |
       _cons |   2.525801    .093599    26.99   0.000     2.342339    2.709263
------------------------------------------------------------------------------

. sum educdec

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     educdec |     20186    11.96661    2.805737          0         25

. twoway function y = 2.525801 +.2874579 + .0235257 * x, range(0 25)

.

No comments: