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

      name:  <unnamed>

       log:  C:\Users\mexmi\Documents\newer web pages\soc_meth_proj3\fall_2021_logs\class12.log

  log type:  text

 opened on:  27 Oct 2021, 09:39:07

 

. use "C:\Users\mexmi\Documents\current class files\intro soc methods\cps_mar_2000_new with additional vars.dta"

 

. *class starts here

 

. tabulate disabwrk disability, miss

 

                      |            disability

      Work disability |         0          1          . |     Total

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

                  NIU |         0          0     30,484 |    30,484

No disability that af |    93,260          0          0 |    93,260

Disability limits or  |         0      9,966          0 |     9,966

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

                Total |    93,260      9,966     30,484 |   133,710

 

* Reminder: the disability variable I created just takes disabwrk and replaces the missing value code with “.” Which Stata understands as the missing value code.

 

* In this brief log I ventured into making some graphs of predicted values from the logistic model predicting disability. In logistic regression often the graph tells a better story than words might.

 

. logistic disability i.sex i.race ib2.metro yrsed c.age##c.age if age>25 & age<65, coef

 

Logistic regression                                    Number of obs =  67,639

                                                       LR chi2(11)   = 3165.03

                                                       Prob > chi2   =  0.0000

Log likelihood = -17987.159                            Pseudo R2     =  0.0809

 

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

                   disability | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]

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

                          sex |

                      Female  |  -.0053214   .0285513    -0.19   0.852     -.061281    .0506382

                              |

                         race |

                 Black/Negro  |   .6057231   .0422787    14.33   0.000     .5228584    .6885878

American Indian/Aleut/Eskimo  |   .3220015   .1122286     2.87   0.004     .1020374    .5419655

   Asian or Pacific Islander  |  -.3954921   .0973523    -4.06   0.000    -.5862991    -.204685

                              |

                        metro |

            Not identifiable  |   .2903771   .2356622     1.23   0.218    -.1715123    .7522665

           Not in metro area  |   .0874893   .0411313     2.13   0.033     .0068734    .1681052

        Outside central city  |  -.2155205    .038526    -5.59   0.000    -.2910301   -.1400109

 Central city status unknown  |   .0362145   .0465509     0.78   0.437    -.0550236    .1274527

                              |

                        yrsed |  -.1416333   .0041263   -34.32   0.000    -.1497206   -.1335459

                          age |   .0661656   .0127446     5.19   0.000     .0411866    .0911445

                              |

                  c.age#c.age |   -.000151   .0001364    -1.11   0.268    -.0004183    .0001163

                              |

                        _cons |  -3.272449   .2905579   -11.26   0.000    -3.841932   -2.702966

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

 

* margins is a post-estimation command that will give us predicted values of disability at every combination of levels (here at every combination of age and race) with 95% CI. This produces a long table.

 

. margins race, over(age)

 

Predictive margins                                      Number of obs = 67,639

Model VCE: OIM

 

Expression: Pr(disability), predict()

Over:       age

 

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

                                 |            Delta-method

                                 |     Margin   std. err.      z    P>|z|     [95% conf. interval]

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

                        age#race |

                       26#White  |   .0291362   .0015358    18.97   0.000      .026126    .0321464

                 26#Black/Negro  |   .0518156   .0031305    16.55   0.000     .0456799    .0579513

26#American Indian/Aleut/Eskimo  |   .0396503   .0046113     8.60   0.000     .0306122    .0486883

   26#Asian or Pacific Islander  |     .01986    .002111     9.41   0.000     .0157225    .0239975

                       27#White  |   .0305848   .0014634    20.90   0.000     .0277166    .0334529

                 27#Black/Negro  |   .0542954   .0030586    17.75   0.000     .0483008    .0602901

27#American Indian/Aleut/Eskimo  |   .0415864    .004739     8.78   0.000      .032298    .0508747

   27#Asian or Pacific Islander  |   .0208637   .0021652     9.64   0.000     .0166199    .0251076

                       28#White  |   .0319968   .0013882    23.05   0.000     .0292759    .0347176

                 28#Black/Negro  |   .0567449   .0029944    18.95   0.000     .0508761    .0626137

28#American Indian/Aleut/Eskimo  |   .0434861   .0048745     8.92   0.000     .0339322      .05304

   28#Asian or Pacific Islander  |   .0218358   .0022203     9.83   0.000      .017484    .0261876

                       29#White  |   .0337242    .001323    25.49   0.000     .0311311    .0363173

                 29#Black/Negro  |   .0596711   .0029502    20.23   0.000     .0538888    .0654535

