Stata 从边际效应的coefplot(mlogit)中删除变量
我想在Stata中运行多项式逻辑回归后,通过coefplot创建一个关于边际效应的系数图。我希望获得以下方面的帮助: 我想在图中只保留一个变量——I.Coquent,它有6个类别,并希望从图中删除其他变量 此外,如果可能的话,我想保留I.court的所有类别,包括绘图中的基本类别。因此,正如附件中的图所示,目前我只能得到5个带有以下代码的类别 对于结果变量的类别,我希望保持如图所示,即所有四个类别的系数值,但水平表示置信区间CI 这是我迄今为止的代码和输出:Stata 从边际效应的coefplot(mlogit)中删除变量,stata,mlogit,marginal-effects,coefplot,Stata,Mlogit,Marginal Effects,Coefplot,我想在Stata中运行多项式逻辑回归后,通过coefplot创建一个关于边际效应的系数图。我希望获得以下方面的帮助: 我想在图中只保留一个变量——I.Coquent,它有6个类别,并希望从图中删除其他变量 此外,如果可能的话,我想保留I.court的所有类别,包括绘图中的基本类别。因此,正如附件中的图所示,目前我只能得到5个带有以下代码的类别 对于结果变量的类别,我希望保持如图所示,即所有四个类别的系数值,但水平表示置信区间CI 这是我迄今为止的代码和输出: mlogit edattain i.
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
在本例中,我希望在cofficient图中保留I.foreign的两个类别,而不是仅将1和0作为基本结果,以及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))