I am trying to run the postestimation command for marginal effects after an alternative specific multinomial logit in Stata 16.1. The model refers to the choice of travel mode for commuting to work with travel time as alternative specific explanatory variable and a series case specific dummy and categorical variables.
I first tried to run it with asclogit and then use estat mfx for postestimation. I am able to get results in line what I am expecting. However, as some variables are 3-level categorical (ex. 0,1,2), the estat mfx command only shows marginal effects for one alternative (1 or 2) with respect to base (0).
Code:
. asclogit choice Ttime, case(ID) alternatives(alternative) casevars(i.m8CLASS i.m9CLASS i.M25Adum i.M25EnvDum i.CITY) basealternative(1) vce(bootstrap, reps(100)) (running asclogit on estimation sample) Bootstrap replications (100) ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 .................................................. 50 .................................................. 100 Alternative-specific conditional logit Number of obs = 5,097 Case ID variable: ID Number of cases = 1699 Alternatives variable: alternative Alts per case: min = 3 avg = 3.0 max = 3 Wald chi2(17) = 417.74 Log likelihood = -1394.0571 Prob > chi2 = 0.0000 (Replications based on 1,699 clusters in ID) ------------------------------------------------------------------------------ | Observed Bootstrap Normal-based choice | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- alternative | Ttime | -.0190327 .0012167 -15.64 0.000 -.0214173 -.0166481 -------------+---------------------------------------------------------------- 1 | (base alternative) -------------+---------------------------------------------------------------- 2 | m8CLASS | 2 | .3283541 .1595204 2.06 0.040 .0156998 .6410084 3 | -.6963945 .2546037 -2.74 0.006 -1.195409 -.1973804 | m9CLASS | 2 | -.4007272 .1504204 -2.66 0.008 -.6955459 -.1059086 3 | -.208201 .1552985 -1.34 0.180 -.5125804 .0961784 | 1.M25Adum | .7260046 .1428897 5.08 0.000 .4459458 1.006063 1.M25EnvDum | .2026583 .1262822 1.60 0.109 -.0448503 .4501669 | CITY | 2 | .1318349 .1511332 0.87 0.383 -.1643807 .4280505 3 | 1.105557 .1405379 7.87 0.000 .8301081 1.381006 | _cons | -1.244998 .183238 -6.79 0.000 -1.604137 -.8858578 -------------+---------------------------------------------------------------- 3 | m8CLASS | 2 | .2417938 .1807076 1.34 0.181 -.1123866 .5959742 3 | -.2168523 .2358429 -0.92 0.358 -.6790959 .2453912 | m9CLASS | 2 | -.3370252 .1867652 -1.80 0.071 -.7030782 .0290278 3 | -.056632 .1677786 -0.34 0.736 -.3854721 .2722081 | 1.M25Adum | .2834844 .1428822 1.98 0.047 .0034404 .5635283 1.M25EnvDum | .2357513 .138836 1.70 0.089 -.0363623 .5078649 | CITY | 2 | .0666527 .1753851 0.38 0.704 -.2770959 .4104012 3 | .1945577 .1745162 1.11 0.265 -.1474877 .5366031 | _cons | .0196005 .2421315 0.08 0.935 -.4549686 .4941696 ------------------------------------------------------------------------------ . estat mfx Pr(choice = 1|1 selected) = .86304661 ------------------------------------------------------------------------------- variable | dp/dx Std. Err. z P>|z| [ 95% C.I. ] X -------------+----------------------------------------------------------------- Ttime | 1 | -.00225 .000277 -8.11 0.000 -.002793 -.001706 24.621 2 | .001642 .000238 6.90 0.000 .001176 .002108 72.466 3 | .000608 .000115 5.28 0.000 .000382 .000833 191.15 -------------+----------------------------------------------------------------- casevars | 2.m8CLASS | -.040292 .021751 -1.85 0.064 -.082924 .002339 1 2.m9CLASS | .039333 .014081 2.79 0.005 .011734 .066932 1 1.M25Adum | -.091621 .018231 -5.03 0.000 -.127353 -.055889 0 1.M25EnvDum | -.026997 .015239 -1.77 0.076 -.056864 .00287 0 2.CITY | -.014123 .016734 -0.84 0.399 -.046922 .018676 1 ------------------------------------------------------------------------------- dp/dx for factor levels is the discrete change from the base level Pr(choice = 2|1 selected) = .09996812 ------------------------------------------------------------------------------- variable | dp/dx Std. Err. z P>|z| [ 95% C.I. ] X -------------+----------------------------------------------------------------- Ttime | 1 | .001642 .000238 6.90 0.000 .001176 .002108 24.621 2 | -.001712 .000252 -6.80 0.000 -.002206 -.001219 72.466 3 | .00007 .000021 3.33 0.001 .000029 .000112 191.15 -------------+----------------------------------------------------------------- casevars | 2.m8CLASS | .032375 .017992 1.80 0.072 -.002889 .067638 1 2.m9CLASS | -.029954 .012048 -2.49 0.013 -.053568 -.006341 1 1.M25Adum | .084712 .01736 4.88 0.000 .050687 .118738 0 1.M25EnvDum | .018629 .013222 1.41 0.159 -.007286 .044543 0 2.CITY | .012221 .014006 0.87 0.383 -.015231 .039673 1 ------------------------------------------------------------------------------- dp/dx for factor levels is the discrete change from the base level Pr(choice = 3|1 selected) = .03698527 ------------------------------------------------------------------------------- variable | dp/dx Std. Err. z P>|z| [ 95% C.I. ] X -------------+----------------------------------------------------------------- Ttime | 1 | .000608 .000115 5.28 0.000 .000382 .000833 24.621 2 | .00007 .000021 3.33 0.001 .000029 .000112 72.466 3 | -.000678 .000133 -5.11 0.000 -.000938 -.000418 191.15 -------------+----------------------------------------------------------------- casevars | 2.m8CLASS | .007918 .007287 1.09 0.277 -.006364 .022199 1 2.m9CLASS | -.009378 .005785 -1.62 0.105 -.020716 .001959 1 1.M25Adum | .006909 .005389 1.28 0.200 -.003653 .01747 0 1.M25EnvDum | .008368 .005592 1.50 0.135 -.002591 .019328 0 2.CITY | .001902 .006178 0.31 0.758 -.010206 .014011 1 ------------------------------------------------------------------------------- dp/dx for factor levels is the discrete change from the base level variable base m8CLASS 1 m9CLASS 1 M25Adum 0 M25EnvDum 0 CITY 1 . end of do-file
Code:
. cmclogit choice Ttime, casevars(i.m8CLASS i.m9CLASS i.M25Adum i.M25EnvDum /// > i.CITY) basealternative(1) vce(bootstrap, reps(100)) (running cmclogit on estimation sample) Bootstrap replications (100) ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 .................................................. 50 .................................................. 100 Conditional logit choice model Number of obs = 5,097 Case ID variable: ID Number of cases = 1699 Alternatives variable: alternative Alts per case: min = 3 avg = 3.0 max = 3 Wald chi2(17) = 339.44 Log likelihood = -1394.0571 Prob > chi2 = 0.0000 (Replications based on 1,699 clusters in ID) ------------------------------------------------------------------------------ | Observed Bootstrap Normal-based choice | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- alternative | Ttime | -.0190327 .0012032 -15.82 0.000 -.021391 -.0166745 -------------+---------------------------------------------------------------- 1 | (base alternative) -------------+---------------------------------------------------------------- 2 | m8CLASS | 2 | .3283541 .1457998 2.25 0.024 .0425917 .6141165 3 | -.6963945 .2490934 -2.80 0.005 -1.184609 -.2081804 | m9CLASS | 2 | -.4007272 .1549979 -2.59 0.010 -.7045175 -.096937 3 | -.208201 .1488804 -1.40 0.162 -.5000012 .0835992 | 1.M25Adum | .7260046 .1559288 4.66 0.000 .4203898 1.031619 1.M25EnvDum | .2026583 .1373049 1.48 0.140 -.0664544 .471771 | CITY | 2 | .1318349 .1689217 0.78 0.435 -.1992455 .4629153 3 | 1.105557 .1764517 6.27 0.000 .7597184 1.451396 | _cons | -1.244998 .2069153 -6.02 0.000 -1.650544 -.839451 -------------+---------------------------------------------------------------- 3 | m8CLASS | 2 | .2417938 .1519654 1.59 0.112 -.0560529 .5396405 3 | -.2168523 .2704695 -0.80 0.423 -.7469628 .3132581 | m9CLASS | 2 | -.3370252 .2004097 -1.68 0.093 -.7298209 .0557705 3 | -.056632 .1869742 -0.30 0.762 -.4230946 .3098306 | 1.M25Adum | .2834844 .143018 1.98 0.047 .0031742 .5637945 1.M25EnvDum | .2357513 .1439977 1.64 0.102 -.0464791 .5179816 | CITY | 2 | .0666527 .1918544 0.35 0.728 -.3093752 .4426805 3 | .1945577 .1861181 1.05 0.296 -.1702271 .5593425 | _cons | .0196005 .2702661 0.07 0.942 -.5101112 .5493122 ------------------------------------------------------------------------------ . estimates store worktrip . margins, dydx(*) predict(pr) outcome(1) atmeans post no observations r(2000); end of do-file
Code:
. estimates restore worktrip (results worktrip are active now) . margins, dydx(m8CLASS) predict(pr) outcome(1) atmeans nose post casevar not constant within case Casevar 2.m8CLASS is not constant within case for 515 cases (3717 obs). r(459);
Code:
. estimates restore worktrip (results worktrip are active now) . margins, dydx(m8CLASS) predict(pr) outcome(1) nose Average marginal effects Number of obs = 5,097 Expression : Pr(alternative|1 selected), predict(pr) Outcome : 1 dy/dx w.r.t. : 2.m8CLASS 3.m8CLASS ------------------------------------------------------------------------------ | dy/dx -------------+---------------------------------------------------------------- m8CLASS | 2 | -.0000415 3 | .0000701 ------------------------------------------------------------------------------ Note: dy/dx for factor levels is the discrete change from the base level.
I wonder whether I am doing something wrong with the cmclogit/margins commands or there is a solution to my problem. I already checked my database for possible string stored data but I have none as well as making sure that no case vars differ within the same case.
I would really appreciate if someone could help me with this issue,
Best,
AS
PS: Sorry for the very long post
0 Response to Unable to obtain marginal effects after cmclogit
Post a Comment