29#American Indian/Aleut/Eskimo  |   .0457841   .0050438     9.08   0.000     .0358984    .0556698

   29#Asian or Pacific Islander  |   .0230374   .0022986    10.02   0.000     .0185323    .0275426

                       30#White  |   .0363883   .0012882    28.25   0.000     .0338635    .0389131

                 30#Black/Negro  |    .064178    .002984    21.51   0.000     .0583295    .0700264

30#American Indian/Aleut/Eskimo  |   .0493253   .0053436     9.23   0.000      .038852    .0597986

   30#Asian or Pacific Islander  |   .0248925   .0024406    10.20   0.000     .0201091    .0296759

                       31#White  |   .0369098   .0011845    31.16   0.000     .0345882    .0392314

                 31#Black/Negro  |   .0651022   .0028879    22.54   0.000     .0594421    .0707623

31#American Indian/Aleut/Eskimo  |   .0500336   .0053733     9.31   0.000     .0395021     .060565

   31#Asian or Pacific Islander  |    .025249   .0024474    10.32   0.000     .0204521    .0300458

                       32#White  |   .0395739   .0011513    34.37   0.000     .0373174    .0418304

                 32#Black/Negro  |   .0696257   .0029481    23.62   0.000     .0638476    .0754037

32#American Indian/Aleut/Eskimo  |   .0535815   .0056849     9.43   0.000     .0424393    .0647237

   32#Asian or Pacific Islander  |   .0271003   .0025966    10.44   0.000      .022011    .0321897

                       33#White  |   .0413991   .0011022    37.56   0.000     .0392389    .0435594

                 33#Black/Negro  |   .0727883    .002967    24.53   0.000      .066973    .0786035

33#American Indian/Aleut/Eskimo  |    .056037   .0059059     9.49   0.000     .0444617    .0676124

   33#Asian or Pacific Islander  |   .0283558   .0026954    10.52   0.000     .0230729    .0336388

                       34#White  |   .0445962   .0010932    40.79   0.000     .0424536    .0467389

                 34#Black/Negro  |   .0780255   .0030397    25.67   0.000     .0720678    .0839832

34#American Indian/Aleut/Eskimo  |   .0602217   .0062642     9.61   0.000     .0479441    .0724993

   34#Asian or Pacific Islander  |   .0306145   .0028744    10.65   0.000     .0249808    .0362482

                       35#White  |   .0473475   .0010779    43.93   0.000     .0452348    .0494601

                 35#Black/Negro  |   .0825975   .0031402    26.30   0.000     .0764429    .0887521

35#American Indian/Aleut/Eskimo  |   .0638474   .0065812     9.70   0.000     .0509485    .0767463

   35#Asian or Pacific Islander  |    .032546   .0030367    10.72   0.000     .0265941    .0384978

                       36#White  |   .0501405   .0010791    46.47   0.000     .0480255    .0522555

                 36#Black/Negro  |   .0873828   .0032684    26.74   0.000      .080977    .0937887

36#American Indian/Aleut/Eskimo  |   .0675849   .0069397     9.74   0.000     .0539833    .0811865

   36#Asian or Pacific Islander  |   .0344767   .0032065    10.75   0.000      .028192    .0407613

                       37#White  |    .051982   .0010748    48.36   0.000     .0498754    .0540886

                 37#Black/Negro  |     .09035   .0033095    27.30   0.000     .0838636    .0968364

37#American Indian/Aleut/Eskimo  |   .0699757   .0071446     9.79   0.000     .0559726    .0839789

   37#Asian or Pacific Islander  |    .035788   .0033088    10.82   0.000     .0293028    .0422732

                       38#White  |   .0533723   .0010736    49.71   0.000     .0512681    .0554765

                 38#Black/Negro  |   .0928188   .0033957    27.33   0.000     .0861633    .0994742

38#American Indian/Aleut/Eskimo  |   .0718698   .0073364     9.80   0.000     .0574907     .086249

   38#Asian or Pacific Islander  |   .0367317   .0033991    10.81   0.000     .0300696    .0433939

                       39#White  |    .056669   .0011196    50.62   0.000     .0544746    .0588633

                 39#Black/Negro  |   .0982141   .0035574    27.61   0.000     .0912417    .1051864

39#American Indian/Aleut/Eskimo  |   .0761828   .0077235     9.86   0.000     .0610449    .0913206

   39#Asian or Pacific Islander  |   .0390621   .0036002    10.85   0.000     .0320058    .0461184

                       40#White  |   .0627902   .0012322    50.96   0.000     .0603752    .0652053

                 40#Black/Negro  |   .1079537   .0038236    28.23   0.000     .1004597    .1154478

