-------------------------------------------------------------------------------------------- name: log: /Users/belenchavez/Desktop/Week5_lecture.txt log type: text opened on: 17 Feb 2016, 18:27:26 r; t=0.00 18:27:26 . /* Quiz*/ . . /* Review: */ . * Filling in missing names from raw_names (after using tsfill) : . * bys ename: replace name = name[_N] if name=="" . . /* Week 5 Lecture */ . cd "/users/belenchavez/desktop" /Users/belenchavez/Desktop r; t=0.00 18:27:26 . use firm, clear r; t=0.00 18:27:26 . tab hired rank | rank hired | 1 2 3 4 | Total -----------+--------------------------------------------+---------- 0 | 28 97 93 55 | 273 1 | 33 54 28 12 | 127 -----------+--------------------------------------------+---------- Total | 61 151 121 67 | 400 r; t=0.00 18:27:26 . . . /******************************************************************************/ . /* LPM model (OLS) > */ . /******************************************************************************/ . reg hired exp gpa i.rank male minority, r Linear regression Number of obs = 400 F(7, 392) = 7.72 Prob > F = 0.0000 R-squared = 0.1067 Root MSE = .44444 ------------------------------------------------------------------------------ | Robust hired | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .1768779 .0841571 2.10 0.036 .0114221 .3423336 gpa | .1593523 .0650013 2.45 0.015 .0315576 .287147 | rank | 2 | -.1593998 .0737867 -2.16 0.031 -.3044669 -.0143327 3 | -.2837943 .0737973 -3.85 0.000 -.4288823 -.1387064 4 | -.3103879 .0787031 -3.94 0.000 -.4651209 -.1556549 | male | .028133 .0445611 0.63 0.528 -.0594757 .1157417 minority | .0688492 .0446719 1.54 0.124 -.0189773 .1566758 _cons | -.336285 .2134923 -1.58 0.116 -.7560183 .0834482 ------------------------------------------------------------------------------ r; t=0.02 18:27:26 . predict yhat_ols (option xb assumed; fitted values) r; t=0.00 18:27:26 . summ yhat_ols Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- yhat_ols | 400 .3175 .1522382 -.0726819 .7076427 r; t=0.00 18:27:26 . . /* A one unit change in experience increases prob of hiring by .177 > Going from rank 1 to rank 2 decreases prob of hiring by 0.159 */ . . /* What does model estimate for Female non-minority from rank 1? */ . /* Assume gpa = 3.8 and exp = 2 */ . di _b[_cons]+_b[gpa]*3.8+_b[exp]*2 .62300949 r; t=0.00 18:27:26 . //62.3% . . * Could have also used lincom: . lincom gpa*3.8+exp*2 + 1.rank*1+_cons ( 1) 2*exp + 3.8*gpa + 1b.rank + _cons = 0 ------------------------------------------------------------------------------ hired | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .6230095 .0791491 7.87 0.000 .4673996 .7786194 ------------------------------------------------------------------------------ r; t=0.01 18:27:26 . lincom gpa*3.8+exp*2 +_cons ( 1) 2*exp + 3.8*gpa + _cons = 0 ------------------------------------------------------------------------------ hired | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .6230095 .0791491 7.87 0.000 .4673996 .7786194 ------------------------------------------------------------------------------ r; t=0.00 18:27:26 . //62.3% . . . /* Estimate effect on hired if exp goes up by half a year? (same from 0.5 to 1, or 1 to 1. > 5, etc. Linear. */ . di _b[exp]*0.5 .08843894 r; t=0.00 18:27:26 . *8.8% . . margins, dydx(exp) Average marginal effects Number of obs = 400 Model VCE : Robust Expression : Linear prediction, predict() dy/dx w.r.t. : exp ------------------------------------------------------------------------------ | Delta-method | dy/dx Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .1768779 .0841571 2.10 0.036 .0114221 .3423336 ------------------------------------------------------------------------------ r; t=0.03 18:27:26 . . /******************************************************************************/ . /*Probit regression > */ . /******************************************************************************/ . probit hired exp gpa i.rank male minority Iteration 0: log likelihood = -249.98826 Iteration 1: log likelihood = -227.90462 Iteration 2: log likelihood = -227.80512 Iteration 3: log likelihood = -227.80512 Probit regression Number of obs = 400 LR chi2(7) = 44.37 Prob > chi2 = 0.0000 Log likelihood = -227.80512 Pseudo R2 = 0.0887 ------------------------------------------------------------------------------ hired | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .5680508 .2611999 2.17 0.030 .0561084 1.079993 gpa | .4926924 .1969036 2.50 0.012 .1067684 .8786165 | rank | 2 | -.4073744 .1970577 -2.07 0.039 -.7936004 -.0211484 3 | -.7911985 .2091566 -3.78 0.000 -1.201138 -.3812591 4 | -.9043956 .247669 -3.65 0.000 -1.389818 -.4189733 | male | .0774922 .1374011 0.56 0.573 -.191809 .3467935 minority | .2156624 .1381238 1.56 0.118 -.0550553 .4863801 _cons | -2.638844 .6943416 -3.80 0.000 -3.999729 -1.27796 ------------------------------------------------------------------------------ r; t=0.37 18:27:27 . * Rank is individually significant. Is it jointly significant? . test 2.rank 3.rank 4.rank ( 1) [hired]2.rank = 0 ( 2) [hired]3.rank = 0 ( 3) [hired]4.rank = 0 chi2( 3) = 19.77 Prob > chi2 = 0.0002 r; t=0.00 18:27:27 . //Yes. Jointly Significant . . * What about male and minority? Not individually sig, are they jointly sig? . test minority male ( 1) [hired]minority = 0 ( 2) [hired]male = 0 chi2( 2) = 2.79 Prob > chi2 = 0.2480 r; t=0.00 18:27:27 . . *Remove male and minority from hired. They are not statistically sig different than 0. . probit hired exp gpa i.rank Iteration 0: log likelihood = -249.98826 Iteration 1: log likelihood = -229.29667 Iteration 2: log likelihood = -229.20659 Iteration 3: log likelihood = -229.20659 Probit regression Number of obs = 400 LR chi2(5) = 41.56 Prob > chi2 = 0.0000 Log likelihood = -229.20659 Pseudo R2 = 0.0831 ------------------------------------------------------------------------------ hired | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .5502365 .2595461 2.12 0.034 .0415355 1.058938 gpa | .4777302 .1954625 2.44 0.015 .0946308 .8608297 | rank | 2 | -.4153992 .1953769 -2.13 0.033 -.7983308 -.0324675 3 | -.812138 .2085956 -3.89 0.000 -1.220978 -.4032981 4 | -.935899 .2456339 -3.81 0.000 -1.417333 -.4544654 | _cons | -2.386837 .6740879 -3.54 0.000 -3.708026 -1.065649 ------------------------------------------------------------------------------ r; t=0.03 18:27:27 . //The probit regression coefficients give the change in the z-score or probit index for a > one unit change in the predictor. . //For a one unit increase in experience, the z-score increases by 0.55 . //For a one unit increase in gpa, the z-score increases by .4777302 . . /* Now, let's look at a person's chance of being hired if they have 3.8 GPA and went to a > top-tier (rank 1 school) > What is the effect of a half-year of experience? */ . . /*Let's look at non-linearity. Is half year of experience the same over all intervals? */ . di normal(_b[_cons]+_b[gpa]*3.8+_b[exp]*2)-normal(_b[_cons]+_b[gpa]*3.8+_b[exp]*1.5) .10139033 r; t=0.00 18:27:27 . //10.14%. Higher than the 8.8% the LPM predicted . . di normal(_b[_cons]+_b[gpa]*3.8+_b[exp]*.75)-normal(_b[_cons]+_b[gpa]*3.8+_b[exp]*.25) .10473978 r; t=0.00 18:27:27 . //Can also do the above by using the command margins. This is on your hw assignment. . //10.47% . . /* Predicted probabilities of being hired at each level of rank holding all other > variables in the model at their means. */ . margins rank, atmeans Adjusted predictions Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() at : exp = 1.46925 (mean) gpa = 3.3899 (mean) 1.rank = .1525 (mean) 2.rank = .3775 (mean) 3.rank = .3025 (mean) 4.rank = .1675 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- rank | 1 | .5163741 .0656201 7.87 0.000 .3877611 .6449871 2 | .3540742 .0394725 8.97 0.000 .2767096 .4314388 3 | .2203289 .0383674 5.74 0.000 .1451302 .2955277 4 | .1854353 .0487112 3.81 0.000 .0899631 .2809075 ------------------------------------------------------------------------------ r; t=0.09 18:27:27 . . /* Average Predicted probabilities calculated using sample values of other predictor varia > bles */ . . margins rank Predictive margins Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- rank | 1 | .5159885 .0631246 8.17 0.000 .3922666 .6397104 2 | .3596023 .0381853 9.42 0.000 .2847605 .4344441 3 | .229225 .0375607 6.10 0.000 .1556075 .3028426 4 | .1947356 .048586 4.01 0.000 .0995088 .2899623 ------------------------------------------------------------------------------ r; t=0.05 18:27:27 . . * For margins we could also hold other variables at certain values, for example GPA = 3.5 . margins rank, at(gpa = 3.5) atmeans Adjusted predictions Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() at : exp = 1.46925 (mean) gpa = 3.5 1.rank = .1525 (mean) 2.rank = .3775 (mean) 3.rank = .3025 (mean) 4.rank = .1675 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- rank | 1 | .5373077 .0656157 8.19 0.000 .4087033 .6659122 2 | .3738226 .0413207 9.05 0.000 .2928356 .4548097 3 | .2362293 .0395476 5.97 0.000 .1587174 .3137411 4 | .1998252 .0514096 3.89 0.000 .0990643 .3005861 ------------------------------------------------------------------------------ r; t=0.06 18:27:27 . marginsplot Variables that uniquely identify margins: rank r; t=1.09 18:27:28 . //Predicted probabilities of being hired holding gpa at 3.5 and all other values at their > means . . * We can also look at interactions: . probit hired exp gpa i.rank i.male Iteration 0: log likelihood = -249.98826 Iteration 1: log likelihood = -229.12454 Iteration 2: log likelihood = -229.02902 Iteration 3: log likelihood = -229.02902 Probit regression Number of obs = 400 LR chi2(6) = 41.92 Prob > chi2 = 0.0000 Log likelihood = -229.02902 Pseudo R2 = 0.0838 ------------------------------------------------------------------------------ hired | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .5591142 .2601396 2.15 0.032 .0492501 1.068978 gpa | .4731448 .1956132 2.42 0.016 .0897499 .8565396 | rank | 2 | -.4261102 .196251 -2.17 0.030 -.8107551 -.0414654 3 | -.8115036 .2085038 -3.89 0.000 -1.220164 -.4028436 4 | -.9379558 .2458167 -3.82 0.000 -1.419748 -.456164 | 1.male | .0816061 .1369642 0.60 0.551 -.1868389 .350051 _cons | -2.4217 .6772841 -3.58 0.000 -3.749153 -1.094248 ------------------------------------------------------------------------------ r; t=0.03 18:27:28 . margins rank##male Predictive margins Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- rank | 1 | .5174707 .0631057 8.20 0.000 .3937858 .6411556 2 | .3572563 .0383048 9.33 0.000 .2821804 .4323323 3 | .2307115 .0377363 6.11 0.000 .1567498 .3046732 4 | .195393 .0487304 4.01 0.000 .0998832 .2909027 | male | 0 | .3039894 .0312224 9.74 0.000 .2427946 .3651843 1 | .3304929 .0313756 10.53 0.000 .2689979 .391988 | rank#male | 1 0 | .5016579 .0675591 7.43 0.000 .3692445 .6340712 1 1 | .532926 .0690698 7.72 0.000 .3975517 .6683003 2 0 | .3424744 .047193 7.26 0.000 .2499779 .4349709 2 1 | .3717567 .043699 8.51 0.000 .2861082 .4574053 3 0 | .2186835 .0405582 5.39 0.000 .1391909 .2981761 3 1 | .242562 .0448143 5.41 0.000 .1547276 .3303964 4 0 | .1844852 .0500708 3.68 0.000 .0863483 .2826221 4 1 | .206158 .0538948 3.83 0.000 .1005261 .3117898 ------------------------------------------------------------------------------ r; t=0.15 18:27:28 . marginsplot Variables that uniquely identify margins: rank male r; t=1.02 18:27:29 . . * We can look at average marginal effects . margins, dydx(exp) Average marginal effects Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() dy/dx w.r.t. : exp ------------------------------------------------------------------------------ | Delta-method | dy/dx Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .1815273 .083079 2.18 0.029 .0186954 .3443592 ------------------------------------------------------------------------------ r; t=0.05 18:27:29 . . . probit hired exp gpa i.rank Iteration 0: log likelihood = -249.98826 Iteration 1: log likelihood = -229.29667 Iteration 2: log likelihood = -229.20659 Iteration 3: log likelihood = -229.20659 Probit regression Number of obs = 400 LR chi2(5) = 41.56 Prob > chi2 = 0.0000 Log likelihood = -229.20659 Pseudo R2 = 0.0831 ------------------------------------------------------------------------------ hired | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .5502365 .2595461 2.12 0.034 .0415355 1.058938 gpa | .4777302 .1954625 2.44 0.015 .0946308 .8608297 | rank | 2 | -.4153992 .1953769 -2.13 0.033 -.7983308 -.0324675 3 | -.812138 .2085956 -3.89 0.000 -1.220978 -.4032981 4 | -.935899 .2456339 -3.81 0.000 -1.417333 -.4544654 | _cons | -2.386837 .6740879 -3.54 0.000 -3.708026 -1.065649 ------------------------------------------------------------------------------ r; t=0.03 18:27:29 . predict yhat_probit (option pr assumed; Pr(hired)) r; t=0.00 18:27:29 . gen yhat_probit_manual = normal(_b[exp]*exp+_b[gpa]*gpa+_b[2.rank]*2.rank+_b[3.rank]*3.ran > k+_b[4.rank]*4.rank + _b[_cons]) r; t=0.00 18:27:29 . assert yhat_probit == yhat_probit_m r; t=0.00 18:27:29 . //Can use those predicted values to assess how our model predicted hiring. . . /******************************************************************************/ . /*Logit regression > */ . /******************************************************************************/ . logistic hired exp gpa i.rank Logistic regression Number of obs = 400 LR chi2(5) = 41.46 Prob > chi2 = 0.0000 Log likelihood = -229.25875 Pseudo R2 = 0.0829 ------------------------------------------------------------------------------ hired | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | 2.473837 1.082549 2.07 0.038 1.049267 5.832517 gpa | 2.234545 .7414652 2.42 0.015 1.166122 4.281877 | rank | 2 | .5089309 .1610714 -2.13 0.033 .2736922 .9463578 3 | .2617923 .0903986 -3.88 0.000 .1330551 .5150889 4 | .2119375 .0885542 -3.71 0.000 .0934435 .4806919 | _cons | .0185001 .0210892 -3.50 0.000 .0019808 .1727834 ------------------------------------------------------------------------------ r; t=0.03 18:27:29 . * Note odds ratios are reported . logit Logistic regression Number of obs = 400 LR chi2(5) = 41.46 Prob > chi2 = 0.0000 Log likelihood = -229.25875 Pseudo R2 = 0.0829 ------------------------------------------------------------------------------ hired | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .9057702 .4375991 2.07 0.038 .0480918 1.763449 gpa | .8040377 .3318193 2.42 0.015 .1536838 1.454392 | rank | 2 | -.6754429 .3164897 -2.13 0.033 -1.295751 -.0551346 3 | -1.340204 .3453064 -3.88 0.000 -2.016992 -.6634158 4 | -1.551464 .4178316 -3.71 0.000 -2.370399 -.7325287 | _cons | -3.989979 1.139951 -3.50 0.000 -6.224242 -1.755717 ------------------------------------------------------------------------------ r; t=0.01 18:27:29 . //The logistic regression coefficients give the change in the log odds of the outcome . //for a one unit increase in the predictor variable. . * For a one unit increase in gpa, the log odds of being hired increases by 0.804. . di exp(.8040377) // To get odds-ratio 2.2345452 r; t=0.00 18:27:29 . * Can get back to odds-ratio by typing: . logit, or Logistic regression Number of obs = 400 LR chi2(5) = 41.46 Prob > chi2 = 0.0000 Log likelihood = -229.25875 Pseudo R2 = 0.0829 ------------------------------------------------------------------------------ hired | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | 2.473837 1.082549 2.07 0.038 1.049267 5.832517 gpa | 2.234545 .7414652 2.42 0.015 1.166122 4.281877 | rank | 2 | .5089309 .1610714 -2.13 0.033 .2736922 .9463578 3 | .2617923 .0903986 -3.88 0.000 .1330551 .5150889 4 | .2119375 .0885542 -3.71 0.000 .0934435 .4806919 | _cons | .0185001 .0210892 -3.50 0.000 .0019808 .1727834 ------------------------------------------------------------------------------ r; t=0.01 18:27:29 . di log(2.234545) //To get what we had in log-odds .80403763 r; t=0.00 18:27:29 . * For a one unit increase in gpa, the odds of being hired increase by a factor of 2.23 . . /*What's the change of being hired for half a year? more experience? */ . di exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*2)/(1+exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*2)) - /// > (exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*1.5)/(1+exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*1.5))) .1017357 r; t=0.00 18:27:29 . * 10.17357% . . di exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*.75)/(1+exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*.75)) - /// > (exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*.25)/(1+exp(_b[_cons]+_b[gpa]*3.8+_b[exp]*.25))) .10651922 r; t=0.00 18:27:29 . *10.6% . . * Can also use margins: . /* Predicted probabilities of being hired at each level of rank holding all other > variables in the model at their means. */ . * Margins for hired . margins rank, atmeans Adjusted predictions Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() at : exp = 1.46925 (mean) gpa = 3.3899 (mean) 1.rank = .1525 (mean) 2.rank = .3775 (mean) 3.rank = .3025 (mean) 4.rank = .1675 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- rank | 1 | .5166016 .0663153 7.79 0.000 .3866261 .6465771 2 | .3522846 .0397848 8.85 0.000 .2743078 .4302614 3 | .218612 .0382506 5.72 0.000 .1436422 .2935819 4 | .1846684 .0486362 3.80 0.000 .0893432 .2799937 ------------------------------------------------------------------------------ r; t=0.14 18:27:29 . . * Average marginal effects of experience . margins, dydx(exp) Average marginal effects Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() dy/dx w.r.t. : exp ------------------------------------------------------------------------------ | Delta-method | dy/dx Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- exp | .1762271 .0836464 2.11 0.035 .0122832 .340171 ------------------------------------------------------------------------------ r; t=0.04 18:27:30 . . . * For margins we could also hold other variables at certain values, for example GPA = 3.5 . margins rank, at(gpa = 3.5) atmeans Adjusted predictions Number of obs = 400 Model VCE : OIM Expression : Pr(hired), predict() at : exp = 1.46925 (mean) gpa = 3.5 1.rank = .1525 (mean) 2.rank = .3775 (mean) 3.rank = .3025 (mean) 4.rank = .1675 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- rank | 1 | .5386615 .0662654 8.13 0.000 .4087837 .6685393 2 | .3727382 .0418127 8.91 0.000 .2907869 .4546895 3 | .2341098 .0395453 5.92 0.000 .1566024 .3116173 4 | .1983708 .0517037 3.84 0.000 .0970334 .2997081 ------------------------------------------------------------------------------ r; t=0.12 18:27:30 . predict yhat_logit (option pr assumed; Pr(hired)) r; t=0.00 18:27:30 . gen double yhat_logit_manual = exp(_b[exp]*exp+_b[gpa]*gpa+_b[2.rank]*2.rank+_b[3.rank]*3 > .rank+_b[4.rank]*4.rank + _b[_cons])/(1+exp(_b[exp]*exp+_b[gpa]*gpa+_b[2.rank]*2.rank+_b[3 > .rank]*3.rank+_b[4.rank]*4.rank + _b[_cons])) r; t=0.00 18:27:30 . assert round(yhat_logit, .001) == round(yhat_logit_manual, .001) r; t=0.00 18:27:30 . . /* Graph example */ . * A very simple example* . use http://www.ats.ucla.edu/stat/stata/webbooks/logistic/apilog, clear r; t=0.11 18:27:30 . regress hiqual avg_ed Source | SS df MS Number of obs = 1,158 -------------+---------------------------------- F(1, 1156) = 1136.02 Model | 126.023363 1 126.023363 Prob > F = 0.0000 Residual | 128.240023 1,156 .110934276 R-squared = 0.4956 -------------+---------------------------------- Adj R-squared = 0.4952 Total | 254.263385 1,157 .219760921 Root MSE = .33307 ------------------------------------------------------------------------------ hiqual | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- avg_ed | .4286426 .0127175 33.70 0.000 .4036906 .4535946 _cons | -.8549049 .0363655 -23.51 0.000 -.9262547 -.7835551 ------------------------------------------------------------------------------ r; t=0.00 18:27:30 . predict yhat (option xb assumed; fitted values) (42 missing values generated) r; t=0.00 18:27:30 . twoway scatter yhat hiqual avg_ed, connect(l .) symbol(i O) sort ylabel(0 1) r; t=0.81 18:27:31 . logit hiqual avg_ed Iteration 0: log likelihood = -730.68708 Iteration 1: log likelihood = -386.87925 Iteration 2: log likelihood = -355.07208 Iteration 3: log likelihood = -353.91734 Iteration 4: log likelihood = -353.91719 Iteration 5: log likelihood = -353.91719 Logistic regression Number of obs = 1,158 LR chi2(1) = 753.54 Prob > chi2 = 0.0000 Log likelihood = -353.91719 Pseudo R2 = 0.5156 ------------------------------------------------------------------------------ hiqual | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- avg_ed | 3.909635 .2383161 16.41 0.000 3.442544 4.376726 _cons | -12.30054 .731489 -16.82 0.000 -13.73423 -10.86684 ------------------------------------------------------------------------------ r; t=0.02 18:27:31 . predict yhat_l (option pr assumed; Pr(hiqual)) (42 missing values generated) r; t=0.00 18:27:31 . twoway scatter yhat_l hiqual avg_ed, connect(l i) msymbol(i O) sort ylabel(0 1) r; t=0.75 18:27:31 . probit hiqual avg_ed Iteration 0: log likelihood = -730.68708 Iteration 1: log likelihood = -372.75642 Iteration 2: log likelihood = -363.42077 Iteration 3: log likelihood = -363.37756 Iteration 4: log likelihood = -363.37756 Probit regression Number of obs = 1,158 LR chi2(1) = 734.62 Prob > chi2 = 0.0000 Log likelihood = -363.37756 Pseudo R2 = 0.5027 ------------------------------------------------------------------------------ hiqual | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- avg_ed | 2.030443 .1059943 19.16 0.000 1.822698 2.238188 _cons | -6.418583 .3243266 -19.79 0.000 -7.054251 -5.782914 ------------------------------------------------------------------------------ r; t=0.02 18:27:31 . predict yhat_p (option pr assumed; Pr(hiqual)) (42 missing values generated) r; t=0.00 18:27:31 . twoway scatter yhat_p hiqual avg_ed, connect(l i) msymbol(i O) sort ylabel(0 1) r; t=0.81 18:27:32 . scatter yhat* avg_ed r; t=0.80 18:27:33 . log close name: log: /Users/belenchavez/Desktop/Week5_lecture.txt log type: text closed on: 17 Feb 2016, 18:27:33 --------------------------------------------------------------------------------------------