-------------------------------------------------------------------- log: choice_binary_revised.log log type: text opened on: 26 Sep 2007, 01:21:59 . use choice_binary.dta . set more off . . list job age school gender +-----------------------------+ | job age school gender | |-----------------------------| 1. | 1 31 16 0 | 2. | 1 34 14 1 | 3. | 1 41 16 1 | 4. | 0 67 9 0 | 5. | 1 25 12 0 | |-----------------------------| 6. | 0 58 12 1 | 7. | 1 45 14 0 | 8. | 1 55 10 0 | 9. | 0 43 12 0 | 10. | 1 55 8 0 | |-----------------------------| 11. | 1 25 11 0 | 12. | 1 41 14 0 | 13. | 0 62 12 1 | 14. | 1 51 13 1 | 15. | 0 39 9 1 | |-----------------------------| 16. | 1 35 10 0 | 17. | 1 40 14 1 | 18. | 0 43 10 1 | 19. | 0 37 12 1 | 20. | 1 27 13 0 | |-----------------------------| 21. | 1 28 14 0 | 22. | 1 48 12 1 | 23. | 0 66 7 1 | 24. | 0 44 11 1 | 25. | 0 21 12 1 | |-----------------------------| 26. | 1 40 10 1 | 27. | 1 41 15 0 | 28. | 0 23 10 1 | 29. | 0 31 11 1 | 30. | 1 44 12 1 | +-----------------------------+ . . regress job age school gender Source | SS df MS Number of obs = 30 -------------+------------------------------ F( 3, 26) = 4.96 Model | 2.62055889 3 .87351963 Prob > F = 0.0075 Residual | 4.57944111 26 .17613235 R-squared = 0.3640 -------------+------------------------------ Adj R-squared = 0.2906 Total | 7.2 29 .248275862 Root MSE = .41968 --------------------------------------------------------------------------- job | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -.0009682 .0066986 -0.14 0.886 -.0147373 .012801 school | .0911182 .0375996 2.42 0.023 .0138312 .1684052 gender | -.3803107 .1562374 -2.43 0.022 -.7014612 -.0591602 _cons | -.2227047 .6153338 -0.36 0.720 -1.487541 1.042132 ------------------------------------------------------------------------------ . predict p_lpm, xb . . regress job age school gender, robust Regression with robust standard errors Number of obs = 30 F( 3, 26) = 10.49 Prob > F = 0.0001 R-squared = 0.3640 Root MSE = .41968 --------------------------------------------------------------------------- | Robust job | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -.0009682 .0064178 -0.15 0.881 -.0141601 .0122237 school | .0911182 .030241 3.01 0.006 .028957 .1532795 gender | -.3803107 .1616239 -2.35 0.026 -.7125334 -.0480881 _cons | -.2227047 .5294223 -0.42 0.677 -1.310948 .8655384 --------------------------------------------------------------------------- . . logit job age school gender Iteration 0: log likelihood = -20.19035 Iteration 1: log likelihood = -14.08727 Iteration 2: log likelihood = -13.333675 Iteration 3: log likelihood = -13.246511 Iteration 4: log likelihood = -13.244612 Iteration 5: log likelihood = -13.244611 Logit estimates Number of obs = 30 LR chi2(3) = 13.89 Prob > chi2 = 0.0031 Log likelihood = -13.244611 Pseudo R2 = 0.3440 --------------------------------------------------------------------------- job | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -.0098882 .0389641 -0.25 0.800 -.0862564 .06648 school | .6741644 .3215752 2.10 0.036 .0438886 1.30444 gender | -2.608477 1.199745 -2.17 0.030 -4.959935 -.2570198 _cons | -5.266331 4.120738 -1.28 0.201 -13.34283 2.810168 --------------------------------------------------------------------------- . predict p_logit, p . mfx compute Marginal effects after logit y = Pr(job) (predict) = .69517648 ------------------------------------------------------------- variable | dy/dx Std. Err. z P>|z| X ---------+--------------------------------------------------- age | -.0020954 .00821 -0.26 0.799 41.3333 school | .1428596 .06298 2.27 0.023 11.8333 gender*| -.4849757 .16352 -2.97 0.003 .566667 ------------------------------------------------------------- (*) dy/dx is for discrete change of dummy variable from 0 to 1 . *dlogit2 job age school gender . . logistic job age school gender Logistic regression Number of obs = 30 LR chi2(3) = 13.89 Prob > chi2 = 0.0031 Log likelihood = -13.244611 Pseudo R2 = 0.3440 -------------------------------------------------------------------------- job | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+------------------------------------------------------------ age | .9901606 .0385807 -0.25 0.800 .917359 1.06874 school | 1.962392 .6310567 2.10 0.036 1.044866 3.685625 gender | .0736466 .0883572 -2.17 0.030 .0070134 .7733529 -------------------------------------------------------------------------- . predict p_logistic, p . mfx compute Marginal effects after logistic y = Pr(job) (predict) = .69517648 ------------------------------------------------------------ variable | dy/dx Std. Err. z P>|z| X ---------+-------------------------------------------------- age | -.0020954 .00821 -0.26 0.799 41.3333 school | .1428596 .06298 2.27 0.023 11.8333 gender*| -.4849757 1.19975 -0.40 0.686 .566667 ------------------------------------------------------------ (*) dy/dx is for discrete change of dummy variable from 0 to 1 . . probit job age school gender Iteration 0: log likelihood = -20.19035 Iteration 1: log likelihood = -13.937494 Iteration 2: log likelihood = -13.305501 Iteration 3: log likelihood = -13.267639 Iteration 4: log likelihood = -13.26742 Probit estimates Number of obs = 30 LR chi2(3) = 13.85 Prob > chi2 = 0.0031 Log likelihood = -13.26742 Pseudo R2 = 0.3429 --------------------------------------------------------------------------- job | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -.0061331 .0237865 -0.26 0.797 -.0527538 .0404876 school | .3869652 .1759277 2.20 0.028 .0421532 .7317773 gender | -1.45382 .6299747 -2.31 0.021 -2.688547 -.2190919 _cons | -3.047916 2.399211 -1.27 0.204 -7.750285 1.654452 --------------------------------------------------------------------------- . predict p_probit, p . mfx compute Marginal effects after probit y = Pr(job) (predict) = .67502799 ------------------------------------------------------------ variable | dy/dx Std. Err. z P>|z| X ---------+-------------------------------------------------- age | -.0022073 .00854 -0.26 0.796 41.3333 school | .1392695 .06012 2.32 0.021 11.8333 gender*| -.4692287 .16282 -2.88 0.004 .566667 ------------------------------------------------------------ (*) dy/dx is for discrete change of dummy variable from 0 to 1 . *dprobit job age school gender . . list p_lpm p_probit p_logit p_logistic +-------------------------------------------+ | p_lpm p_probit p_logit p_logi~c | |-------------------------------------------| 1. | 1.205173 .9984285 .9945883 .9945883 | 2. | .6397215 .7602951 .7733448 .7733448 | 3. | .8151807 .9248186 .9245898 .9245898 | 4. | .532491 .5095153 .5346048 .5346048 | 5. | .8465095 .9253966 .9293296 .9293296 | |-------------------------------------------| 6. | .4342487 .4153232 .4113591 .4113591 | 7. | 1.009382 .9818525 .9765006 .9765006 | 8. | .6352275 .6859546 .7173721 .7173721 | 9. | .8290821 .9085606 .9167091 .9167091 | 10. | .452991 .3860938 .3972671 .3972671 | |-------------------------------------------| 11. | .7553912 .8543728 .8701486 .8701486 | 12. | 1.013255 .9829184 .9773914 .9773914 | 13. | .4303759 .4057835 .4018164 .4018164 | 14. | .5321442 .5855156 .5950862 .5950862 | 15. | .1792894 .1041526 .1003838 .1003838 | |-------------------------------------------| 16. | .6545911 .7281004 .7556962 .7556962 | 17. | .6339124 .7487157 .7627772 .7627772 | 18. | .266535 .185178 .1738827 .1738827 | 19. | .4545805 .4660999 .4623967 .4623967 | 20. | .9356914 .9653944 .961978 .961978 | |-------------------------------------------| 21. | 1.025841 .9860208 .9800642 .9800642 | 22. | .4439305 .4393799 .4354945 .4354945 | 23. | -.029088 .013983 .0217048 .0217048 | 24. | .356685 .3032854 .2902687 .2902687 | 25. | .4700715 .5052068 .5018782 .5018782 | |-------------------------------------------| 26. | .2694395 .1901327 .1781852 .1781852 | 27. | 1.104373 .9938793 .9883499 .9883499 | 28. | .2858986 .2197184 .204144 .204144 | 29. | .3692714 .3316926 .3174461 .3174461 | 30. | .4478032 .4490708 .4452417 .4452417 | +-------------------------------------------+ . . * WLS . . gen sigi = sqrt(p_lpm*(1-p_lpm)) (6 missing values generated) . gen job1 = job/sigi (6 missing values generated) . gen age1 = age/sigi (6 missing values generated) . gen school1 = school/sigi (6 missing values generated) . gen gender1 = gender/sigi (6 missing values generated) . gen sigi_inv = 1/sigi (6 missing values generated) . . regress job1 age1 school1 gender1 sigi_inv, noconst Source | SS df MS Number of obs = 24 -------------+------------------------------ F( 4, 20) = 12.50 Model | 53.56152 4 13.39038 Prob > F = 0.0000 Residual | 21.4168641 20 1.0708432 R-squared = 0.7144 -------------+------------------------------ Adj R-squared = 0.6572 Total | 74.9783841 24 3.12409934 Root MSE = 1.0348 --------------------------------------------------------------------------- job1 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age1 | -.0021052 .0080463 -0.26 0.796 -.0188894 .014679 school1 | .1128579 .0529995 2.13 0.046 .0023028 .223413 gender1 | -.401973 .1913488 -2.10 0.049 -.8011197 -.0028263 sigi_inv | -.4112543 .7492448 -0.55 0.589 -1.974151 1.151643 --------------------------------------------------------------------------- . . regress job age school gender [aw = 1/sigi] (sum of wgt is 5.4335e+01) Source | SS df MS Number of obs = 24 -------------+------------------------------ F( 3, 20) = 2.51 Model | 1.62003772 3 .540012574 Prob > F = 0.0876 Residual | 4.29587769 20 .214793884 R-squared = 0.2738 -------------+------------------------------ Adj R-squared = 0.1649 Total | 5.91591541 23 .257213713 Root MSE = .46346 --------------------------------------------------------------------------- job | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -.0014612 .0080317 -0.18 0.857 -.018215 .0152926 school | .1148828 .0557078 2.06 0.052 -.0013215 .2310871 gender | -.4295052 .2035091 -2.11 0.048 -.8540177 -.0049927 _cons | -.4355718 .7657082 -0.57 0.576 -2.032811 1.161667 --------------------------------------------------------------------------- . wls0 job age school gender, wvar(sigi) type(abse) noconst graph (6 missing values generated) WLS regression - type: proportional to abs(e) (sum of wgt is 6.1313e+01) Source | SS df MS Number of obs = 24 -------------+------------------------------ F( 3, 20) = 2.51 Model | 1.62003773 3 .540012577 Prob > F = 0.0876 Residual | 4.29587767 20 .214793883 R-squared = 0.2738 -------------+------------------------------ Adj R-squared = 0.1649 Total | 5.9159154 23 .257213713 Root MSE = .46346 --------------------------------------------------------------------------- job | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -.0014612 .0080317 -0.18 0.857 -.018215 .0152926 school | .1148828 .0557078 2.06 0.052 -.0013215 .2310871 gender | -.4295052 .2035091 -2.11 0.048 -.8540177 -.0049927 _cons | -.4355718 .7657082 -0.57 0.576 -2.032811 1.161667 --------------------------------------------------------------------------- . wls0 job age school gender, wvar(sigi) type(e2) noconst graph (6 missing values generated) WLS regression - type: proportional to e^2 (sum of wgt is 1.2977e+02) Source | SS df MS Number of obs = 24 -------------+------------------------------ F( 3, 20) = 2.51 Model | 1.6200377 3 .540012566 Prob > F = 0.0876 Residual | 4.2958777 20 .214793885 R-squared = 0.2738 -------------+------------------------------ Adj R-squared = 0.1649 Total | 5.9159154 23 .257213713 Root MSE = .46346 --------------------------------------------------------------------------- job | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -.0014612 .0080317 -0.18 0.857 -.018215 .0152926 school | .1148828 .0557078 2.06 0.052 -.0013216 .2310871 gender | -.4295052 .2035091 -2.11 0.048 -.8540177 -.0049927 _cons | -.4355718 .7657082 -0.57 0.576 -2.032811 1.161667 --------------------------------------------------------------------------- . . . /* WLS: example of Greene chapter 12 */ . . use http://www.ats.ucla.edu/stat/stata/examples/greene/TBL5-1, clear . . rename x1 age . rename x2 income . rename x3 exp . rename x4 ownrent . rename x5 selfemp . . generate incomesq = income^2 . drop if exp==0 (28 observations deleted) . save chapter12, replace file chapter12.dta saved . . /* summary check */ . . gen age1 = age / income^0.5 . gen income1 = income / income^0.5 . gen exp1 = exp / income^0.5 . gen ownrent1 = ownrent / income^0.5 . gen selfemp1 = selfemp / income^0.5 . gen incomesq1 = incomesq / income^0.5 . gen const1 = 1 / income^0.5 . . wls0 exp age ownrent income incomesq , wvar(income) type(abse) noconst /* 12.3a */ WLS regression - type: proportional to abs(e) (sum of wgt is 5.7161e-01) Source | SS df MS Number of obs = 72 -------------+------------------------------ F( 4, 67) = 5.73 Model | 1266234.75 4 316558.686 Prob > F = 0.0005 Residual | 3703808.1 67 55280.7179 R-squared = 0.2548 -------------+------------------------------ Adj R-squared = 0.2103 Total | 4970042.85 71 70000.6035 Root MSE = 235.12 --------------------------------------------------------------------------- exp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -2.935011 4.603331 -0.64 0.526 -12.1233 6.253276 ownrent | 50.49364 69.87914 0.72 0.472 -88.9857 189.973 income | 202.1694 76.78152 2.63 0.010 48.91285 355.426 incomesq | -12.11364 8.27314 -1.46 0.148 -28.62689 4.39962 _cons | -181.8706 165.5191 -1.10 0.276 -512.2481 148.5068 --------------------------------------------------------------------------- . regress exp age ownrent income incomesq [aw = 1/income] (sum of wgt is 2.4956e+01) Source | SS df MS Number of obs = 72 -------------+------------------------------ F( 4, 67) = 5.73 Model | 1266234.79 4 316558.697 Prob > F = 0.0005 Residual | 3703808.18 67 55280.719 R-squared = 0.2548 -------------+------------------------------ Adj R-squared = 0.2103 Total | 4970042.96 71 70000.6051 Root MSE = 235.12 --------------------------------------------------------------------------- exp | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age | -2.935011 4.603331 -0.64 0.526 -12.1233 6.253276 ownrent | 50.49364 69.87914 0.72 0.472 -88.9857 189.973 income | 202.1694 76.78152 2.63 0.010 48.91285 355.426 incomesq | -12.11364 8.27314 -1.46 0.148 -28.62689 4.39962 _cons | -181.8706 165.5191 -1.10 0.276 -512.2481 148.5068 --------------------------------------------------------------------------- . regress exp1 age1 ownrent1 income1 incomesq1 const1, noconstant Source | SS df MS Number of obs = 72 -------------+------------------------------ F( 5, 67) = 15.84 Model | 1518004.77 5 303600.953 Prob > F = 0.0000 Residual | 1283774.35 67 19160.8111 R-squared = 0.5418 -------------+------------------------------ Adj R-squared = 0.5076 Total | 2801779.11 72 38913.5988 Root MSE = 138.42 --------------------------------------------------------------------------- exp1 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age1 | -2.935011 4.603331 -0.64 0.526 -12.1233 6.253275 ownrent1 | 50.49365 69.87914 0.72 0.472 -88.9857 189.973 income1 | 202.1694 76.78152 2.63 0.010 48.91284 355.426 incomesq1 | -12.11364 8.27314 -1.46 0.148 -28.62689 4.399621 const1 | -181.8706 165.5191 -1.10 0.276 -512.2481 148.5068 --------------------------------------------------------------------------- . regress exp1 age1 ownrent1 income1 incomesq1 Source | SS df MS Number of obs = 72 -------------+------------------------------ F( 4, 67) = 2.83 Model | 216096.606 4 54024.1516 Prob > F = 0.0313 Residual | 1279473.4 67 19096.6179 R-squared = 0.1445 -------------+------------------------------ Adj R-squared = 0.0934 Total | 1495570.01 71 21064.3663 Root MSE = 138.19 --------------------------------------------------------------------------- exp1 | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+------------------------------------------------------------- age1 | -2.647726 4.616128 -0.57 0.568 -11.86156 6.566103 ownrent1 | 48.1849 69.89543 0.69 0.493 -91.32696 187.6968 income1 | 311.1198 148.1804 2.10 0.040 15.35038 606.8892 incomesq1 | -16.40469 10.50467 -1.56 0.123 -37.3721 4.562719 _cons | -277.2822 231.3404 -1.20 0.235 -739.0396 184.4752 --------------------------------------------------------------------------- . . /* end of checkup */ . . log close log: choice_binary_revised.log log type: text closed on: 26 Sep 2007, 01:22:02 ------------------------------------------------------------------------------------------------------