40#American Indian/Aleut/Eskimo  |   .0840833   .0084038    10.01   0.000     .0676122    .1005545

   40#Asian or Pacific Islander  |   .0434445   .0039665    10.95   0.000     .0356703    .0512186

                       41#White  |   .0638476   .0012504    51.06   0.000     .0613969    .0662983

                 41#Black/Negro  |   .1099607   .0039287    27.99   0.000     .1022607    .1176608

41#American Indian/Aleut/Eskimo  |   .0855765   .0085802     9.97   0.000     .0687597    .1023934

   41#Asian or Pacific Islander  |   .0441327   .0040439    10.91   0.000     .0362068    .0520586

                       42#White  |    .067079   .0013121    51.12   0.000     .0645074    .0696507

                 42#Black/Negro  |   .1150673   .0040858    28.16   0.000     .1070593    .1230752

42#American Indian/Aleut/Eskimo  |   .0897333   .0089318    10.05   0.000     .0722273    .1072393

   42#Asian or Pacific Islander  |   .0464539   .0042398    10.96   0.000     .0381442    .0547637

                       43#White  |   .0703614   .0013809    50.95   0.000     .0676548     .073068

                 43#Black/Negro  |   .1202497    .004228    28.44   0.000      .111963    .1285364

43#American Indian/Aleut/Eskimo  |   .0939533   .0092895    10.11   0.000     .0757462    .1121603

   43#Asian or Pacific Islander  |   .0488134   .0044364    11.00   0.000     .0401181    .0575086

                       44#White  |   .0735196   .0014369    51.17   0.000     .0707034    .0763358

                 44#Black/Negro  |   .1251446   .0043825    28.56   0.000      .116555    .1337342

44#American Indian/Aleut/Eskimo  |   .0979728   .0096265    10.18   0.000     .0791051    .1168404

   44#Asian or Pacific Islander  |   .0511109   .0046218    11.06   0.000     .0420523    .0601695

                       45#White  |   .0768419    .001496    51.36   0.000     .0739097     .079774

                 45#Black/Negro  |   .1304322   .0045495    28.67   0.000     .1215153     .139349

45#American Indian/Aleut/Eskimo  |   .1022643   .0099922    10.23   0.000     .0826801    .1218486

   45#Asian or Pacific Islander  |   .0534845   .0048258    11.08   0.000     .0440261    .0629429

                       46#White  |   .0801878   .0015538    51.61   0.000     .0771425    .0832331

                 46#Black/Negro  |   .1359156   .0047322    28.72   0.000     .1266407    .1451905

46#American Indian/Aleut/Eskimo  |   .1066487   .0103896    10.26   0.000     .0862854     .127012

   46#Asian or Pacific Islander  |   .0558423    .005036    11.09   0.000     .0459718    .0657127

                       47#White  |   .0837023    .001602    52.25   0.000     .0805625    .0868421

                 47#Black/Negro  |   .1412271   .0048535    29.10   0.000     .1317145    .1507397

47#American Indian/Aleut/Eskimo  |   .1110696   .0107282    10.35   0.000     .0900427    .1320966

   47#Asian or Pacific Islander  |   .0584255   .0052339    11.16   0.000     .0481672    .0686838

                       48#White  |   .0875746   .0016564    52.87   0.000     .0843281    .0908211

                 48#Black/Negro  |   .1475587   .0050432    29.26   0.000     .1376742    .1574432

48#American Indian/Aleut/Eskimo  |   .1161428   .0111854    10.38   0.000     .0942198    .1380658

   48#Asian or Pacific Islander  |   .0611489   .0054759    11.17   0.000     .0504164    .0718814

                       49#White  |   .0912184    .001688    54.04   0.000       .08791    .0945268

                 49#Black/Negro  |   .1527887   .0051215    29.83   0.000     .1427507    .1628266

49#American Indian/Aleut/Eskimo  |   .1206095   .0114919    10.50   0.000     .0980857    .1431332

   49#Asian or Pacific Islander  |   .0638987   .0056647    11.28   0.000     .0527961    .0750014

                       50#White  |   .0961123   .0017368    55.34   0.000     .0927082    .0995164

                 50#Black/Negro  |   .1605574   .0053374    30.08   0.000     .1500964    .1710185

50#American Indian/Aleut/Eskimo  |   .1269285   .0120227    10.56   0.000     .1033644    .1504926

   50#Asian or Pacific Islander  |   .0673901   .0059618    11.30   0.000     .0557052     .079075

                       51#White  |   .1006579   .0017704    56.85   0.000     .0971879    .1041279

                 51#Black/Negro  |   .1674929   .0055066    30.42   0.000     .1567003    .1782856

