discrete choice modeling
DESCRIPTION
William Greene Stern School of Business New York University. Discrete Choice Modeling. Lab Sessions. Lab Session 2. Analyzing Binary Choice Data. Data Set: Load PANELPROBIT.LPJ. Fit Basic Models. Partial Effects for Interactions. Partial Effects. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/1.jpg)
Discrete Choice Modeling
William GreeneStern School of BusinessNew York University
Lab Sessions
![Page 2: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/2.jpg)
Lab Session 2
Analyzing Binary Choice Data
![Page 3: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/3.jpg)
Data Set: Load PANELPROBIT.LPJ
![Page 4: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/4.jpg)
Fit Basic Models
![Page 5: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/5.jpg)
Partial Effects for Interactions
21 2 3 4
1 3 4
2 4
Prob[ 1| ] [ ] [ ]Partial Effects?
[ ]( 2 )
[ ]( )
Compute without extensive additional computation ofe
y x x z x xzA
P A x zxP A xz
xtra variables, etc.
![Page 6: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/6.jpg)
Partial Effects Build the interactions into the model
statement PROBIT ; Lhs = Doctor
; Rhs = one,age,educ,age^2,age*educ $
Built in computation for partial effects PARTIALS ; Effects:
Age & Educ = 8(2)20 ; Plot(ci) $
![Page 7: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/7.jpg)
Average Partial Effects---------------------------------------------------------------------Partial Effects Analysis for Probit Probability Function---------------------------------------------------------------------Partial effects on function with respect to AGEPartial effects are computed by average over sample observationsPartial effects for continuous variable by differentiationPartial effect is computed as derivative = df(.)/dx---------------------------------------------------------------------df/dAGE Partial Standard(Delta method) Effect Error |t| 95% Confidence Interval---------------------------------------------------------------------Partial effect .00441 .00059 7.47 .00325 .00557EDUC = 8.00 .00485 .00101 4.80 .00287 .00683EDUC = 10.00 .00463 .00068 6.80 .00329 .00596EDUC = 12.00 .00439 .00061 7.18 .00319 .00558EDUC = 14.00 .00412 .00091 4.53 .00234 .00591EDUC = 16.00 .00384 .00138 2.78 .00113 .00655EDUC = 18.00 .00354 .00192 1.84 -.00023 .00731EDUC = 20.00 .00322 .00250 1.29 -.00168 .00813
![Page 8: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/8.jpg)
Useful Plot
![Page 9: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/9.jpg)
More Elaborate Partial Effects
PROBIT ; Lhs = Doctor ; Rhs = one,age,educ,age^2,age*educ, female,female*educ,income $
PARTIAL ; Effects: income @ female = 0,1 ? Do for each subsample | educ = 12,16,20 ? Set 3 fixed values & age = 20(10)50 ? APE for each setting
![Page 10: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/10.jpg)
Constructed Partial Effects
![Page 11: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/11.jpg)
Predictions List and keep predictions Add ; List ; Prob = PFIT to the probit or logit command (Tip: Do not use ;LIST with large samples!)
Sample ; 1-100 $PROBIT ; Lhs=ip ; Rhs=x1 ; List ; Prob=Pfit $DSTAT ; Rhs = IP,PFIT $
![Page 12: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/12.jpg)
Testing a Hypothesis – Wald Test
SAMPLE ; All $PROBIT ; Lhs = IP ; RHS = Sectors,X1 $MATRIX ; b1 = b(1:3) ; v1 = Varb(1:3,1:3) $MATRIX ; List ; Waldstat = b1'<V1>b1 $CALC ; List ; CStar = CTb(.95,3) $
ˆ ˆ ˆ -1Wald = ( - ) [Est.Var( - )] ( - )
Wald Statistic
β 0 β 0 β 0
![Page 13: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/13.jpg)
Testing a Hypothesis – LM Test
PROBIT ; LHS = IP ; RHS = X1 $PROBIT ; LHS = IP ; RHS = X1,Sectors ; Start = b,0,0,0 ; MAXIT = 0 $
ˆ ˆ
ˆ
ˆ
0 0 -1 0
0
0
LM = ( ) [Est.Hessian ] ( )
=MLE with restrictions imposed
Hessian is computed at .
Lagrange Multiplier Test
g β g β
β
β
![Page 14: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/14.jpg)
Results of an LM test
Maximum iterations reached. Exit iterations with status=1.Maxit = 0. Computing LM statistic at starting values.No iterations computed and no parameter update done.+---------------------------------------------+| Binomial Probit Model || Dependent variable IP || Number of observations 6350 || Iterations completed 1 || LM Stat. at start values 163.8261 || LM statistic kept as scalar LMSTAT || Log likelihood function -4228.350 || Restricted log likelihood -4283.166 || Chi squared 109.6320 || Degrees of freedom 6 || Prob[ChiSqd > value] = .0000000 |+---------+--------------+----------------+--------+---------+----------+|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|+---------+--------------+----------------+--------+---------+----------+ Constant -.01060549 .04902957 -.216 .8287 IMUM .43885789 .14633344 2.999 .0027 .25275054 FDIUM 2.59443123 .39703852 6.534 .0000 .04580618 SP .43672968 .11922200 3.663 .0002 .07428482 RAWMTL .000000 .06217590 .000 1.0000 .08661417 INVGOOD .000000 .03590410 .000 1.0000 .50236220 FOOD .000000 .07923549 .000 1.0000 .04724409
Note: Wald equaled 163.236.
![Page 15: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/15.jpg)
Likelihood Ratio Test
PROBIT ; Lhs = IP ; Rhs = X1,Sectors $CALC ; LOGLU = Logl $PROBIT ; Lhs = IP ; Rhs = X1 $CALC ; LOGLR = Logl $CALC ; List ; LRStat = 2*(LOGLU – LOGLR) $
Result is 164.878.
LR = 2[LogL(unrestricted) -Logl(restricted)]
![Page 16: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/16.jpg)
Using the Binary Choice Simulator
Fit the model with MODEL ; Lhs = … ; Rhs = …Simulate the model withBINARY CHOICE ; <same LHS and RHS > ; Start = B (coefficients) ; Model = the kind of model (Probit or Logit) ; Scenario: variable <operation> = value / (may repeat) ; Plot: Variable ( range of variation is optional) ; Limit = P* (is optional, 0.5 is the default) $E.g.: Probit ; Lhs = IP ; Rhs = One,LogSales,Imum,FDIum $ BinaryChoice ; Lhs = IP ; Rhs = One,LogSales,IMUM,FDIUM ; Model = Probit ; Start = B ; Scenario: LogSales * = 1.1 ; Plot: LogSales $
![Page 17: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/17.jpg)
Estimated Model for Innovation
+---------+--------------+----------------+--------+---------+----------+|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|+---------+--------------+----------------+--------+---------+----------+ Index function for probability Constant -1.89382186 .20520881 -9.229 .0000 LOGSALES .16345837 .01766902 9.251 .0000 10.5400961 IMUM .99773826 .14091020 7.081 .0000 .25275054 FDIUM 3.66322280 .37793285 9.693 .0000 .04580618+---------------------------------------------------------+|Predictions for Binary Choice Model. Predicted value is ||1 when probability is greater than .500000, 0 otherwise.||------+---------------------------------+----------------+|Actual| Predicted Value | ||Value | 0 1 | Total Actual |+------+----------------+----------------+----------------+| 0 | 531 ( 8.4%)| 2033 ( 32.0%)| 2564 ( 40.4%)|| 1 | 454 ( 7.1%)| 3332 ( 52.5%)| 3786 ( 59.6%)|+------+----------------+----------------+----------------+|Total | 985 ( 15.5%)| 5365 ( 84.5%)| 6350 (100.0%)|+------+----------------+----------------+----------------+
![Page 18: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/18.jpg)
Effect of logSales on Probability
![Page 19: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/19.jpg)
Model Simulation:
logSales Increases by 10% for all Firms in the Sample+-------------------------------------------------------------+|Scenario 1. Effect on aggregate proportions. Probit Model ||Threshold T* for computing Fit = 1[Prob > T*] is .50000 ||Variable changing = LOGSALES, Operation = *, value = 1.100 |+-------------------------------------------------------------+|Outcome Base case Under Scenario Change || 0 985 = 15.51% 300 = 4.72% -685 || 1 5365 = 84.49% 6050 = 95.28% 685 || Total 6350 = 100.00% 6350 = 100.00% 0 |+-------------------------------------------------------------+
![Page 20: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/20.jpg)
Lab Session 3
Bivariate Extensions of the Probit Model
![Page 21: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/21.jpg)
Bivariate Probit ModelTwo equation modelGeneral usage of
LHS = the set of dependent variables RH1 = one set of independent variables RH2 = a second set of variables
Economical use of namelists is useful here
Namelist ; x1=one,age,female,educ,married,working $Namelist ; x2=one,age,female,hhninc,hhkids $BivariateProbit ;lhs=doctor,hospital
;rh1=x1 ;rh2=x2;marginal effects $
![Page 22: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/22.jpg)
Heteroscedasticity in the Bivariate Probit Model
General form of heteroscedasticity in LIMDEP/NLOGIT: Exponential
σi = σ exp(γ’zi) so that σi > 0
γ = 0 returns the homoscedastic case σi = σ Easy to specify
Namelist ; x1=one,age,female,educ,married,working ; z1 = … $Namelist ; x2=one,age,female,hhninc,hhkids ; z2 = … $BivariateProbit ;lhs=doctor,hospital
;rh1=x1 ; hf1 = z1 ;rh2=x2 ; hf2 = z2$
![Page 23: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/23.jpg)
Heteroscedasticity in Marginal Effects
Univariate case:
If the variables are the same in x and z, these terms are added.
Sign and magnitude are ambiguousVastly more complicated for the bivariate
probit case. NLOGIT handles it internally.
( )
( )
( ) ( )
ii i
i
i i i
i i
i i i i
i i i
E[y | , ] =exp
E[y | , ]exp
E[y | , ]exp exp
β xx zγ z
x z β x βx γ z
x z β x β x γz γ z γ z
![Page 24: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/24.jpg)
Marginal Effects: Heteroscedasticity
+------------------------------------------------------+| Partial Effects for Ey1|y2=1 |+----------+---------------------+---------------------+| | Regression Function | Heteroscedasticity || +---------------------+---------------------+| | Direct | Indirect | Direct | Indirect || Variable | Efct x1 | Efct x2 | Efct h1 | Efct h2 |+----------+----------+----------+----------+----------+| AGE | .00190 | -.00012 | .00000 | .00000 || FEMALE | .10215 | .20688 | -.05880 | -.30944 || EDUC | -.00247 | .00000 | .00000 | .00000 || MARRIED | .00103 | .00000 | .00064 | .00476 || WORKING | -.02139 | .00000 | .00000 | .00000 || HHNINC | .00000 | .00154 | .00000 | .00000 || HHKIDS | .00000 | .00005 | .00000 | .00000 |+----------+----------+----------+----------+----------+
![Page 25: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/25.jpg)
Marginal Effects: Total Effects
+-------------------------------------------+| Partial derivatives of E[y1|y2=1] with || respect to the vector of characteristics. || They are computed at the means of the Xs. || Effect shown is total of 4 parts above. || Estimate of E[y1|y2=1] = .819898 || Observations used for means are All Obs. || Total effects reported = direct+indirect. |+-------------------------------------------++---------+--------------+----------------+--------+---------+----------+|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|+---------+--------------+----------------+--------+---------+----------+ Constant .000000 ......(Fixed Parameter)....... AGE .00347726 .00022941 15.157 .0000 43.5256898 FEMALE .08021863 .00535648 14.976 .0000 .47877479 EDUC -.00392413 .00093911 -4.179 .0000 11.3206310 MARRIED .00061108 .00506488 .121 .9040 .75861817 WORKING -.02280671 .00518908 -4.395 .0000 .67704750 HHNINC .00216510 .00374879 .578 .5636 .35208362 HHKIDS .00034768 .00164160 .212 .8323 .40273000
![Page 26: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/26.jpg)
Imposing Fixed Value and Equality Constraints
Used throughout LIMDEP in all models,model parameters appear as a long list:
β1 β2 β3 β4 α1 α2 α3 α4 σ and so on. M parameters in total.
Use ; RST = list of symbols for the model parameters, in the right order
This may be used for nonlinear models. Not in REGRESS. Use ;CLS:… for linear models
Use the same name for equal parametersUse specific numbers to fix the values
![Page 27: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/27.jpg)
BivariateProbit ; lhs=doctor,hospital ; rh1=one,age,female,educ,married,working ; rh2=one,age,female,hhninc,hhkids ; rst = beta1,beta2,beta3,be,bm,bw, beta1,beta2,beta3,bi,bk, 0.4 $
--------+-------------------------------------------------------------Variable| Coefficient Standard Error b/St.Er. P[|Z|>z] Mean of X--------+------------------------------------------------------------- |Index equation for DOCTORConstant| -1.69181*** .08938 -18.928 .0000 AGE| .01244*** .00167 7.440 .0000 44.3352 FEMALE| .38543*** .03157 12.209 .0000 .42277 EDUC| .08144*** .00457 17.834 .0000 10.9409 MARRIED| .42021*** .03987 10.541 .0000 .84539 WORKING| .03310 .03910 .847 .3972 .73941 |Index equation for HOSPITALConstant| -1.69181*** .08938 -18.928 .0000 AGE| .01244*** .00167 7.440 .0000 44.3352 FEMALE| .38543*** .03157 12.209 .0000 .42277 HHNINC| -.98617*** .08917 -11.060 .0000 .34930 HHKIDS| -.09406** .04600 -2.045 .0409 .45482 |Disturbance correlationRHO(1,2)| .40000 ......(Fixed Parameter)......--------+-------------------------------------------------------------
![Page 28: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/28.jpg)
Miscellaneous Topics
Two Step Estimation Robust (Sandwich) Covariance
matrix Matrix Algebra – Testing for
Normality
![Page 29: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/29.jpg)
Two Step Estimation
![Page 30: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/30.jpg)
Murphy and Topel
This can usually easily be programmed using the models, CREATE, CALC and MATRIX. Several leading cases are built in.
![Page 31: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/31.jpg)
Two Step Estimation: Automated
![Page 32: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/32.jpg)
Application: Recursive Probit
Hospital = bh’xh + c*Doctor + ehDoctor = bd’xd + ed
Sample ; All $Namelist ; xD=one,age,female,educ,married,working ; xH=one,age,female,hhninc,hhkids $Reject ; _Groupti < 7 $Probit ; lhs=hospital;rhs=xh,doctor$Probit ; lhs=doctor;rhs=xd;prob=pd;hold$Probit ; lhs=hospital;rhs=xh,pd;2step=pd$
![Page 33: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/33.jpg)
Robust Covariance Matrix
12ni=1
ML ML
12 2n ni=1 i=1
ML ML ML ML
Standard Covariance Matrix Estimator (General)logLˆ= ˆ ˆ
'Robust' (Sandwich) EstimatorlogL logL logL logˆ= ˆ ˆ ˆ ˆ
V
V
1ni=1
ML ML
Lˆ ˆ
TO WHAT SPECIFICATION 'ERRORS' IS THIS ESTIMATOR ROBUST? IN THE PROBIT CASES THE ESTIMATOR IS INCONSISTENT, SO NOT TO(1) HETEROSCEDASTICITY(2) OMITTED VARIABLES(3) WRONG DIS
TRIBUTIONAL ASSUMPTIONPOSSIBLY TO CROSS OBSERVATION CORRELATION.
![Page 34: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/34.jpg)
Robust Covariance Matrix ; ROBUST Using the health care data:
+---------------------------------------------+| Binomial Probit Model |+---------------------------------------------++---------+--------------+----------------+--------+---------+|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] |+---------+--------------+----------------+--------+---------+ |Index function for probabilityConstant| -.17336*** .05874 -2.951 .0032 AGE| .01393*** .00074 18.920 .0000 43.5257 FEMALE| .32097*** .01718 18.682 .0000 .47877 EDUC| -.01602*** .00344 -4.650 .0000 11.3206 MARRIED| -.00153 .01869 -.082 .9347 .75862 WORKING| -.09257*** .01893 -4.889 .0000 .67705 Robust VC=<H>G<H> used for estimates. Constant| -.17336*** .05881 -2.948 .0032 AGE| .01393*** .00073 19.024 .0000 43.5257 FEMALE| .32097*** .01701 18.869 .0000 .47877 EDUC| -.01602*** .00345 -4.648 .0000 11.3206 MARRIED| -.00153 .01874 -.082 .9348 .75862 WORKING| -.09257*** .01885 -4.911 .0000 .67705
![Page 35: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/35.jpg)
Cluster Correction PROBIT ; Lhs = doctor ; Rhs = one,age,female,educ,married,working ; Cluster = ID $
Normal exit: 4 iterations. Status=0. F= 17448.10+---------------------------------------------------------------------+| Covariance matrix for the model is adjusted for data clustering. || Sample of 27326 observations contained 7293 clusters defined by || variable ID which identifies by a value a cluster ID. |+---------------------------------------------------------------------+Variable| Coefficient Standard Error b/St.Er. P[|Z|>z] Mean of X--------+------------------------------------------------------------- |Index function for probabilityConstant| -.17336** .08118 -2.135 .0327 AGE| .01393*** .00102 13.691 .0000 43.5257 FEMALE| .32097*** .02378 13.497 .0000 .47877 EDUC| -.01602*** .00492 -3.259 .0011 11.3206 MARRIED| -.00153 .02553 -.060 .9521 .75862 WORKING| -.09257*** .02423 -3.820 .0001 .67705--------+-------------------------------------------------------------
![Page 36: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/36.jpg)
Using Matrix AlgebraNamelists with the current sample serve 2 major functions:
(1) Define lists of variables for model estimation (2) Define the columns of matrices built from the data.
NAMELIST ; X = a list ; Z = a list … $
Set the sample any way you like. Observations are now the rows of all matrices. When the sample changes, the matrices change.
Lists may be anything, may contain ONE, may overlap (some or all variables) and may contain the same variable(s) more than once
![Page 37: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/37.jpg)
Matrix Functions
Matrix Product: MATRIX ; XZ = X’Z $Moments and Inverse MATRIX ; XPX = X’X
; InvXPX = <X’X> $Moments with individual specific weights in variable w. Σi wi xixi’ = X’[w]X. [Σi wi xixi’ ]-1 = <X’[w]X>Unweighted Sum of Rows in a Matrix Σi xi = 1’XColumn of Sample Means (1/n) Σi xi = 1/n * X’1 or MEAN(X) (Matrix function. There are over 100 others.)Weighted Sum of rows in matrix Σi wi xi = 1’[w]X
![Page 38: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/38.jpg)
Normality Test for Probit
i i
i i i i
i i i3 i42
i3 i i4
Testing for normality in the probit model: RHS variables. y = LHS variable
Probit ModelProb[y 1| ] ( ), Normal CDF. ( ) density
[ ,z ,z ], z -(1/3)[( ) 1], z (1
x
x βx βx z x
βx
2i i
ii i i i
i i
1n n n 2i i i i i i i ii=1 i=1 i=1
/4){( )[3 ( ) ]}( ) e y ( ), d
( )[1 ( )]Lagrange Multiplier Statistic. ̂= compute at MLE of
ˆ ˆ ˆˆ ˆˆ ˆ ˆ LM= (ed) d (ed)
βx βxβxx
βx βxβ
z ' z z
Thanks to Joachim Wilde, Univ. Halle, Germany for suggesting this.
![Page 39: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/39.jpg)
Normality Test for Probit
NAMELIST ; XI = One,... $CREATE ; yi = the dependent variable $PROBIT ; Lhs = yi ; Rhs = Xi ; Prob = Pfi $CREATE ; bxi = b'Xi ; fi = N01(bxi) $CREATE ; zi3 = -1/2*(bxi^2 - 1) ; zi4 = 1/4*(bxi*(bxi^2+3)) $NAMELIST ; Zi = Xi,zi3,zi4 $CREATE ; di = fi/sqr(pfi*(1-pfi)) ; ei = yi - pfi
; eidi = ei*di ; di2 = di*di $MATRIX ; List ; LM = 1'[eidi]Zi * <ZI'[di2]Zi> * Zi'[eidi]1 $
![Page 40: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/40.jpg)
Multivariate Probit
MPROBIT ; LHS = y1,y2,…,yM ; Eq1 = RHS for equation 1 ; Eq2 = RHS for equation 2 … ; EqM = RHS for equation M $
Parameters are the slope vectors followed by the lower triangle of the correlation matrix
![Page 41: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/41.jpg)
Constrained Panel Probit
Sample ; 1 - 1270 $MPROBIT ; LHS = IP84, IP85, IP86 ; MarginalEffects ; Eq1 = One,Fdium84,SP84 ; Eq2 = One,Fdium85,SP85 ; Eq3 = One,Fdium86,SP86 ; Rst = b1,b2,b3,b1,b2,b3,b1,b2,b3,r45, r46, r56 ; Maxit = 3 ; Pts = 15 $ (Reduces time to compute)
![Page 42: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/42.jpg)
Estimated Multivariate Probit+---------------------------------------------+| Multivariate Probit Model: 3 equations. || Number of observations 1270 || Log likelihood function -2423.732 || Number of parameters 6 || Replications for simulated probs. = 15 |+---------------------------------------------++---------+--------------+----------------+--------+---------+----------+|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|+---------+--------------+----------------+--------+---------+----------+ Index function for IP84 Constant .13489406 .03467525 3.890 .0001 FDIUM84 .33571101 .47118274 .712 .4762 .05055702 SP84 .65662961 .13801209 4.758 .0000 .11012047 Index function for IP85 Constant .13489406 .03467525 3.890 .0001 FDIUM85 .33571101 .47118274 .712 .4762 .05051809 SP85 .65662961 .13801209 4.758 .0000 .11014611 Index function for IP86 Constant .13489406 .03467525 3.890 .0001 FDIUM86 .33571101 .47118274 .712 .4762 .05049439 SP86 .65662961 .13801209 4.758 .0000 .11016926 Correlation coefficients R(01,02) .46759312 .03716428 12.582 .0000 R(01,03) .37251014 .03946383 9.439 .0000 R(02,03) .46215054 .03721312 12.419 .0000
![Page 43: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/43.jpg)
![Page 44: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/44.jpg)
Endogenous Variable in Probit Model
PROBIT ; Lhs = y1, y2 ; Rh1 = rhs for the probit model,y2 ; Rh2 = exogenous variables for y2 $
SAMPLE ; All $CREATE ; GoodHlth = Hsat > 5 $PROBIT ; Lhs = GoodHlth,Hhninc ; Rh1 = One,Female,Hhninc ; Rh2 = One,Age,Educ $
![Page 45: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/45.jpg)
Lab Session 4
Panel DataBinary Choice Models with
Panel Data
![Page 46: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/46.jpg)
Telling NLOGIT You are Fitting a Panel Data Model
Balanced Panel Model ; … ; PDS = number of periods $ REGRESS ; Lhs = Milk ; Rhs = One,Labor ; Pds = 6 ; Panel $ (Note ;Panel is needed only for REGRESS)
Unbalanced Panel Model ; … ; PDS = group size variable $ REGRESS ; Lhs = Milk ; Rhs = One,Labor ; Pds = FarmPrds
; Panel $ FarmPrds gives the number of periods, in every period. (More later about unbalanced panels)
![Page 47: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/47.jpg)
Group Size Variables for Unbalanced Panels
Farm Milk Cows FarmPrds1 23.3 10.7 31 23.3 10.6 31 25 9.4 32 19.6 11 22 22.2 11 23 24.7 11 43 25.4 12 43 25.3 13.5 43 26.1 14.5 44 55.4 22 24 63.5 22 2
![Page 48: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/48.jpg)
Application to Spanish Dairy Farms Dairy.lpj
Input Units Mean Std. Dev. Minimum Maximum
Milk Milk production (liters) 131,108 92,539 14,110 727,281
Cows # of milking cows 2.12 11.27 4.5 82.3
Labor # man-equivalent units 1.67 0.55 1.0 4.0
Land Hectares of land devoted to pasture and crops.
12.99 6.17 2.0 45.1
Feed Total amount of feedstuffs fed to dairy cows (tons)
57,941 47,981 3,924.14 376,732
N = 247 farms, T = 6 years (1993-1998)
![Page 49: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/49.jpg)
Global Setting for Panels
SETPANEL ; Group = the name of the ID variable ; PDS = the name of the groupsize variable to create $
Subsequent model commands state ;PANEL with no other specifications requred to set the panel.Some other specifications usually required for thespecific model – e.g., fixed vs. random effects.
![Page 50: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/50.jpg)
Dialog Boxes for Model Commands
![Page 51: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/51.jpg)
![Page 52: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/52.jpg)
Selecting PANEL from the Options Tab
![Page 53: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/53.jpg)
Load the Probit Data Set
Data for this session are PANELPROBIT.LPJ
Various Fixed and Random Effects ModelsRandom ParametersLatent Class
![Page 54: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/54.jpg)
Fixed Effects Models
? Fixed Effects Probit. ? Looks like an incidental parameters problem.Sample ; All $Namelist ; X = IMUM,FDIUM,SP,LogSales $Probit ; Lhs = IP ; Rhs = X ; FEM ; Marginal ; Pds=5 $Probit ; Lhs = IP ; Rhs = X,one ; Marginal $
![Page 55: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/55.jpg)
Logit Fixed Effects Models Conditional and Unconditional FE
? Logit, conditional vs. unconditionalLogit ; Lhs = IP ; Rhs = X ; Pds = 5 $ (Conditional)Logit ; Lhs = IP ; Rhs = X ; Pds = 5 ; Fixed $
![Page 56: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/56.jpg)
Hausman Test for Fixed Effects
? Logit: Hausman test for fixed effects?Logit ; Lhs = IP ; Rhs = X ; Pds = 5 $Matrix ; Bf = B ; Vf = Varb $Logit ; Lhs = IP ; Rhs = X,One $Calc ; K = Col(X) $Matrix ; Bp = b(1:K) ; Vp = Varb(1:K,1:K) $Matrix ; Db = Bf - Bp ; DV = Vf - Vp ; List ; Hausman = Db'<DV>Db $Calc ; List ; Ctb(.95,k) $
![Page 57: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/57.jpg)
Random Effects and Random Constant
? Random effects? Quadrature Based (Butler and Moffitt) EstimatorProbit ; Lhs = IP ; Rhs = X,One ; Random ; Pds = 5 $Calc ; List ; RhoQ = rho $? Simulation Based EstimatorProbit ; Lhs = IP ; Rhs = X,one ; RPM ; Pds = 5 ; Fcn = One(N) ; Halton ; Pts = 25 $Calc ; List ; RhoRP = b(6)^2/(1+b(6)^2) ; RhoQ $
![Page 58: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/58.jpg)
Unbalanced Panel Data SetLoad healthcare.lpjCreate group size variableExamine Distribution of Group Sizes
Sample ; all$Setpanel ; Group = id ; Pds = ti $Histogram ; rhs = ti $
![Page 59: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/59.jpg)
Group Sizes
![Page 60: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/60.jpg)
A Fixed Effects Probit Model
Probit ;lhs=doctor ; rhs=age,hhninc,educ,married ; fem ; panel ; Parameters $+---------------------------------------------+| Probit Regression Start Values for DOCTOR || Maximum Likelihood Estimates || Dependent variable DOCTOR || Weighting variable None || Number of observations 27326 || Iterations completed 10 || Log likelihood function -17700.96 || Number of parameters 5 || Akaike IC=35411.927 Bayes IC=35453.005 || Finite sample corrected AIC =35411.929 |+---------------------------------------------++---------+--------------+----------------+--------+---------+----------+|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|+---------+--------------+----------------+--------+---------+----------+ AGE .01538640 .00071823 21.423 .0000 43.5256898 HHNINC -.09775927 .04626475 -2.113 .0346 .35208362 EDUC -.02811308 .00350079 -8.031 .0000 11.3206310 MARRIED -.00930667 .01887548 -.493 .6220 .75861817 Constant .02642358 .05397131 .490 .6244
These are the pooled data estimates used to obtain starting values for the iterations to get the full fixed effects model.
![Page 61: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/61.jpg)
Fixed Effects Model
Nonlinear Estimation of Model ParametersMethod=Newton; Maximum iterations=100Convergence criteria: max|dB| .1000D-08, dF/F= .1000D-08, g<H>g= .1000D-08Normal exit from iterations. Exit status=0.+---------------------------------------------+| FIXED EFFECTS Probit Model || Maximum Likelihood Estimates || Dependent variable DOCTOR || Number of observations 27326 || Iterations completed 11 || Log likelihood function -9454.061 || Number of parameters 4928 || Akaike IC=28764.123 Bayes IC=69250.570 || Finite sample corrected AIC =30933.173 || Unbalanced panel has 7293 individuals. || Bypassed 2369 groups with inestimable a(i). || PROBIT (normal) probability model |+---------------------------------------------++---------+--------------+----------------+--------+---------+----------+|Variable | Coefficient | Standard Error |b/St.Er.|P[|Z|>z] | Mean of X|+---------+--------------+----------------+--------+---------+----------+ Index function for probability AGE .06334017 .00425865 14.873 .0000 42.8271810 HHNINC -.02495794 .10712886 -.233 .8158 .35402169 EDUC -.07547019 .04062770 -1.858 .0632 11.3602526 MARRIED -.04864731 .06193652 -.785 .4322 .76348771
![Page 62: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/62.jpg)
Computed Fixed Effects Parameters
![Page 63: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/63.jpg)
Lab Session 5
Modeling Heterogeneity with Random Parameters and Latent Classes
![Page 64: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/64.jpg)
Random Parameters Model? Random parameters specification?Logit ; Lhs = IP ; Rhs = One,IMUM,FDIUM,SP,LogSales ; Pds = 5 ; RPM ; Halton ; Pts = 25 ; Cor ; Fcn = One(n),IMUM(n),FDIUM(n) ; Marginal ; Parameters $Sample ; 1 - 1270 $Create ; bimum = 0 $Matrix ; bi = beta_i(1:1270,2:2) $Create ; bimum = bi $Kernel ; Rhs = bimum $
BIMUM
.84
1.68
2.52
3.36
4.20
.001.2000 1.2750 1.3500 1.4250 1.5000 1.57501.1250
Kernel density estimate for BIMUM
Dens
ity
![Page 65: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/65.jpg)
Random Parameters with Industry Heterogeneity
? Random parameters with industry heterogeneity? Examine effect of industry heterogeneity.Sample ; All $Logit ; Lhs = IP ; Rhs = One,IMUM,FDIUM,SP,LogSales ; Pds = 5 ; RPM = InvGood,RawMtl ; Halton ; Pts = 15 ; Cor ; Fcn = One(n),IMUM(n),FDIUM(n) ; Marginal ; Parameters $Create; Bimum = beta_i(firm,2) $Regress ; Lhs = Bimum ; Rhs = one,InvGood,RawMtl $
![Page 66: Discrete Choice Modeling](https://reader036.vdocument.in/reader036/viewer/2022081604/56816893550346895ddf1ebe/html5/thumbnails/66.jpg)
Latent Class Models
? Latent class modelsSample ; All $Logit ; Lhs = IP ; Rhs = X ; LCM ; Pds=5 ; Pts = 3 $Logit ; Lhs = IP ; Rhs = X ; LCM=Invgood,Rawmtl ; Pds=5 ; Pts = 3 $Logit ; Lhs = IP ; Rhs = X ; LCM ; Pds=5 ; Pts = 4 $Logit ; Lhs = IP ; Rhs = X ; LCM ; Pds=5 ; Pts = 5 $