= Stata predict = '''`predict`''' is a post-estimation command that calculates predicted probabilities. <> ---- == Usage == To obtain the predicted outcome propensity from a [[Stata/Logistic|logistic]] model, try: {{{ . webuse nhanes2 . gen goodhealth = inrange(hlthstat,1,3) . logistic goodhealth i.agegrp i.sex weight Logistic regression Number of obs = 10,351 LR chi2(7) = 1132.40 Prob > chi2 = 0.0000 Log likelihood = -5056.9403 Pseudo R2 = 0.1007 ------------------------------------------------------------------------------ goodhealth | Odds ratio Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- agegrp | 30–39 | .7793651 .0902187 -2.15 0.031 .6211643 .9778571 40–49 | .3560292 .0380841 -9.65 0.000 .288691 .4390742 50–59 | .2226468 .0225284 -14.85 0.000 .1825947 .2714844 60–69 | .1394634 .0122928 -22.35 0.000 .1173362 .1657633 70+ | .104361 .010635 -22.18 0.000 .0854664 .1274327 | sex | Female | .8600342 .0451549 -2.87 0.004 .7759337 .9532501 weight | .9929544 .0017037 -4.12 0.000 .9896208 .9962992 _cons | 21.95965 3.387447 20.03 0.000 16.23009 29.71186 ------------------------------------------------------------------------------ Note: _cons estimates baseline odds. . predict propensity, pr . mean propensity, over(strata) Mean estimation Number of obs = 10,351 --------------------------------------------------------------------- | Mean Std. err. [95% conf. interval] --------------------+------------------------------------------------ c.propensity@strata | 1 | .7425612 .0069563 .7289254 .756197 2 | .7738034 .01002 .7541622 .7934446 3 | .7501458 .0071763 .7360789 .7642126 4 | .7842088 .0063844 .7716941 .7967236 5 | .7810146 .0084046 .76454 .7974892 6 | .7666114 .007752 .7514159 .7818069 7 | .7350987 .0062277 .7228913 .7473061 8 | .7491121 .0075689 .7342755 .7639487 9 | .7983793 .0081168 .7824689 .8142897 10 | .7807851 .008437 .764247 .7973231 11 | .7720709 .0079622 .7564634 .7876784 12 | .7804427 .007765 .7652219 .7956636 13 | .766857 .0072942 .7525591 .781155 14 | .7760337 .0066241 .7630492 .7890181 15 | .7515905 .0068979 .7380693 .7651116 16 | .7879491 .0072613 .7737155 .8021827 17 | .7700296 .0065947 .7571028 .7829564 18 | .7512391 .0070538 .7374124 .7650659 20 | .7732079 .0080411 .7574459 .78897 21 | .765017 .0091615 .7470587 .7829753 22 | .7578301 .007664 .7428073 .772853 23 | .784183 .0073184 .7698376 .7985285 24 | .7476354 .0065429 .7348101 .7604606 25 | .7650576 .008138 .7491056 .7810097 26 | .7680721 .0084251 .7515573 .7845869 27 | .7783377 .0081194 .7624221 .7942533 28 | .7741337 .0081387 .7581803 .7900871 29 | .7287702 .0061495 .7167159 .7408244 30 | .7629903 .0068803 .7495037 .7764769 31 | .7853215 .0078016 .7700289 .8006141 32 | .8055108 .0065239 .7927226 .818299 --------------------------------------------------------------------- }}} This can also be used to generate out-of-sample predicted propensities. {{{ . sample 30 (7,246 observations deleted) . logistic goodhealth i.agegrp i.sex weight [snip] . clear . webuse nhanes2 . predict propensity, pr . mean propensity, over(strata) Mean estimation Number of obs = 10,351 --------------------------------------------------------------------- | Mean Std. err. [95% conf. interval] --------------------+------------------------------------------------ c.propensity@strata | 1 | .746138 .0069755 .7324646 .7598114 2 | .777912 .0100163 .7582781 .797546 3 | .7535636 .0071896 .7394706 .7676566 4 | .7876387 .0063554 .7751809 .8000965 5 | .783574 .0083246 .7672562 .7998919 6 | .7702981 .00772 .7551653 .7854308 7 | .7386229 .006259 .7263541 .7508918 8 | .7525448 .0075756 .7376952 .7673943 9 | .8018701 .0080247 .7861401 .8176002 10 | .7841906 .0084246 .7676768 .8007044 11 | .7752522 .0079553 .7596582 .7908461 12 | .783474 .0077902 .7682037 .7987444 13 | .7702269 .0072267 .7560612 .7843925 14 | .7799459 .0065436 .7671192 .7927726 15 | .7551355 .006916 .7415788 .7686922 16 | .7911832 .0072553 .7769613 .805405 17 | .7745866 .0065169 .7618122 .787361 18 | .755422 .0070323 .7416373 .7692067 20 | .7769737 .0080169 .7612591 .7926883 21 | .7683972 .0091782 .7504062 .7863882 22 | .7622266 .00758 .7473683 .777085 23 | .7876735 .0073226 .7733199 .8020272 24 | .7515857 .0065253 .7387948 .7643765 25 | .7694184 .0081019 .7535371 .7852996 26 | .7710772 .0084184 .7545756 .7875788 27 | .7820861 .0080883 .7662315 .7979407 28 | .7769497 .0082211 .7608347 .7930646 29 | .7323046 .006182 .7201866 .7444226 30 | .7661599 .0068439 .7527445 .7795753 31 | .7889444 .00777 .7737137 .8041751 32 | .8079336 .0065227 .7951478 .8207193 --------------------------------------------------------------------- }}} To obtain the predicted probabilities of each outcome from a [[Stata/Mlogit|mlogit]] or [[Stata/Ologit|ologit]] model, try: {{{ . use https://www3.nd.edu/~rwilliam/statafiles/mroz.dta . ologit lfstatus kidslt6 kidsge6 age educ exper nwifeinc [snip] . predict lfstatus_pr1, pr outcome(0) . predict lfstatus_pr1, pr outcome(1) . predict lfstatus_pr2, pr outcome(2) }}} ---- == See also == [[https://www.stata.com/manuals/rpredict.pdf|Stata manual for predict]] ---- CategoryRicottone