全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
10960 13
2009-04-02
請教各位,若我想用Sas跑heckman two stage以解決內生性問題,回歸如下Y1=a0+a1*x1+a2*x2+a3*x3~~~Y2=b0+b1*Y1+b2*x1+b3*x2+b4*x3~                                                                               該如何撰寫SAS語言來解決內生性問題???謝謝大家
二维码

扫码加我 拉你入群

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

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

全部回复
2009-4-3 07:35:00

libname data 'd:\heckman';
/***********************************************************************************/
/* Here we reprducing the Linear, Logit and Probit results  */

DATA mroz;
SET data.mroz1;

proc reg data=mroz;
 model hours= lwage nwifeinc age educ kidslt6 kidsge6;
 title1 'Linear Model Estimates '; 
run;

PROC probit DATA=mroz ;
 class  inlf;
 model  inlf= nwifeinc educ exper expersq age kidslt6 kidsge6 / covb;
 title2 'Probit Model Estimates ';
run;

proc probit data=mroz;
 class  inlf;
 model inlf= nwifeinc educ exper expersq age kidslt6 kidsge6/ d=logistic;
 title3 'Logit Model Estimates ';
run;

/*************************************************************************************/
/*----HECKMAN 2-STAGE ESTIMATION----*/
/*----STAGE 1: PROGRAM TO ESTIMATE M1----*/

DATA stage1;
SET data.mroz1;


PROC probit DATA=stage1 ;
class  inlf;
model  inlf=  nwifeinc educ exper expersq age kidslt6 kidsge6 / covb;
OUTPUT OUT=PREDS XBETA=ZALFA1;
title4 'First Stage:  Probit Estimates of Selection';
run;
/*----ZALFA IS USED TO ESTIMATE M1 FROM EQUATION 1----*/
DATA PREDS;
SET PREDS;
PDFZALFA1 = PDF('NORMAL',ZALFA1) ; /*PDFZALFA = NORMAL PROB DENSITY FUNCTION OF ZALFA*/
CDFZALFA1 = CDF('NORMAL',ZALFA1) ; /*CDFZALFA = CUMULATIVE  DENSITY FUNCTION OF ZALFA*/
P         = inlf                 ; /*EQUATION 1: P = 1  if in labor force, 1975      */
MMILLS    = (PDFZALFA1/CDFZALFA1); /*MMILLS   = MILLS RATIO                          */
RUN;

/*New data set */
DATA data.AHEKCHEK;    
SET PREDS;
RUN;

/*----HECKMAN 2-STAGE ESTIMATION----*/
DATA AHECKMAN1;
SET data.AHEKCHEK;

PROC REG DATA=AHECKMAN1;
MODEL lwage=  educ exper expersq  MMILLS;
RUN;
/***************************************************************************************/

二维码

扫码加我 拉你入群

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

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

2009-4-3 07:37:00

为什么不用stata呢,stata里面实现很简单。

Examples

    Setup
        . webuse womenwk

    Obtain full ML estimates
        . heckman wage educ age, select(married children educ age)

    Obtain Heckman's two-step consistent estimates
        . heckman wage educ age, select(married children educ age) twostep

    Define and use each equation separately
        . global wage_eqn wage educ age
        . global seleqn married children age
        . heckman $wage_eqn, select($seleqn)

    Use a variable to identify selection
        . generate wageseen = (wage < .)
        . heckman wage educ age, select(wageseen = married children educ age)

    Specify robust variance
        . heckman wage educ age, select(married children educ age) vce(robust)

    Specify clustering on county
        . heckman $wage_eqn, select($seleqn) vce(cluster county)

    Report first-step probit estimates
        . heckman wage educ age, select(married children educ age) first

    Create mymills containing nonselection hazard
        . heckman $wage_eqn, select($seleqn) mills(mymills)

    No constant in model
        . heckman wage educ age, noconstant select(married children educ age)

    No constant in selection equation
        . heckman wage educ age, select(married children educ age, noconstant)

二维码

扫码加我 拉你入群

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

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

2009-4-4 03:09:00

謝謝版主~可否更詳細幫我敘述SAS的指令~因為有些地方我看不太懂~我是跑一般迴歸:Y1=a0+a1*x1+a2*x2+a3*x3
以及Y2=b0+b1*Y1+b2*x1+b3*x2+b4*x3~~~因此~這種情形具有內生性的變數是否為:Y1 x1 x2 x3 呢???那該如何解決???我看很多案例~都跟我不太相似~因此很不確定~麻煩了解的人幫忙一下~感激不禁!!!

二维码

扫码加我 拉你入群

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

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

2009-4-4 10:05:00

我上面的是heckman模型的程序。你可能对heckman理解的不同。

你最好看看计量经济学的书。

先把内生性问题如何理论上解决,然后在说程序。

二维码

扫码加我 拉你入群

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

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

2009-4-4 12:54:00

恩恩~我會在去看仔細點~我只知道個大概~細節沒有很清楚~感謝您!!!

二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群