加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

条件Logit模型总结

(2013-05-04 12:29:57)
分类: 03SAS数据处理

条件Logit模型可以使用多个软件实现运算(SAS、STATA)

下表给出了一个详细说明:

http://www.ats.ucla.edu/stat/sas/faq/conditional_logit_sas.htm

明确一个问题,条件LOGIT模型中,每个主体,例如公司或者个人,存在多种选择的方案,但是 他们只能做出选择其中一个方案的选择,而不是多种选择。

所以条件LOGIT模型是一种简单化的MULTI-LOGIT模型。

Table 1.2 Procedures and Commands for CDVMs

 

Model SAS 9.2 Stata 11 LIMDEP 9.0 SPSS 17
OLS (Ordinary Least Squares) REG .regress Regress$ Regression
Binary Binary logit QLIM, LOGISTIC, GENMOD, PROBIT .logit, .logistic Logit$ Logistic regression
Binary Probit QLIM, LOGISTIC, GENMOD, PROBIT .probit Probit$ Probit
Bivariate Probit QLIM .biprobit Bivariateprobit$ -
Ordinal Ordered logit QLIM, LOGISTIC, GENMOD, PROBIT .ologit Ordered$, Logit$ Plum
Generalized logit - .gologit2* - -
Ordered Probit QLIM, LOGISTIC, GENMOD, PROBIT .oprobit Ordered$ Plum
Nominal Multinomial logit LOGISTIC, CATMOD .mlogit Mlogit$, Logit$ Nomreg
Conditional Logit LOGISTIC, MDC, PHREG .clogit Clogit$, Logit$ Coxreg
Nested logit MDC .nlogit Nlogit$** -
Multinomial probit - .mprobit - -
* A user-written command written by Williams (2005).
** The Nlogit$ command is supported by NLOGIT, a stand-alone package, which is sold separately.
 

 

 

