楼主: 6513
23778 32

[回归分析求助] IV-Oprobit 怎么做?——我的个人经验 [推广有奖]

  • 2关注
  • 13粉丝

已卖:4078份资源

博士生

82%

还不是VIP/贵宾

-

TA的文库  其他...

读一本好书

威望
0
论坛币
17436 个
通用积分
601.1555
学术水平
22 点
热心指数
18 点
信用等级
16 点
经验
29745 点
帖子
277
精华
0
在线时间
327 小时
注册时间
2013-1-20
最后登录
2026-1-30

楼主
6513 在职认证  发表于 2021-8-12 09:36:05 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
我们在使用stata的过程中,有时会碰到有序回归模型,使用oprobit,在解决内生性问题时,尝试使用工具变量进行处理,但是一般的教科书中只有IV-Probit的方法,几乎没有看到IV-Oprobit 的方法,因此,本贴结合自己的使用经验,试图给大家做个例子。

首先,第一步,要知道这个命令要用到cmp,我们help cmp来看一下介绍


关于版本要求,最好从Stata 13起步

    Versions 8.0.0 and 8.2.0 of cmp, released in mid-2017 and early 2018,
    include changes that can somewhat affect results in hierarchical models.
    An older version, 7.1.0, is available as a Github archive, and can be
    directly installed, in Stata 13 or later, via "net from
    https://raw.github.com/droodman/cmp/v7.1.0".

    Versions 8.6.2, released in June 2021, requires Stata 13 or later. The
    previous version works in Stata 11 and 12 too.


第二步,安装命令:ssc install ghk2,replace

第三步,大致知道cmp命令语句等式的意思

   To inform cmp about the natures of the dependent variables and about which
    equations apply to which observations, the user must include the
    indicators() option after the comma in the cmp command line. This must
    contain one expression for each equation. The expression can be a
    constant, a variable name, or a formula. Formulas that contain spaces or
    parentheses should be enclosed in quotes. For each observation, each
    expression must evaluate to one of the following codes, with the meanings
    shown:

        0 = observation is not in this equation's sample
        . = observation is in this equation's sample but dependent variable
        unobserved for this observation
        1 = equation is "continuous" for this observation, i.e., is linear
        with Gaussian error or is an uncensored observation in a tobit
        equation
        2 = observation is left-censored for this (tobit) equation at the
        value stored in the dependent variable
        3 = observation is right-censored at the value stored in the dependent
        variable
        4 = equation is probit for this observation
        5 = equation is ordered probit for this observation
        6 = equation is multinomial probit for this observation
        7 = equation is interval-censored for this observation
        8 = equation is truncated on the left and/or right (obsolete because
        truncation is now a general modeling feature)
        9 = equation is rank-ordered probit for this observation
        10 = equation is frational probit for this observation

    For clarity, users can execute the cmp setup subcommand, which defines
    global macros that can then be used in cmp command lines:

        $cmp_out = 0
        $cmp_missing = .

        $cmp_cont = 1

        $cmp_left = 2

        $cmp_right = 3

        $cmp_probit = 4

        $cmp_oprobit = 5

        $cmp_mprobit = 6

        $cmp_int = 7

        $cmp_trunc = 8 (deprecated)

        $cmp_roprobit = 9

        $cmp_frac = 10


第四步,举例说明

. cmp setup

. webuse laborsup


先来一个正常的oprobit,mprobit

. oprobit kids fem_inc male_educ

