楼主: dicuike
15271 127

悬赏5000论坛币求高手帮助 [推广有奖]

  • 1关注
  • 8粉丝

教师

已卖:1339份资源

副教授

62%

还不是VIP/贵宾

-

威望
0
论坛币
18952 个
通用积分
0.4200
学术水平
20 点
热心指数
22 点
信用等级
18 点
经验
11655 点
帖子
375
精华
0
在线时间
1372 小时
注册时间
2005-6-16
最后登录
2025-9-11

楼主
dicuike 在职认证  发表于 2010-1-15 08:59:18 |AI写论文
5000论坛币
本人最近在做cross category dependence 的分析时遇到了编程方面的问题,请各位高手帮帮忙。如有兴趣的各位请向我发短信息,我们再结合原始数据进行接下来的工作。谢谢大家!

最佳答案

bobguy 查看完整内容

Here is the SAS pgm for the simulation data + estimation based on simulation data for a conditional logit model/a discreta choice model. The estimation uses the procedures both SAS canned procedure(proc MDC) and me written codes with SAS proc nlmixed. The results are much each other from both approaches. The results are concured with simulation parameters. ******************************** ...
关键词:悬赏500 0论坛币 求高手 论坛币 DEPENDENCE 论坛 高手 悬赏

本帖被以下文库推荐

dicuike@126.com 事在人为!

沙发
bobguy 发表于 2010-1-15 08:59:19
Here is the SAS pgm for the simulation data + estimation based on simulation data for a conditional logit model/a discreta choice model.

The estimation uses the procedures both SAS canned procedure(proc MDC) and me written codes with SAS proc nlmixed.

The results are much each other from both approaches. The results are concured with simulation parameters.

**************************************************************************************************************************;


/* cdf of extreme value type 1  is F(x)= exp(-exp(-x))

    an inverse transform on the cdf yields

      x = -log(-log(F(x))   */

%let size=500;
%let Eulerconstant=0.5772156649015328606;

data err_extreme;                 

  seed=7813430;

  do i=1 to &size;
    e1=-log(-log(ranuni(seed)) ) - &Eulerconstant;
    e2=-log(-log(ranuni(seed)) ) - &Eulerconstant;  
    e3=-log(-log(ranuni(seed)) ) - &Eulerconstant;  
    e4=-log(-log(ranuni(seed)) ) - &Eulerconstant;  
    output;
  end;
  keep e:;
run;

*verify the sample data;
proc corr data=err_extreme;               
  var e: ;
run;


data simudata;
   set err_extreme;
   ***4 choices**;
   seed= 6791534;
   x1= rannor(seed); ***dependent on choice, cost/benefit of particular choice;
   x2= rannor(seed); ***dependent on choice, cost/benefit of particular choice;
   x3= rannor(seed); ***dependent on choice, cost/benefit of particular choice;
   x4= rannor(seed); ***dependent on choice, cost/benefit of particular choice;
   z1= ranuni(seed)-1.5; ***dependent on choice, cost/benefit of particular choice;
   z2= ranuni(seed)-0.2; ***dependent on choice, cost/benefit of particular choice;
   z3= ranuni(seed)-0.3; ***dependent on choice, cost/benefit of particular choice;
   z4= ranuni(seed)-1.5; ***dependent on choice, cost/benefit of particular choice;

   ***choice related fixed cost/benefit only 3 can be identified;

  *simulation parameters ;
   int1=1;int2=2;int3=3;int4=0;

   u1= int1 + 0.4 * x1 - 1*z1  + 1* e1;
   u2= int2 + 0.4 * x2 - 1*z2  + 1* e2;  
   u3= int3 + 0.4 * x3 - 1*z3  + 1* e3;  
   u4= int4 + 0.4 * x4 - 1*z4  + 1* e4;

   max=max(u1,u2,u3,u4);
   if u1=max then do;
       choice=1;
       z=z1;
       x=x1;
   end;
   else if u2=max then do;
       choice=2;
       z=z2;
       x=x2;
   end;  
   else if u3=max then do;
       choice=3;
       z=z3;
       x=x3;
   end;  
   else do;
       choice=4;
       z=z4;
       x=x4;
   end;  
   keep z: x:  choice;
run;

proc print data=simudata(obs=10);
run;

proc freq data=simudata;
table choice;
run;

****shape the data for sas procedure;
data simudata2;
      set simudata;
      array xv(4)  x1-x4;
      array zv(4)  z1-z4;
      retain pid 0;
      pid + 1;
      do i = 1 to 4;
         mode = i;
         decision = ( choice = i );
         dmy1=(mode=1);dmy2=(mode=2);dmy3=(mode=3);dmy4=(mode=4);         
         xx =xv(i);
         zz =zv(i);
         output;
      end;
      keep dmy1 dmy2 dmy3 xx  zz  decision pid mode;
   run;

proc print data=simudata2(obs=10);
run;


***write your own ML estimation of discrete choice model***;

proc nlmixed data=simudata tech=DBLDOG ;
      parms  a1=0 a2=0 a3=0 b1=0.1 c1=-0.1   ;  
     
      a4=0.000;
      v1= min(1e50, a1+ b1 *  x1 +  c1* z1) ;
      v2= min(1e50, a2+ b1 *  x2+   c1* z2) ;
      v3= min(1e50, a3+ b1 *  x3 +  c1* z3) ;
      v4= min(1e50, a4+ b1 *  x4 +  c1* z4) ;

      pr1 =min(1e50, exp(v1));
      pr2 =min(1e50, exp(v2));
      pr3 =min(1e50, exp(v3));
      pr4 =min(1e50, exp(v4));
     
      tpr=pr1+pr2+pr3+pr4;
      if choice=1 then p=pr1/tpr;
      else if choice=2 then p=pr2/tpr;
      else if choice=3 then p=pr3/tpr;
      else if choice=4 then p=pr4/tpr;
  
      p=max(1e-12,p);
      log_like =log(p);

      model choice ~ general(log_like);
      
      run;

***SAS ***;
proc mdc data=simudata2( keep=dmy1 dmy2 dmy3 xx  zz  pid mode decision
  rename=(dmy1=a1 dmy2=a2 dmy3=a3  xx=x  zz = z)) ;

      model decision = a1 a2 a3 x  z  / type=clogit choice=(mode 1 2 3 4)
                               covest=hess;
      id pid;
      
   run;

藤椅
maximus11111 发表于 2010-1-15 12:20:18
可你只有4890个论坛币啊。。。。。。。。。。。。。。。

板凳
不够拉风 发表于 2010-1-15 17:16:17
这个 。。爱莫能助

报纸
liyang1987 发表于 2010-1-15 17:59:29
你具体到这是哪一学科领域的知识或困难

地板
本是平民 发表于 2010-1-15 18:25:11
楼主看来要卖身抵债了  嘿嘿

7
zyl1792 发表于 2010-1-15 18:34:06


没有那个机会了啊

8
财大小强 发表于 2010-1-15 20:02:32
论坛可以欠债么?

9
liuxiaqing 发表于 2010-1-15 20:40:48
maximus11111 发表于 2010-1-15 12:20
可你只有4890个论坛币啊。。。。。。。。。。。。。。。
发“悬赏贴”时已经从发贴人的帐户上扣除相应的论坛币了

10
可可咖啡因 发表于 2010-1-15 20:46:48
ddddddddddd
dddddddd

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

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