麦克法登的贡献:

  丹尼尔·麦克法登(Daniel L McFadden)1937年生于美国北卡罗来那州的瑞雷(Raleigh, NC),在明尼苏达大学 (University of Minnesota)物理系获得学士学位后改念经济,1962 年于同校获得博士学位。曾在匹兹堡大学、耶鲁大学、麻省理工学院、和柏克莱加州大学任教,1990年后是柏克莱加州大学的讲座教授,现为加州大学伯克利分校经济学教授和计量经济学实验室主任。

     丹尼尔·麦克法登(Daniel L.McFadden,1937-)美国经济学家美,国加州大学伯克利分校教授麦克法登的贡献主要是他对分析离散抉择的理论和方法的发展。离散抉择分析是指个人在有限种可能中作出抉择的行为分析,如个人对职业、居住地、交通工具等的选择,都是有限的离散抉择。在麦克法登以前,对于离散变量的研究都缺乏经济理论基础。麦克法登从经典的微观经济学出发,创建了有效的条件逻辑特模型(Conditional Logit Model)。这种模型理论坚实,加之计算简单,因此现在被广泛介绍于竞技计量学教科书中。

    主要研究领域:计量经济学及经济学理论以往研究课题:隐含变量模式、选择模式及应用、大规模抽样计量经济学、抽样理论、经济生产理论以及消费理论。目前正在研究的课题有老龄化趋势经济学、储蓄行为,人口统计学趋势、住房流动性、健康和死亡比例研究、利用计量心理学数据进行的消费者需求分析以及计量经济学模拟方法研究。此次他以“对分析离散选择的原理和方法所做出的发展和贡献”而获2000年诺贝尔经济学奖。

    主要贡献:麦克法登最主要的贡献在于,对诸如不同交通工具或不同职业等的“类别选择”(Discrete Choices) 问题上,发展出一套完整的理论和实证方法。和赫克曼一样,麦克法登也很擅长于将经济理论和计量方法紧密结合起来,并将之应用到许多不同领域 (例如生产经济理论、运输经济学、环境经济学等) 的实证研究中。在一九七零年代以前, 经济理论和计量经济学的分析都局限于数值连续的经济变数 (像消费、所得、价格等) ,类别选择的问题虽然是无所不在,传统上却没有一个严谨的分析架构,麦克法登填补了这个空隙,他对类别选择问题的研究在很短的时间内就发展成为一个新兴领域,大大的扩充了经济理论和计量经济学的范围和适用性,许多其他社会科学的学门也因此获得一个十分有用的实证研究工具。

    对类别问题的分析:麦克法登对类别选择问题的分析可简单介绍如下: 在类别选择问题中,不论要选的类别是什么,每一个类别对做选择的经济个体来说都有或多或少的效用(没有效用的类别当然不会被考虑) ,一个类别的脱颖而出必然是因为该类别能产生出最高的效用。麦克法登将每一个类别的效用分解为两部份,第一个部分受“类别本身的特质”以及“做选择之经济个体的特质”所影响(了解这些特质是如何影响各个类别的效用便是实证分析的主要目的) ,而第二个部分则是一个随机变数,用以总结所有其他无法观察到的影响。也就是因为效用包含了这么一个随机变数,所以每一个类别的效用本身也都是随机的,影响所及各个类别之效用的大小不是固定不变, 而是随机变动的,换句语说经济个体不会固定的选择某一类别,我们最多只能说某个经济个体选择某某类别的机率是多少,这套想法麦克法登称之为“随机效用模型” (Random Utility Model 或简称 RUM) , 它让习惯于传统非随机效用理论之经济学家的眼界为之大开, 更大大扩展了效用理论的适用范围。

   Logit模型:麦克法登接着对随机效用做出一些巧妙的分配假设,使得选择各类别的机率 (乃至于整个概似函数) 都可以很简单的公式表示出来,我们因此可用标准的统计方法 (最大概似估计法) 将“类别特质”以及“经济个体特质”对类别选择的影响估计出来,麦克法登将这种计量模型取名为“条件 Logit 模型” (Conditional Logit Model) ,由于这种模型的理论坚实而计算简单,几乎没有一本计量经济学的教科书不特设专章介绍这种模型以及类似的“多项 Logit 模型”Multinomial Logit Model) 。

  多项 Logit型虽然好用,但和所有其他的计量模型一样都有某些限制,多项 Logit 模型最大的限制在于各个类别必须是对等的,因此在可供选择的类别中,不可有主要类别和次要类别混杂在一起的情形。例如在研究旅游交通工具的选择时,可将交通工具的类别粗分为航空、火车、公用汽车、自用汽车四大类,但若将航空类别再依三家航空公司细分出三类而得到总共六个类别,则多项 Logit 模型就不适用,因为航空、火车、公用汽车、自用汽车均属同一等级的主要类别,而航空公司的区别则很明显的是较次要的类别,不应该混杂在一起。在这个例子中,主要类别和次要类别很容易分辨,但在其他的研究中可能就不是那么容易,若不慎将不同层级的类别混在一起,则由多项 Logit 模型所得到的实证结果就会有误差。为解决这个问题,麦克法登除了设计出多个检定方法以检查这个问题是否存在外,还发展出一个较为一般化的“阶层多项 Logit 模型” (Nested Multinoimal Logit Model) ,不仅可同时处理主要类别和次要类别,尚保持多项 Logit 模型的优点:理论完整而计算简单。

  麦克法登本人也进行了许多利用多项 Logit 模型的实证研究,例如都市交通工具的选择、家庭用电需求、电语需求、老人住家需求等等。麦克法登曾更进一步的发展出可同时处理类别和连续型经济变数的混合模型,并将之应用到家庭对电器类别以及用电量 (连续型变数) 需求的实证研究上。毫无疑问的,多项 Logit 模型体系的建立和应用的普及,确定了麦克法登在计量经济学中宗师的地位。

  在不对等类别选择的问题上,文献中也还可找到一些可同时处理主要类别和次要类别的不同模型,但这些模型的估计都牵涉到多重积分以致计算繁复到几乎没有实用价值,麦克法登针对这个问题也发展出一种充分利用电脑计算能力的“模拟动差估计法” (Method of Simulated Moments) ,这个方法开创性的将应用数学中的数值方法和计量经济学紧密结合,又再次开启了一个崭新的跨领域研究课题。

 

