楼主: bobguy
2218 2

Numeric define elasticity of Multinomial Logit Model [推广有奖]

学科带头人

7%

还不是VIP/贵宾

-

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

中级热心勋章

楼主
bobguy 发表于 2010-1-25 04:49:43 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
Note: 1) This is a simulation(Monte Carlo), the results are close to the theoretical results.
          2) The theoretical results in the paper is valid for the assumption that offerings is the same within a given chioce -- which I implemented as,
    x1=    0.85+0.15*1;
    x2=    0.85+0.15*2;
    x3=    0.85+0.15*3;
    x4=    0.85+0.15*4;

         3) The numeric definition should be valid at any time.
         4) adjusted chg=0.01 to have a 'better' numerica derivative.
         5) when calculate elasticity for x1, everything else needs to be fixed including the errors.

Hope this is clear.





options notes;
%let size=80000;   ***simulation size;
%let Eulerconstant=0.5772156649015328606;


***error of extreme distribution;
data a;
  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;  
    ****alternative offering values;
    x1=    0.85+0.15*1;
    x2=    0.85+0.15*2;
    x3=    0.85+0.15*3;
    x4=    0.85+0.15*4;

    output;
  end;
  keep e: x:;
run;

%macro e(ovar=, factor=, dsn=);
data tmp;
   set a;
   ***4 choices**;

   array x(*)  x1-x4 ;
   array u(*) u1-u4;

   array e(*) e1-e4;
   do i=1 to 4;
       if upcase(vname(x(i)))= %upcase("&ovar") then  x(i)=&factor+x(i);
   end;
   ***unitility function, the parameters estimated from the model***;
  *** may have many covariates****;
  ***for simplicity, coef=1 and only one variable;
   do i=1 to 4;
       u(i)=0 + 1*x(i)  + e(i) ;
   end;

   max=max(u1,u2,u3,u4);

   do i = 1 to 4;
      if u(i)=max then choice=i;     
   end;
run;

****calculate means on each choice****;
proc sql;
  create table &dsn as
  select choice, count( choice ) as n, calculated n/&size as p,
           mean(x1) as x1m , mean(x2) as x2m,
           mean(x3) as x3m , mean(x4) as x4m
from tmp
group by  choice
;
quit;

proc print data=&dsn;run;
%mend;

%macro e2(dsn1=x1,dsn2=xx1, ovar=x1,chg=0.01) ;
%e(ovar=&ovar, factor=0, dsn=&dsn1);
%e(ovar=&ovar, factor=&chg, dsn=&dsn2);

data all;
  set &dsn1(keep=n choice p &ovar.m  rename=(p=p1  &ovar.m=&ovar));
  set &dsn2(keep=n p &ovar.m rename=(p=p2 n=n2 &ovar.m=&ovar._2));
  e1= ( (p1-p2)/(&ovar-&ovar._2) ) *( &ovar/p1);    ***elasticity evaluate at first point x(i);
  e2= ( (p1-p2)/(&ovar-&ovar._2) ) *(&ovar._2/p2);  ***elasticity evaluate at second point define as x(i)=&factor+x(i);
  &ovar.Chg=put( 100*(&ovar-&ovar._2) /&ovar, 8.2); ***change in x(i) in %;
run;

proc print; run;
%mend;

%e2(dsn1=x1,dsn2=xx1, ovar=x1,chg=0.01) ;

%e2(dsn1=x2,dsn2=xx2, ovar=x2,chg=0.01) ;

%e2(dsn1=x3,dsn2=xx3, ovar=x3,chg=0.01) ;

%e2(dsn1=x4,dsn2=xx4, ovar=x4,chg=0.01) ;
二维码

扫码加我 拉你入群

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

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

关键词:Multinomial elasticity elastic numeric DEFINE logit model elasticity Multinomial numeric

沙发
crackman 发表于 2010-1-25 07:19:12
牛人
值得学习
呵呵
谢谢

藤椅
hitomiao 发表于 2010-2-9 06:17:32
我刚刚开始学习multinomial logit model,觉得十分头疼,谢谢lz分享教程。

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 05:40