楼主: bobguy
1267 1

[SAS] region switch regression in proc nlmixed [推广有奖]

学科带头人

7%

还不是VIP/贵宾

-

威望
0
论坛币
14187 个
通用积分
28.9279
学术水平
344 点
热心指数
363 点
信用等级
228 点
经验
104882 点
帖子
1846
精华
0
在线时间
1608 小时
注册时间
2008-7-18
最后登录
2019-3-8

中级热心勋章

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
      When an error in a selection equation is correlated with regression equations, then these correlation measures have to be corrected in the likelihood function, otherwise the results will be biased.

      Here are a couple of procedures one can use.
1) nlmixed
2) qlim


      here is a link for the further reference ( first 2 pages)
http://siteresources.worldbank.org/DEC/Resources/movestay.pdf
  1. **************************************************;
  2. %let n=500;

  3. data Sigma (type=cov);
  4. infile cards;
  5. input _type_ $ _Name_ $ errz err0 err1;
  6. cards;
  7. cov errz 1 0.8 0.5
  8. cov err0 0.8 1 0.3
  9. cov err1 0.5 0.3 1
  10. ;
  11. run;

  12. proc simnormal data=sigma out=err_mat numreal=&n seed=134;
  13. var errz err0 err1;
  14. run;


  15. data sim;
  16.   set err_mat;
  17.    x0=rannor(123);
  18.    x1=rannor(123);
  19.    z=rannor(123);
  20.    s=1+2*z>errz;
  21.    if s=0 then y=2+2*x0+1.41*err0;
  22.    else        y=1+3*x1+0.2*err1;
  23.    if s=0 then y0=y;
  24.    else y1=y;

  25. run;

  26. proc nlmixed data=sim;
  27. parms a1 a2 b1 b2 z1 z2=1 s0=1 s1=0.5 r0 r1=0.01;
  28. /*s0=1; s1=0.2;*/
  29. err0=(y-a1-a2*x0);
  30. err1=(y-b1-b2*x1);

  31. pdf0=pdf('normal',err0,0,s0);
  32. pdf1=pdf('normal',err1,0,s1);

  33. if s=0 then do;
  34.     zbeta=(z1+z2*z+r0*(err0/s0))/sqrt(1-r0**2);
  35.     cdf=cdf('normal',zbeta);
  36.     prob=cdf;
  37.     lik=(1-prob)*pdf0;
  38. end;
  39. else   do;
  40.     zbeta=(z1+z2*z+r1*(err1/s1))/sqrt(1-r1**2);
  41.     cdf=cdf('normal',zbeta);
  42.     prob=cdf;
  43.     lik=(prob)*pdf1;
  44. end;
  45. ll=log(lik);
  46. model s ~ general(ll);
  47. run;

  48. proc qlim data=sim;
  49.    model s = z/discrete;
  50.    model y0 = x0 / select(s=0);
  51.    model y1 = x1 / select(s=1);
  52. run;
复制代码




二维码

扫码加我 拉你入群

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

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

关键词:proc nlmixed regression regressio regress nlmixed sigma Sigma sigma nlmixed region switch proc nlmixed

已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
xddlovejiao1314 + 100 + 100 + 3 + 3 + 3 精彩帖子
niuniuyiwan + 60 + 60 + 5 + 5 + 5 精彩帖子

总评分: 经验 + 160  论坛币 + 160  学术水平 + 8  热心指数 + 8  信用等级 + 8   查看全部评分

本帖被以下文库推荐

沙发
xddlovejiao1314 学生认证  发表于 2015-11-2 13:11:39 |只看作者 |坛友微信交流群
谢谢分享。
已有 1 人评分论坛币 收起 理由
niuniuyiwan + 10 精彩帖子

总评分: 论坛币 + 10   查看全部评分

使用道具

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

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 22:36