http://www.indiana.edu/~statmath/stat/all/cdvm/cdvm7.html

The Conditional Logit Regression Model


Imagine a choice of the travel modes among air flight, train, bus, and car. The data set and model here are adopted from Greene (2003). The model examines how the generalized cost measure (cost), terminal waiting time (time), and household income (income) affect the choice.

These independent variables are not characteristics of subjects (individuals), but attributes of the alternatives. Thus, the data arrangement of the conditional logit model is different from that of the multinomial logit model (Figure 2).

Figure 2. Data Arrangement for the Conditional Logit Model

  +------------------------------------------------------------------------------+
  | subject   mode   choice   air   train   bus   cost   time   income   air_inc |
  |------------------------------------------------------------------------------|
                                      70     69       35        35 |
                                      71     34       35         0 |
                                      70     35       35         0 |
                                      30            35         0 |
                                      68     64       30        30 |
  |------------------------------------------------------------------------------|
                                      84     44       30         0 |
                                      85     53       30         0 |
                                      50            30         0 |
                                     129     69       40        40 |
                                     195     34       40         0 |
  …       …      …        …     …       …     …      …      …        …         
… … 

The example data set has four observations per subject, each of which contains attributes of using air flight, train, bus, and car. The dependent variable choice is coded 1 only if a subject chooses that travel mode. The four dummy variables, air, train, bus, and car, are flagging the corresponding modes of transportation. See the appendix for details about the data set.

Top

7.1 Conditional Logit in STATA (.clogit)

STATA has the .clogit command to estimate the condition logit model. The group() option specifies the variable (e.g., identification number) that identifies unique individuals.

. clogit choice air train bus cost time air_inc, group(subject)

Iteration 0:   log likelihood =  -205.8187  
Iteration 1:   log likelihood = -199.23679  
Iteration 2:   log likelihood = -199.12851  
Iteration 3:   log likelihood = -199.12837  
Iteration 4:   log likelihood = -199.12837  
 
Conditional (fixed-effects) logistic regression   Number of obs          840
                                                  LR chi2(6)          183.99
                                                  Prob > chi2         0.0000
Log likelihood = -199.12837                       Pseudo R2           0.3160
 
------------------------------------------------------------------------------
      choice |      Coef.   Std. Err.         P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         air |   5.207443   .7790551     6.68   0.000     3.680523    6.734363
       train |   3.869043   .4431269     8.73   0.000      3.00053    4.737555
         bus |   3.163194   .4502659     7.03   0.000     2.280689    4.045699
        cost |  -.0155015    .004408    -3.52   0.000     -.024141    -.006862
        time |  -.0961248   .0104398    -9.21   0.000    -.1165865   -.0756631
     air_inc |    .013287   .0102624     1.29   0.195    -.0068269     
.033401
--------------------------------------------------------------------------------------

Let us run the .listcoef command to compute factor changes in odds. For a one unit increase in the waiting time for a given travel mode, for example, we can expect a decrease in the odds of using that travel by 9 percent (or a factor of .9084), holding other variables constant.

. listcoef

clogit (N=840): Factor Change in Odds 
 
  Odds of: 1 vs 0
 
--------------------------------------------------
      choice |                  P>|z|    e^b  
-------------+------------------------------------
         air |   5.20744    6.684   0.000 182.6265
       train |   3.86904    8.731   0.000  47.8965
         bus |   3.16319    7.025   0.000  23.6460
        cost |  -0.01550   -3.517   0.000   0.9846
        time |  -0.09612   -9.207   0.000   0.9084
     air_inc |   0.01329    1.295   0.195   
1.0134
--------------------------------------------------

Top

7.2 Conditional Logit in SAS

