楼主: sewind_tj
13002 18

[回归分析求助] 请问斑竹关于工具变量分位数回归 [推广有奖]

  • 47关注
  • 7粉丝

已卖:61份资源

副教授

68%

还不是VIP/贵宾

-

威望
0
论坛币
13840 个
通用积分
157.4302
学术水平
47 点
热心指数
36 点
信用等级
16 点
经验
841 点
帖子
553
精华
0
在线时间
1357 小时
注册时间
2008-1-22
最后登录
2020-8-21

楼主
sewind_tj 发表于 2012-9-11 10:12:34 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
请问斑竹关于工具变量分位数回归目前是否有相关的命令?

二维码

扫码加我 拉你入群

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

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

关键词:分位数回归 工具变量 分位数 斑竹 工具

本帖被以下文库推荐

善待你一生!
让网络基于真人的故事!

沙发
夸克之一 发表于 2012-9-11 10:31:39
https://www.msu.edu/~kwakdo/

Kwak, D. (2010). Implementation of instrumental variable quantile regression (IVQR) methods. [pdf]

(Abstract) A new Stata command, ivqreg, is introduced to perform a quantile regression for estimating treatment effect using the robust standard error formula in Chernozhukov and Hansen (2006) for an exactly-identified instrumental variable case and the formula in Chernozhukov and Hansen (2008) for an over-identified instrumental variable case. We examine finite sample properties of the instrumental variable quantile regression (IVQR) estimator for convergence and coverage using Monte Carlo simulations. We demonstrate the uses of ivqreg command on data on educational achievement and earnings.

Kwak, D. (2010). Inverse probability weighted estimation for the effect of kindergarten enrollment age and peer quality on student academic achievement for grades K-12.

(Abstract) Using Tennessee's Project STAR experiment data and focusing on kindergarten entering students aged 5, we estimate the effect of kinder entering age on academic achievement for grades K-12. We estimate the age effect on achievement by inverse probability weighted (IPW) estimator since STAR sample has substantial missing data by attrition such that only 2,813 students out of 5,440 students remain in the program by the end of program. We find that age has positive effect until first grade and no statistically significant effect for second and third graders. However, age has statistically significant negative effect afterward. Furthermore, we also estimate the long-run effect of peer quality on academic achievement for grades K-12. Random assignments of students and teachers in the Project STAR experiment guarantee that the peer quality effect to be exogenous once we successfully control for missing data. Peer quality measures are constructed using the class average scores of cognitive and non-cognitive skill tests for grades in K-3. IPW estimates provide evidence that peer quality in K-3 has an long-term positive effect on student academic achievement. The positive effect of peer quality persists throughout all grades including high school grade.
已有 2 人评分学术水平 热心指数 信用等级 收起 理由
日新少年 + 2 + 2 + 2 精彩帖子
dream521 + 1 + 1 + 1 精彩帖子

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

藤椅
sewind 发表于 2012-9-11 21:07:53
夸克之一 发表于 2012-9-11 10:31
https://www.msu.edu/~kwakdo/

Kwak, D. (2010). Implementation of instrumental variable quantile re ...
谢谢夸克之一。
Long for you forever!

板凳
sewind 发表于 2012-9-11 21:20:30
夸克之一 发表于 2012-9-11 10:31
https://www.msu.edu/~kwakdo/

Kwak, D. (2010). Implementation of instrumental variable quantile re ...
请您指点一下,有几个途径能获得ivqreg命令呢?
Long for you forever!

报纸
夸克之一 发表于 2012-9-11 21:25:44
sewind 发表于 2012-9-11 22:20
请您指点一下,有几个途径能获得ivqreg命令呢?
IV_qreg1.pdf (427.86 KB)


地板
sewind 发表于 2012-9-12 09:12:45
夸克之一 发表于 2012-9-11 21:25
实在不好意思在打扰夸克版主。
我在stata公司查询了一下,ivqreg还没有公布。
如果要想获得ivqreg.ado,是否需要向作者写信索取,对吗?
Long for you forever!

7
夸克之一 发表于 2012-9-12 09:26:33
不需要吧。。。我记得有的啊。