. margins, dydx(*) predict(outcome(#2))

. cmp (kids = fem_inc male_educ), ind($cmp_oprobit) qui

. margins, dydx(*) predict(eq(#1) outcome(#2) pr)


. webuse sysdsn3

. mprobit insure age male nonwhite site2 site3

. margins, dydx(nonwhite) predict(outcome(2))

. cmp (insure = age male nonwhite site2 site3, iia), nolr ind($cmp_mprobit) qui

. margins, dydx(nonwhite) predict(eq(#2) pr)



由于在help中没有直接的iv-oprobit,先借鉴下ivprobit

. ivprobit fem_work fem_educ kids (other_inc = male_educ), first

. version 13: margins, predict(pr) dydx(*)

. cmp (fem_work = other_inc fem_educ kids) (other_inc = fem_educ kids  male_educ), ind($ cmp_probit  $ cmp_cont)   

. margins, predict(pr) dydx(*) force


由此,我们大致可以推测出语法结构:

以y1为例,问卷中是一个五分类的变量,分别赋值1-5,现在转换成二分类的y2,赋值1和0,有变量x1,x2,x3,x4,其中,x1是解释变量,他的工具变量是mv,其它的x2,x3,x4是控制变量

那么,ivprobit模型为ivprobit y2 x2,x3,x4(x1=mv)

如果我们要做iv-oprobit,则变成:

cmp(y1=x1 x2 x3 x4)(x1=x2 x3 x4 mv),ind($ cmp_oprobit   $ cmp_cont)technique(dfp) nolrtest

可以看到cmp后边跟了两个等式,第一个等式,y1=x1 x2 x3 x4就是正常的oprobit回归中所有变量,第二个等式x1=x2 x3 x4 mv,就是将主要解释变量x1让它等于工具变量 加上x1以外的所有变量,

ind($cmp_oprobit   $cmp_cont)这个语法是固定的,要联系到第三步中这两个的意思,建议最好在help中复制这个命令,我自己做的时候,就老出错,不知道是不是括号的问题,后来改了才能进行,比如:

The indicators() option must contain 2 variables, one for each equation. Did you forget to type cmp setup?

technique(dfp) nolrtest是help文件中没怎么出现的,但我在别的提问中看到这个,目前还不知道意思,暂且加上

然后就是等结果,结果分为两部分

第一部分

Fitting individual models as starting point for full model fit.
Note: For programming reasons, these initial estimates may deviate from your specification.
      For exact fits of each equation alone, run cmp separately on each.

Iteration 0:   log likelihood =  -14235.01  
Iteration 1:   log likelihood = -13216.218  
Iteration 2:   log likelihood = -13210.845  
Iteration 3:   log likelihood = -13210.842  
Iteration 4:   log likelihood = -13210.842  

Ordered probit regression   一个模型


然后会出现

Warning: regressor matrix for _cmp_y1 equation appears ill-conditioned. (Condition number = 4140.8843.)
This might prevent convergence. If it does, and if you have not done so already, you may need to remove nearly
collinear regressors to achieve convergence. Or you may need to add a nrtolerance(#) or nonrtolerance option to the command line.
See cmp tips.


又是一个模型


Warning: regressor matrix for erzi equation appears ill-conditioned. (Condition number = 5012.1327.)
This might prevent convergence. If it does, and if you have not done so already, you may need to remove nearly
collinear regressors to achieve convergence. Or you may need to add a nrtolerance(#) or nonrtolerance option to the command line.
See cmp tips.

Fitting full model.


Iteration 0:   log likelihood = -18709.494  

接下来就是漫长的运行,一直到260多次,终于结束


Iteration 261: log likelihood = -18698.597  
Iteration 262: log likelihood = -18698.593  
Iteration 263: log likelihood = -18698.593  
Iteration 264: log likelihood = -18698.593  

Mixed-process regression  


终于出现了模型的结果,最后求一下边际效应

margins, dydx(*)


由于帖子被自动排版,出了很多问题,比如符号 $ 的 问题,导致$ cmp_oprobit     $cmp_cont 出现问题,我传一个word供大家观看。
以上就是我自己的操作经验,其实我自己也有点懵逼,不知道对错,欢迎大家指正、批评。


IV-Oprobit.doc (48.5 KB)


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:oprobit Probit 个人经验 Rob bit IV-Oprobit ;IV-oprobit

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Sunknownay + 3 + 3 + 3 鼓励积极发帖讨论

总评分: 学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

沙发
ZGYNLF119986 发表于 2021-8-12 15:27:21
LZ是个牛人啊!能否附上数据,大家学习一下,谢谢!

藤椅
6513 在职认证  发表于 2021-8-12 18:34:37
ZGYNLF119986 发表于 2021-8-12 15:27
LZ是个牛人啊!能否附上数据,大家学习一下,谢谢!
help cmp 什么都有

板凳
三重虫 发表于 2021-8-15 19:27:00

报纸
soleeeee 学生认证  发表于 2021-11-10 11:18:35 来自手机
请问您是怎么做检验的呢?我的也是多元有序模型,借鉴了您的经验之后工具变量的回归跑出来了,但不知道要怎么做检验,官方给的弱工具变量检验也跑不出来

地板
wangxinxin032 发表于 2021-12-27 19:27:32
soleeeee 发表于 2021-11-10 11:18
请问您是怎么做检验的呢?我的也是多元有序模型,借鉴了您的经验之后工具变量的回归跑出来了,但不知道要怎 ...
后来解决了吗?

7
haochaoting 发表于 2022-1-19 15:26:05
操作完之后报一下错误,lz遇到过这样的问题吗?小白求解答,非常感谢~~


cannot compute an improvement -- flat region encountered
convergence not achieved
convergence not achieved

8
6513 在职认证  发表于 2022-1-25 10:59:34
haochaoting 发表于 2022-1-19 15:26
操作完之后报一下错误,lz遇到过这样的问题吗?小白求解答,非常感谢~~
抱歉,我没遇到过,没办法帮助你

9
Senior123 发表于 2022-2-17 16:09:45
我看的文献里的命令跟你这不一样哎。IV ordered probit:cmp (fem educ = fem work) (kids = fem educ), indicators($cmp cont $cmp oprobit) nolrtest。我是了你的命令,和我这个出来的结果不一样。以下附上该文献(自己命名的,不要介意)
还有就是想问下,后续结果怎么解释,对于IV和cmp,完全一头蒙,后面还需要怎么操作呢。

10
其它用户名 学生认证  发表于 2022-3-11 17:42:42
楼主好,请问cmp(y1=x1 x2 x3 x4)(x1=x2 x3 x4 mv)中的第二个括号里为啥不仅仅等于x1的工具变量mv即可呢 为啥还要加上x2、x3、x4呢~谢谢

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-2-7 15:59