SAS has the MDC procedure to fit the conditional logit model. The TYPE=CLOGIT indicates the conditional logit model; the ID statement specifies the identification variable; and the NCHOICE=4 tells that there are four choices of the travel mode.

PROC MDC DATA=masil.travel;
   MODEL choice = air train bus cost time air_inc /TYPE=CLOGIT NCHOICE=4;
   ID subject;
RUN;

                                       The MDC Procedure
 
                                   Conditional Logit Estimates
 
Algorithm converged.
 
 
                                        Model Fit Summary
 
                           Dependent Variable                   choice
                           Number of Observations                  210
                           Number of Cases                         840
                           Log Likelihood                   -199.12837
                           Maximum Absolute Gradient        2.73152E-8
                           Number of Iterations                      5
                           Optimization Method          Newton-Raphson
                           AIC                               410.25674
                           Schwarz Criterion                 430.33938
 
 
                                   Discrete Response Profile
 
                            Index    CHOICE     Frequency    Percent
 
                                                   58      27.62
                                                   63      30.00
                                                   30      14.29
                                                   59      28.10
 
 
                                    Goodness-of-Fit Measures
 
           Measure                       Value    Formula
 
           Likelihood Ratio (R)         183.99    2 * (LogL - LogL0)
           Upper Bound of R (U)         582.24    - 2 * LogL0
           Aldrich-Nelson                0.467    R / (R+N)
           Cragg-Uhler 1                0.5836    1 - exp(-R/N)
           Cragg-Uhler 2                0.6225    (1-exp(-R/N)) / (1-exp(-U/N))
           Estrella                     0.6511    1 - (1-R/U)^(U/N)
           Adjusted Estrella            0.6212    1 - ((LogL-K)/LogL0)^(-2/N*LogL0)
           McFadden's LRI                0.316    R / U
           Veall-Zimmermann             0.6354    (R * (U+N)) / (U * (R+N))
 
           N = # of observations, K = # of regressors
 
 
                                  Conditional Logit Estimates
 
                                      Parameter Estimates
 
                                                 Standard                 Approx
               Parameter     DF     Estimate        Error    t Value    Pr > |t|
 
               air                  5.2074       0.7791       6.68     <.0001
               train                3.8690       0.4431       8.73     <.0001
               bus                  3.1632       0.4503       7.03     <.0001
               cost                -0.0155     0.004408      -3.52     0.0004
               time                -0.0961       0.0104      -9.21     <.0001
               air_inc              0.0133       0.0103       1.29     
0.1954

Alternatively, you may use the PHREG procedure that estimates the Cox proportional hazards model for survival data and the conditional logit model.

In order to make the data set consistent with the survival analysis data, you need to create a failure time variable, failure=1–choice. The identification variable is specified in the STRATA statement. The NOSUMMARY option suppresses the display of the event and censored observation frequencies.

PROC PHREG DATA=masil.travel NOSUMMARY;
   STRATA subject;
   MODEL failure*choice(0)=air train bus cost time air_inc;
RUN;

                                      The PHREG Procedure
 
                                       Model Information
 
                             Data Set                 MASIL.TRAVEL
                             Dependent Variable       failure
                             Censoring Variable       choice
                             Censoring Value(s)       0
                             Ties Handling            BRESLOW
 
 
                            Number of Observations Read         840
                            Number of Observations Used         840
 
 
                                       Convergence Status
 
                         Convergence criterion (GCONV=1E-8) satisfied.
 
 
                                     Model Fit Statistics
 
                                             Without           With
                            Criterion     Covariates     Covariates
 
                            -2 LOG L         582.244        398.257
                            AIC              582.244        410.257
                            SBC              582.244        430.339
 
 
                            Testing Global Null Hypothesis: BETA=0
 
                    Test                 Chi-Square       DF     Pr > ChiSq
 
                    Likelihood Ratio       183.9869                <.0001
                    Score                  173.4374                <.0001
                    Wald                   103.7695                <.0001
 
 
                            Analysis of Maximum Likelihood Estimates
 
                          Parameter      Standard                                 Hazard
       Variable    DF      Estimate         Error    Chi-Square    Pr > ChiSq      Ratio
 
       air                5.20743       0.77905       44.6799        <.0001    182.625
       train              3.86904       0.44313       76.2343        <.0001     47.896
       bus                3.16319       0.45027       49.3530        <.0001     23.646
       cost              -0.01550       0.00441       12.3671        0.0004      0.985
       time              -0.09612       0.01044       84.7778        <.0001      0.908
       air_inc            0.01329       0.01026        1.6763        