*! ivqreg version DowonKwak 1.0.0 28July2010
program define ivqreg, eclass byable(onecall)
        version 10.1

        if _by() {
                local BY `"by `_byvars'`_byrc0':"'
        }
        if replay() {
                if ("`e(cmd)'"!="myprog") error 301

                Replay `0'
                exit
        }
        `BY' Estimate `0'
end

program Estimate, eclass byable(recall) sort

local cmdline `"ivqreg `0'"'

* step 1: parsing
gettoken lhs 0 : 0

gettoken p 0 : 0, parse(" (") quotes
while `"`p'"' != "(" {
        local inexog `"`inexog' `p'"'
        gettoken p 0 : 0, parse(" (") quotes
}

gettoken q 0 : 0, parse(" =") quotes
while `"`q'"' != "=" {
        local endo `"`endo' `q'"'
        gettoken q 0 : 0, parse(" =") quotes
}

gettoken r 0 : 0, parse(" )") quotes
while `"`r'"' != ")" {
        local instr `"`instr' `r'"'
        gettoken r 0 : 0, parse(" )") quotes
}

local allinstr `"`inexog' `instr'"'
local rhs `"`endo' `inexog'"'

* step 2: Syntax

local options "Level(cilevel)"
        syntax [if] [in] [,                ///
        `options'                          ///
         noConstant                        ///
         Quantil(real 0.5)                 ///
         Robust                            ///
         * ]
                if "`constan'"!="" {
                        di in red "nocons invalid"
                        exit 198
                }
                if `quantil' >= 1 {
                        local quant = `quantil'/100
                }
                else    local quant "`quantil'"
                if `quant' <= 0 | `quant' >= 1 {
                        di in red "quantiles(`quantil') out of range"
                        exit 198
                }
       
        /* count what is left over after marking out sample             */
        cap count if `touse'
        local N = r(N)
        if (`N' == 0) error 2000

* Step 3: Initial Two stage quantile regression for construnction of grid
marksample touse
markout `touse' `lhs' `endo' `instr' `inexog' `allinstr' `rhs'

qui regress `endo' `allinstr' if `touse'
predict dhat, xb
local dhat dhat
keep if `touse'