51#American Indian/Aleut/Eskimo  |   .1326787   .0124718    10.64   0.000     .1082345     .157123

   51#Asian or Pacific Islander  |   .0707063   .0062234    11.36   0.000     .0585086    .0829039

                       52#White  |   .1055833   .0018104    58.32   0.000     .1020349    .1091316

                 52#Black/Negro  |   .1751472   .0057009    30.72   0.000     .1639735    .1863208

52#American Indian/Aleut/Eskimo  |   .1389699   .0129668    10.72   0.000     .1135555    .1643843

   52#Asian or Pacific Islander  |    .074261   .0065177    11.39   0.000     .0614866    .0870354

                       53#White  |   .1103685   .0018447    59.83   0.000      .106753     .113984

                 53#Black/Negro  |   .1821939   .0058667    31.06   0.000     .1706954    .1936923

53#American Indian/Aleut/Eskimo  |    .144911    .013386    10.83   0.000     .1186749     .171147

   53#Asian or Pacific Islander  |   .0778288   .0067843    11.47   0.000     .0645318    .0911258

                       54#White  |   .1202041   .0019636    61.22   0.000     .1163555    .1240527

                 54#Black/Negro  |   .1966507   .0061444    32.00   0.000     .1846079    .2086935

54#American Indian/Aleut/Eskimo  |   .1571211    .014253    11.02   0.000     .1291858    .1850565

   54#Asian or Pacific Islander  |   .0851462   .0073274    11.62   0.000     .0707848    .0995077

                       55#White  |   .1276141   .0020584    62.00   0.000     .1235797    .1316484

                 55#Black/Negro  |   .2071298   .0063832    32.45   0.000     .1946189    .2196406

55#American Indian/Aleut/Eskimo  |   .1661403   .0148239    11.21   0.000      .137086    .1951946

   55#Asian or Pacific Islander  |   .0907794   .0077337    11.74   0.000     .0756215    .1059372

                       56#White  |   .1328917   .0021776    61.03   0.000     .1286238    .1371596

                 56#Black/Negro  |   .2153072   .0066274    32.49   0.000     .2023177    .2282967

56#American Indian/Aleut/Eskimo  |   .1728806   .0153955    11.23   0.000      .142706    .2030552

   56#Asian or Pacific Islander  |   .0945764   .0080519    11.75   0.000      .078795    .1103578

                       57#White  |   .1395999   .0023434    59.57   0.000     .1350071    .1441928

                 57#Black/Negro  |   .2246018   .0069049    32.53   0.000     .2110684    .2381352

57#American Indian/Aleut/Eskimo  |   .1809549   .0159014    11.38   0.000     .1497889     .212121

   57#Asian or Pacific Islander  |   .0997462   .0084266    11.84   0.000     .0832303     .116262

                       58#White  |   .1503938   .0026495    56.76   0.000     .1452008    .1555867

                 58#Black/Negro  |   .2402677   .0073436    32.72   0.000     .2258746    .2546609

58#American Indian/Aleut/Eskimo  |   .1942938   .0168469    11.53   0.000     .1612744    .2273132

   58#Asian or Pacific Islander  |    .107783   .0090619    11.89   0.000     .0900221    .1255439

                       59#White  |   .1548894   .0029281    52.90   0.000     .1491505    .1606284

                 59#Black/Negro  |   .2467438   .0076597    32.21   0.000      .231731    .2617565

59#American Indian/Aleut/Eskimo  |   .1998296    .017286    11.56   0.000     .1659497    .2337096

   59#Asian or Pacific Islander  |     .11114   .0093554    11.88   0.000     .0928038    .1294761

                       60#White  |   .1621137   .0033307    48.67   0.000     .1555857    .1686418

                 60#Black/Negro  |   .2570016   .0080902    31.77   0.000     .2411452     .272858

60#American Indian/Aleut/Eskimo  |   .2086489   .0179467    11.63   0.000     .1734741    .2438237

   60#Asian or Pacific Islander  |    .116605   .0098046    11.89   0.000     .0973883    .1358216

                       61#White  |   .1714402   .0038294    44.77   0.000     .1639348    .1789457

                 61#Black/Negro  |   .2692025   .0085747    31.40   0.000     .2523964    .2860086