0.1954      1.013

While the MDC procedure reports t statistics, the PHREG procedure computes chi-squared (e.g., 12.3671=-3.52^2). The PHREG presents the hazard ratio at the last column of the output, which is equivalent to the factor changes under the e^b column of the SPost .listcoef command.


http://www.ats.ucla.edu/stat/sas/faq/conditional_logit_sas.htm

How do I do a conditional logit model analysis in SAS 9.1?

PROC LOGISITC has been improved in SAS 9.1 It does a lot more than just logistic regression on binary outcome variables. On this page, we show two examples on using proc logistic for conditional logit models. For conditional logit model, proc logistic is very easy to use and it handles all kinds of matching, 1-1, 1-M matching, and in fact M-N matching.

Example 1: 1-1 Matching

This example is adapted from Chapter 7 of Applied Logistic Regression by Hosmer & Lemeshow (2000). You can download the SAS data file lbwt11.sas7bdat here.

The first 20 observations are listed below. Notice that variable pairid indicates that the observations are paired.

pairid lbwt age lastwt race smoke ptd ht ui race1 race2 race3 1 0 14 135 1 0 0 0 0 1 0 0 1 1 14 101 3 1 1 0 0 0 0 1 2 0 15 98 2 0 0 0 0 0 1 0 2 1 15 115 3 0 0 0 1 0 0 1 3 0 16 95 3 0 0 0 0 0 0 1 3 1 16 130 3 0 0 0 0 0 0 1 4 0 17 103 3 0 0 0 0 0 0 1 4 1 17 130 3 1 1 0 1 0 0 1 5 0 17 122 1 1 0 0 0 1 0 0 5 1 17 110 1 1 0 0 0 1 0 0 6 0 17 113 2 0 0 0 0 0 1 0 6 1 17 120 1 1 0 0 0 1 0 0 7 0 17 113 2 0 0 0 0 0 1 0 7 1 17 120 2 0 0 0 0 0 1 0 8 0 17 119 3 0 0 0 0 0 0 1 8 1 17 142 2 0 0 1 0 0 1 0 9 0 18 100 1 1 0 0 0 1 0 0 9 1 18 148 3 0 0 0 0 0 0 1 10 0 18 90 1 1 0 0 1 1 0 0 10 1 18 110 2 1 1 0 0 0 1 0
proc logistic data = lbwt11 descending; model lbwt = lastwt smoke race2 race3 ptd ht ui ; strata pairid; run;
The LOGISTIC Procedure Conditional Analysis Model Information Data Set ATS.LBWT11 Response Variable lbwt Number of Response Levels 2 Number of Strata 56 Model binary logit Optimization Technique Newton-Raphson ridge Model Information low brth wt < 2500g Number of Observations Read 112 Number of Observations Used 112 Response Profile Ordered Total Value lbwt Frequency 1 1 56 2 0 56 Probability modeled is lbwt=1. Strata Summary lbwt Response ------ Number of Pattern 1 0 Strata Frequency 1 1 1 56 112 Newton-Raphson Ridge Optimization Without Parameter Scaling Convergence criterion (GCONV=1E-8) satisfied. Model Fit Statistics Without With Criterion Covariates Covariates AIC 77.632 65.589 SC 77.632 84.618 -2 Log L 77.632 51.589 Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 26.0439 7 0.0005 Score 20.2669 7 0.0050 Wald 12.7208 7 0.0792 Analysis of Maximum Likelihood Estimates Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq lastwt 1 -0.0184 0.0101 3.3229 0.0683 smoke 1 1.4007 0.6278 4.9770 0.0257 race2 1 0.5714 0.6896 0.6864 0.4074 race3 1 -0.0253 0.6992 0.0013 0.9711 ptd 1 1.8080 0.7887 5.2557 0.0219 ht 1 2.3612 1.0861 4.7259 0.0297 ui 1 1.4019 0.6962 4.0554 0.0440 Odds Ratio Estimates Point 95% Wald Effect Estimate Confidence Limits lastwt 0.982 0.963 1.001 smoke 4.058 1.185 13.890 race2 1.771 0.458 6.842 race3 0.975 0.248 3.839 ptd 6.098 1.300 28.609 ht 10.603 1.262 89.115 ui 4.063 1.038 15.901

