Using Stata 13.1 under Windows 7.1. Trying to understand margins better so I ran one of the examples from logit:
As a test, this works ok:
However, this throws an error:
Not sure why. The coefficient table shows smoke present:
What am I missing?
Code:
. webuse lbw (Hosmer & Lemeshow data) . logit low age lwt i.race smoke ptl ht ui Iteration 0: log likelihood = -117.336 Iteration 1: log likelihood = -101.28644 Iteration 2: log likelihood = -100.72617 Iteration 3: log likelihood = -100.724 Iteration 4: log likelihood = -100.724 Logistic regression Number of obs = 189 LR chi2(8) = 33.22 Prob > chi2 = 0.0001 Log likelihood = -100.724 Pseudo R2 = 0.1416 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | -.0271003 .0364504 -0.74 0.457 -.0985418 .0443412 lwt | -.0151508 .0069259 -2.19 0.029 -.0287253 -.0015763 | race | black | 1.262647 .5264101 2.40 0.016 .2309024 2.294392 other | .8620792 .4391532 1.96 0.050 .0013548 1.722804 | smoke | .9233448 .4008266 2.30 0.021 .137739 1.708951 ptl | .5418366 .346249 1.56 0.118 -.136799 1.220472 ht | 1.832518 .6916292 2.65 0.008 .4769494 3.188086 ui | .7585135 .4593768 1.65 0.099 -.1418484 1.658875 _cons | .4612239 1.20459 0.38 0.702 -1.899729 2.822176 ------------------------------------------------------------------------------
As a test, this works ok:
Code:
. margins race ,atmeans Adjusted predictions Number of obs = 189 Model VCE : OIM Expression : Pr(low), predict() at : age = 23.2381 (mean) lwt = 129.8201 (mean) 1.race = .5079365 (mean) 2.race = .1375661 (mean) 3.race = .3544974 (mean) smoke = .3915344 (mean) ptl = .1957672 (mean) ht = .0634921 (mean) ui = .1481481 (mean) ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- race | white | .191685 .0454474 4.22 0.000 .1026096 .2807603 black | .4560013 .107471 4.24 0.000 .245362 .6666405 other | .3596187 .0695116 5.17 0.000 .2233784 .495859 ------------------------------------------------------------------------------
Code:
. margins smoke ,atmeans factor 'smoke' not found in list of covariates r(322);
Not sure why. The coefficient table shows smoke present:
Code:
r(table)[9,10] low: low: low: low: low: low: low: low: low: low: 1b. 2. 3. age lwt race race race smoke ptl ht ui _cons b -.02710031 -.01515082 0 1.2626473 .86207916 .92334482 .54183656 1.8325178 .75851348 .46122388 se .03645043 .00692588 . .52641014 .43915315 .40082664 .346249 .69162923 .45937677 1.2045897 z -.74348404 -2.1875663 . 2.3985998 1.963049 2.3036014 1.5648755 2.6495667 1.6511794 .38288876 pvalue .45718868 .02870121 . .01645789 .04964048 .02124503 .11761211 .00805951 .09870194 .70180224 ll -.09854183 -.02872529 . .23090236 .00135479 .13773904 -.136799 .47694941 -.14184845 -1.8997286 ul .04434121 -.00157635 . 2.2943922 1.7228035 1.7089506 1.2204721 3.1880862 1.6588754 2.8221764 df . . . . . . . . . . crit 1.959964 1.959964 1.959964 1.959964 1.959964 1.959964 1.959964 1.959964 1.959964 1.959964 eform 0 0 0 0 0 0 0 0 0 0
What am I missing?
Comment