从边际效应系数图中删除变量 (mlogit)

Dropping variables from the coefplot of marginal effects (mlogit)

我想通过 coefplot 在 Stata 中 运行 多项逻辑回归后的边际效应上创建一个系数图。我想获得帮助的内容:

到目前为止,这是我的代码和输出:

mlogit edattain i.cohort3 both sex age agesqr i.ownershipd i.electric, base(1) nolog

margins, dydx(*) post

coefplot (, keep(*:1._predict) label(No Education)) ///
(, keep(*:2._predict) label(Primary))   ///
(, keep(*:3._predict) label(Secondary))  ///
(, keep(*:4._predict) label(Higher))  ///
, drop(both sex age agesqr 100.ownershipd 210.ownershipd 250.ownershipd 999.ownershipd ///
1.electric 2.electric _cons) swapnames xline(0) legend(rows(1))

下面是一个示例数据集:

* Example generated by -dataex-. To install: ssc install    dataex
clear
input int rep78 byte foreign int(price length weight)
. 0 6486 182 2520
2 0 4060 201 3330
4 0 5798 214 3700
1 0 4934 198 3470
3 0 5222 201 3210
3 0 4723 199 3200
. 0 4424 203 3420
2 0 4172 179 2690
5 1 9690 189 2830
3 1 6295 174 2070
4 1 9735 177 2650
4 1 6229 170 2370
5 1 4589 165 2020
4 1 5079 170 2280
4 1 8129 184 2750
3 1 4296 161 2130
end
label values foreign origin
label def origin 0 "Domestic", modify
label def origin 1 "Foreign", modify

在这种情况下,我想在系数图中保留 i.foreign 的两个类别,而不是仅将 10 作为基本结果省略,以及所有rep78 中的 5 个结果类别。我希望删除其他预测变量。

以下对我有用:

sysuse auto, clear

mlogit rep78 i.foreign price length weight, base(1) nolog
margins, dydx(*) post

coefplot (, keep(*.foreign:1._predict) label(rep78 1)) ///
(, keep(*.foreign:2._predict) label(rep78 2))   ///
(, keep(*.foreign:3._predict) label(rep78 3))  ///
(, keep(*.foreign:4._predict) label(rep78 4))  ///
(, keep(*.foreign:5._predict) label(rep78 5))  ///
,  omitted xline(0) legend(rows(1))