61#American Indian/Aleut/Eskimo  |   .2195731   .0186038    11.80   0.000     .1831103     .256036

   61#Asian or Pacific Islander  |   .1239699    .010352    11.98   0.000     .1036803    .1442595

                       62#White  |   .1818269   .0044742    40.64   0.000     .1730576    .1905962

                 62#Black/Negro  |   .2839796   .0093362    30.42   0.000      .265681    .3022782

62#American Indian/Aleut/Eskimo  |   .2322845   .0195918    11.86   0.000     .1938853    .2706836

   62#Asian or Pacific Islander  |   .1317758   .0110513    11.92   0.000     .1101157     .153436

                       63#White  |   .1930082   .0051641    37.38   0.000     .1828868    .2031296

                 63#Black/Negro  |    .297791   .0099591    29.90   0.000     .2782715    .3173106

63#American Indian/Aleut/Eskimo  |   .2449851   .0202723    12.08   0.000     .2052522    .2847181

   63#Asian or Pacific Islander  |     .14093   .0117012    12.04   0.000     .1179961    .1638639

                       64#White  |   .1981591   .0058617    33.81   0.000     .1866703    .2096478

                 64#Black/Negro  |   .3045623   .0106882    28.50   0.000     .2836137    .3255108

64#American Indian/Aleut/Eskimo  |   .2510348   .0208096    12.06   0.000     .2102487     .291821

   64#Asian or Pacific Islander  |   .1449857   .0121485    11.93   0.000      .121175    .1687963

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

 

* the marginsplot command turns the long table into a useful graph (which is not embedded in this text file but you can find it in the

 

. marginsplot, x(age)

 

Variables that uniquely identify margins: race age

 

 

 

 

* Now let’s try to make a graph just of the White subjects of actual versus predicted disability by age:

 

 

. by age: egen wht_disability_mean=mean(disability) if race==100

(45,376 missing values generated)

 

* The by age: egen command lets us attribute an average (within each year of age) of disability to each white person, so we can graph the averages rather than the flurry of 0’s and 1’s which would not be helpful.

 

 

. logistic disability i.sex i.race ib2.metro yrsed c.age##c.age if age>25 & age<65, coef

 

Logistic regression                                    Number of obs =  67,639

                                                       LR chi2(11)   = 3165.03

                                                       Prob > chi2   =  0.0000

Log likelihood = -17987.159                            Pseudo R2     =  0.0809

 

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

                   disability | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]

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

                          sex |

                      Female  |  -.0053214   .0285513    -0.19   0.852     -.061281    .0506382

                              |

                         race |

                 Black/Negro  |   .6057231   .0422787    14.33   0.000     .5228584    .6885878

American Indian/Aleut/Eskimo  |   .3220015   .1122286     2.87   0.004     .1020374    .5419655

   Asian or Pacific Islander  |  -.3954921   .0973523    -4.06   0.000    -.5862991    -.204685

                              |

                        metro |

            Not identifiable  |   .2903771   .2356622     1.23   0.218    -.1715123    .7522665

           Not in metro area  |   .0874893   .0411313     2.13   0.033     .0068734    .1681052

        Outside central city  |  -.2155205    .038526    -5.59   0.000    -.2910301   -.1400109

 Central city status unknown  |   .0362145   .0465509     0.78   0.437    -.0550236    .1274527

                              |

                        yrsed |  -.1416333   .0041263   -34.32   0.000    -.1497206   -.1335459

                          age |   .0661656   .0127446     5.19   0.000     .0411866    .0911445

                              |

                  c.age#c.age |   -.000151   .0001364    -1.11   0.268    -.0004183    .0001163

                              |

                        _cons |  -3.272449   .2905579   -11.26   0.000    -3.841932   -2.702966

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

 

* Now I am going to use the model to generate predicted disability averages for White people.

 

. predict wht_disab_predicted if age>25 & age<65 & race==100

(option pr assumed; Pr(disability))

(75,824 missing values generated)

 

* And here below I am using by age: egen to generate the average (at each year of age) of predicted values of disability for White people

 

. by age: egen wht_disability_predicted=mean( wht_disab_predicted ) if race==100

(75,824 missing values generated)

 

* And here below I graph the actual and predicted values together.

 

. twoway (connected wht_disability_predicted age if age>25 & age<65) (scatter wht_disability_mean age if age>25 & age<65, mcolor(dknavy) msymbol(smx))

 

* After fidgeting with the colors a little in the Stata graph editor, it looks like this:

 

 

. log close

      name:  <unnamed>

       log:  C:\Users\mexmi\Documents\newer web pages\soc_meth_proj3\fall_2021_logs\class12.log

  log type:  text

 closed on:  27 Oct 2021, 14:53:56

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