display _newline "Initial Estimation: `quantil'th Two Stage Quantile Regression" _col(60) "Number of obs = " e(N)
qui qreg `lhs' `dhat' `inexog' if `touse', q(`quantil')
predict iner if `touse', resid
matrix btwo=e(b)
scalar bdht=btwo[1,1]
matrix vtwo=e(V)
local vnames `endo' `inexog' _cons
matrix rownames vtwo = `vnames'
matrix colnames vtwo = `vnames'
matrix colnames btwo = `vnames'
ereturn post btwo vtwo, depname(`lhs') obs(`e(N)') esample(`touse')
ereturn display

display _newline in yellow "Grid search is in progress (200)"

marksample touse
markout `touse'
tempname intv nn nz dh_se

mata: ivqr_initial("`lhs'", "`endo'", "`inexog'", "`instr'", "`dhat'", "iner", "`touse'")
drop iner
local nz nz
local nn nn

*set of grid
scal dh_se=sqrt((`nn'/100)*intv[1,1])
scal gll=bdht-2*dh_se
scal size=dh_se/50
matrix gr_alpha=J(200,2,.)
       
forvalues j=1/200 {
matrix gr_alpha[`j',1]=gll+`j'*size
}  

* step 3: Grid search               
forvalues j=1/50 {
        gen yo`j'k=`lhs'-`endo'*gr_alpha[`j',1]
        qui qreg yo`j'k `instr' `inexog' if `touse', q(`quantil')
        matrix b_al`j'l=e(b)
        predict er`j', resid
        display _col(`j') _continue .
}
display _col(52) 50

forvalues j=51/100 {
        gen yo`j'k=`lhs'-`endo'*gr_alpha[`j',1]
        qui qreg yo`j'k `instr' `inexog' if `touse', q(`quantil')
        matrix b_al`j'l=e(b)
        predict er`j', resid
        local k= `j'-50
        display _col(`k') _continue .
}

display _col(52) 100


forvalues j=101/150 {
        gen yo`j'k=`lhs'-`endo'*gr_alpha[`j',1]
        qui qreg yo`j'k `instr' `inexog' if `touse', q(`quantil')
        matrix b_al`j'l=e(b)
        predict er`j', resid
        local k= `j'-100
        display _col(`k') _continue .
}

display _col(52) 150

forvalues j=151/200 {
        gen yo`j'k=`lhs'-`endo'*gr_alpha[`j',1]
        qui qreg yo`j'k `instr' `inexog' if `touse', q(`quantil')
        matrix b_al`j'l=e(b)
        predict er`j', resid
        local k= `j'-150
        display _col(`k') _continue .
}

display _col(52) 200


* step 4: IV quantile regression                
forvalues j=1/200 {
marksample touse
markout `touse'
tempname vq
matrix b_gam=b_al`j'l[1,1..`nz']
mata: ivqr_grid("yo`j'k", "`endo'", "`inexog'", "`instr'", "er`j'", "`touse'")
matrix gr_alpha[`j',2] = vq
drop yo`j'k er`j'
                  }

        svmat gr_alpha, name(a_grid)       
        gsort a_grid2
        scal alpha_opt=a_grid1          
        drop a_grid1 a_grid2

* step 5: Standard errors for just-identified case
if `nz'==1 {      
   gen double yoptm = `lhs'-`endo'*alpha_opt
   qui qreg  yoptm  `instr' `inexog' if `touse', q(`quantil')
   matrix xzhat=e(b)
   matrix xhat=xzhat[.,`nz'+1...]
   qui predict ero, resid
   qui iqreg ero
   matrix iqrr=e(b)
   qui sum ero
   scal eeh = r(sd)               
   scal iqq = iqrr[1,1]/1.349
   scal iqr = min(iqq,eeh)
   matrix bhat=(alpha_opt, xhat)                                                        
   *This is the final estimate for theta
   matrix colnames bhat = `endo' `inexog' _cons

marksample touse
markout `touse'
tempname Vrb vn
mata: ivqr_rbstse("yoptm", "`endo'", "`inexog'", "`instr'", "ero", "`touse'")
drop ero dhat yoptm       
}       

* step 5-2: Standard errors for over-identified case
if `nz'>1 {

   gen double yoptm = `lhs'-`endo'*alpha_opt
   qui qreg  yoptm  `instr' `inexog' if `touse', q(`quantil')
   matrix xzhat=e(b)
   matrix xhat=xzhat[.,`nz'+1...]
   qui predict ero, resid
   qui iqreg ero
   matrix iqrr=e(b)
   qui sum ero
   scal eeh = r(sd)               
   scal iqq = iqrr[1,1]/1.349
   scal iqr = min(iqq,eeh)                       
   matrix bhat=(alpha_opt, xhat)                                                        
   *This is the final estimate for theta
   matrix colnames bhat = `endo' `inexog' _cons


marksample touse
markout `touse'
tempname Vrb vn
mata: ivqrovi_rbstse("yoptm", "`endo'", "`inexog'", "`instr'", "ero", "`touse'")

drop ero dhat yoptm
}       

* step 6: return saved results
*// row and column names
local vnames `endo' `inexog' _cons
matrix rownames vn = `vnames'
matrix colnames vn = `vnames'
matrix rownames Vrb = `vnames'
matrix colnames Vrb = `vnames'
matrix colnames bhat = `vnames'

*// robust standard error option
local N = r(N)
if "`robust'" !="" {
        ereturn post bhat Vrb, depname(`lhs') obs(`N') esample(`touse')
       
                   }
        else    ereturn post bhat vn, depname(`lhs') obs(`N') esample(`touse')
                 
                  
*// Return as e() macro
ereturn local depvar ="`lhs'"
ereturn scalar N = r(N)
ereturn local cmdline `cmdline'
ereturn local title "Instrumental Variable `quantil'th Quantile Regression"
ereturn local cmd "ivqreg"

display _newline "`quantil'th Instrumental Variable Quantile Regression" _col(60) "Number of obs = " e(N)
ereturn display

end

8
sewind_tj 发表于 2012-9-12 11:42:33
夸克之一 发表于 2012-9-12 09:26
不需要吧。。。我记得有的啊。

*! ivqreg version DowonKwak 1.0.0 28July2010
安分感谢夸克帮助。
您给了我“鱼”,能不能教我如何“渔”的?
我是依次用了以下几个步骤
1、ssc inst ivqreg
2、findit ivqreg
3、google ivqreg.ado 和google ivqreg.hlp
您能不能告诉我是如何获得ivqreg.ado和ivqreg.hlp的?
善待你一生!
让网络基于真人的故事!

9
夸克之一 发表于 2012-9-12 11:46:51
sewind_tj 发表于 2012-9-12 12:42
安分感谢夸克帮助。
您给了我“鱼”,能不能教我如何“渔”的?
我是依次用了以下几个步骤
我真不记得了,应该是从那篇论文里找到线索的。。

10
sewind_tj 发表于 2012-9-12 12:32:47
夸克之一 发表于 2012-9-12 11:46
我真不记得了,应该是从那篇论文里找到线索的。。
哦,我仔细阅读一下这篇文章。
能不能把ivqreg.ado和ivqreg.hlp
传上来一份。
感谢夸克帮助!!!
善待你一生!
让网络基于真人的故事!

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-29 13:51