Example 2: 1-M matching

This example is adapted from Chapter 7 of Applied Logistic Regression by Hosmer & Lemeshow (2000). You can download the SAS data file bbdm13.sas7bdat here.

The first 20 observations are listed below. Notice that variable str indicates that there are four choices for each subject.

str obs fndx chk agmn wt mod wid nvmr 1 1 1 1 13 118 55 0 0 1 2 0 2 11 175 1 0 0 1 3 0 2 12 135 1 0 0 1 4 0 1 11 125 55 0 0 2 1 1 1 14 118 55 0 0 2 2 0 2 15 183 55 0 0 2 3 0 2 11 218 55 0 0 2 4 0 1 13 192 55 0 0 3 1 1 1 15 125 55 0 0 3 2 0 2 14 123 55 0 0 3 3 0 1 13 140 55 0 0 3 4 0 1 13 160 55 0 0 4 1 1 1 14 150 55 0 1 4 2 0 1 13 130 1 0 0 4 3 0 2 14 140 55 0 0 4 4 0 1 16 130 55 0 0 5 1 1 1 17 150 1 0 0 5 2 0 2 12 148 55 0 0 5 3 0 1 13 134 55 0 0 5 4 0 1 14 138 55 1 0
proc logistic data = bbdm13 descending; model fndx = chk agmn wt mod wid nvmr ; strata str; run;
` The LOGISTIC Procedure
Conditional Analysis
Model Information
Data Set ATS.BBDM13 Response Variable fndx Number of Response Levels 2 Number of Strata 50 Model binary logit Optimization Technique Newton-Raphson ridge
Model Information
final diagnosis
Number of Observations Read 200 Number of Observations Used 200
Response Profile
Ordered Total Value fndx Frequency
1 1 50 2 0 150
Probability modeled is fndx=1.
Strata Summary
fndx Response ------ Number of Pattern 1 0 Strata Frequency
1 1 3 50 200
Newton-Raphson Ridge Optimization
Without Parameter Scaling
Convergence criterion (GCONV=1E-8) satisfied. Model Fit Statistics
Without With Criterion Covariates Covariates
AIC 138.629 102.430 SC 138.629 122.220 -2 Log L 138.629 90.430
Testing Global Null Hypothesis: BETA=0
Test Chi-Square DF Pr > ChiSq
Likelihood Ratio 48.1998 6 <.0001 Score 39.9247 6 <.0001 Wald 25.2218 6 0.0003
Analysis of Maximum Likelihood Estimates
Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq
chk 1 -1.1218 0.4474 6.2862 0.0122 agmn 1 0.3561 0.1292 7.6013 0.0058 wt 1 -0.0284 0.00998 8.0771 0.0045 mod 1 0.00376 0.0120 0.0984 0.7538 wid 1 -0.4916 0.8173 0.3618 0.5475 nvmr 1 1.4722 0.7582 3.7701 0.0522
Odds Ratio Estimates
Point 95% Wald Effect Estimate Confidence Limits
chk 0.326 0.135 0.783 agmn 1.428 1.108 1.839 wt 0.972 0.953 0.991 mod 1.004 0.980 1.028 wid 0.612 0.123 3.035 nvmr 4.359 0.986 19.264

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有