Discrete (Qualitative) Choice - PowerPoint PPT Presentation

About This Presentation
Title:

Discrete (Qualitative) Choice

Description:

7 Discrete (Qualitative) Choice Logit Model R ... – PowerPoint PPT presentation

Number of Views:148
Avg rating:3.0/5.0
Slides: 59
Provided by: 693588
Category:

less

Transcript and Presenter's Notes

Title: Discrete (Qualitative) Choice


1
?????? ?7?
  • ???????
  • Discrete (Qualitative) Choice
  • ???????
  • Logit Model

2
???????????Continuous choice and discrete choice
  • ???????????(?????)
  • Continuous(Quantitative) Choice
  • ?????????
  • ??????????
  • (????????????????)
  • ???(??)?????
  • Discrete(Quanlitative)Choice
  • ?????????????
  • (?????????????)
  • ???(discrete)?
  • ???(alternative)?????

5??
3
??????????Modeling of discrete choice
  • ???,???????alternative?????
  • Individual enumerates alternatives
  • ?????????????????????
  • Assign evaluation points for each alternative.
  • ???????????
  • Chose the alternative having the highest point

France 40?
USA 50?
China 60?
4
????????Deterministic Choice Models
  • ??????????????????????????????????
  • Individual always chose the alternative of the
    highest points.
  • ???????????,??????????
  • ?????????????????????
  • ???????,?????II????
  • ??????????????????????
  • ???????????,?????????
  • ???(???)???
  • ?????????????????
  • ????????? Fuzzy Choice Model

5
??????????????Probablistic Choice
  • ???? In many cases,
  • ?????????????????????????????? Both alternatives
    are possibly chosen, if the difference of utility
    was not large.
  • ????????????,?????????.

???A???????? Probability of choice of A
1
A??????? ????A??????? Utility of A is very
superior to that of B, A is almost chosen.
A??????? A?????????????? Utility of A is very
inferior to that of B, A is rarely chosen.
2?????? 50??
0
???A???-???B??? Utility of A Utility of B
6
???????Logit Model
  • S????????,???????????
  • ??????????????
  • 3???????????????????
  • 2000?????????
  • McFadden(1937-)???
  • ??????????????????????????????????????????????(???
    ??????)

7
2????????Binary (Binomial) Logit Model
  • ????2???? 2????????
  • When they have two alternatives
  • ??????(n?)????
  • Many alternatives
  • ?????????
  • Multinomial Logit

8
????????
?????????(????S??????????) Formulation of choice
shares
??????,ß??? estimation of parameter
values (?????????????????????????)
????????? prospect for choice share in the
future (????????????????????????)
9
?????????????????????????
  • ??????????????????6????????5????1????
  • ???????????????????????????????????????(??)
  • ?5???1?????????????????1?????????????p?????????
  • ??????????p5/6???????
  • ??????(???)Maximum Likelihood

10
???????????????Estimation of parameters in Logit
model based on the aggregated shares
  • ?????(???????????)
  • ??????????????????????p???? Observed share
  • ??????????????2?????????VA?VB????????
  • Utility differences are reversely calculated to
    meet with the obsereved share of two
    alternatives.
  • ??????????????????????????????
  • Adjust the parameters (functions) such that
    the proper utility difference are obtained.

11
???? Linear Regression
??
???????
2?(??)?????????????y??????????????????????
12
????? Maximum Likelihood(???????????????)
  • ???????6????????????5???????.????????????q??????
  • ??(??????????q)???????,??????????????????(????L(q)
    )
  • ??????????????????q??????
  • ???????????
  • ??q????5?,(1-q)????1??????????????????6???????????
    ??

13
?????????????Maximum likelihood Example
??????????
?????????????q????????????
???,6????5?????????
14
????????????????Disaggregated estimation by ML
  • ??????(??????????)
  • ????????????
  • ???????????????????????????????????????
  • ???????????????????????(????)????
  • ?????????????????????????????

15
?????????Travel mode choice model
  • ??OD?????????,????????????????????????
  • Utility for each mode are function of time and
    cost
  • 2????????

???j?????????????????
16
2???????????Scheme of binary logit model
V
1
V
0
X2
X1
17
?????(??)??????????????
?3.15 ??????? ?3.15 ??????? ?3.15 ??????? ?3.15 ???????
tBij 1 2 3
1 5 11 13
2 10 12 12
3 14 16 7
??? ???
?3.16 ???????? ?3.16 ???????? ?3.16 ???????? ?3.16 ????????
tCij 1 2 3
1 3 8 10
2 8 7 11
3 10 11 3
??? ???
?3.17 ??????? ?3.17 ??????? ?3.17 ??????? ?3.17 ???????
cBij 1 2 3
1 130 140 180
2 140 130 220
3 180 220 130
??? ???
?3.18 ???????? ?3.18 ???????? ?3.18 ???????? ?3.18 ????????
cCij 1 2 3
1 21 45 58
2 45 42 60
3 58 60 19
??? ???
?3.19 ?????? ?3.19 ?????? ?3.19 ?????? ?3.19 ??????
PBij 1 2 3
1 0.273 0.265 0.253
2 0.282 0.248 0.255
3 0.239 0.192 0.244

?3.20 ??????? ?3.20 ??????? ?3.20 ??????? ?3.20 ???????
PCij 1 2 3
1 0.727 0.735 0.747
2 0.718 0.752 0.745
3 0.761 0.808 0.756
18
?????(??)???????????????
???????????2????????????????
19
?????(??)???????????????
??????
VBUS-VCAR
20
R???????Linear regression by R
  • tb lt- c(5,10,14,11,12,16,13,12,7)
  • tc lt- c(3,8,10,8,7,11,10,11,3)
  • cb lt- c(130,140,180,140,130,220,180,220,130)
  • cc lt- c(21,45,58,45,42,60,58,60,19)
  • pb lt- c(0.273,0.282,0.239,0.265,0.248,0.192,0.253,
    0.255,0.244)
  • pc lt- rep(1,9)-pb
  • lnpbpc lt- log(pc/pb)
  • tsa lt- tc-tb
  • csa lt- cc-cb
  • ans lt- lm(lnpbpc tsacsa)
  • summary(ans)

21
R????????????Result of linear regression
  • Call
  • lm(formula lnpbpc tsa csa)
  • Residuals
  • Min 1Q Median 3Q Max
  • -0.021913 -0.017819 -0.006659 0.018098 0.030403
  • Coefficients
  • Estimate Std. Error t value
    Pr(gtt)
  • (Intercept) 0.3898049 0.0446483 8.731
    0.000125
  • tsa -0.0795878 0.0060416 -13.173
    1.18e-05
  • csa -0.0038682 0.0003171 -12.200
    1.85e-05
  • ---
  • Signif. codes 0 0.001 0.01 0.05
    . 0.1 1
  • Residual standard error 0.0237 on 6 degrees of
    freedom
  • Multiple R-squared 0.9799, Adjusted
    R-squared 0.9732
  • F-statistic 146 on 2 and 6 DF, p-value
    8.165e-06

22
????????????????Maximum Likelihood Estimation
?3.15 ??????? ?3.15 ??????? ?3.15 ??????? ?3.15 ???????
tBij 1 2 3
1 5 11 13
2 10 12 12
3 14 16 7
??? ???
?3.16 ???????? ?3.16 ???????? ?3.16 ???????? ?3.16 ????????
tCij 1 2 3
1 3 8 10
2 8 7 11
3 10 11 3
??? ???
?3.17 ??????? ?3.17 ??????? ?3.17 ??????? ?3.17 ???????
cBij 1 2 3
1 130 140 180
2 140 130 220
3 180 220 130
??? ???
?3.18 ???????? ?3.18 ???????? ?3.18 ???????? ?3.18 ????????
cCij 1 2 3
1 21 45 58
2 45 42 60
3 58 60 19
??? ???
23
????????????????Maximum Likelihood Estimation
????
????????????
24
????????????????Maximum Likelihood Estimation
??????Solver in MS Excel ??????Excel
?????????????????????????????? ???????????????????
???????????????
????????????????????????????????????????????? ????
???(log)???????????????????Logarithm of
likelihood function
25
????????????????
????????????
26
????????????Estimated Logit model
27
R???????????????
  • ????????? ??????x???????.
  • LL lt- function (x)
  • vbus lt- x1 tb x2 cb
  • vcar lt- x1 tc x2 cc x3
  • ppb lt- 1/(1exp(vcar - vbus))
  • ppc lt- 1- ppb
  • return(sum(pblog(ppb)pclog(ppc)))
  • Optim?????????,???res?????.????(0,0,0)
  • b0c(0,0,0)
  • reslt-optim(b0,LL, method "BFGS", hessian
    TRUE, controllist(fnscale-1))

28
R??????????
  • gt res
  • par
  • 1 -0.081037584 -0.004007811 0.369193890
  • value
  • 1 -5.047779
  • counts
  • function gradient
  • 62 18
  • convergence
  • 1 0
  • message
  • NULL
  • hessian
  • ,1 ,2 ,3
  • 1, -19.628306 -613.3939 5.313007
  • 2, -613.393875 -23980.3173 196.530577
  • 3, 5.313007 196.5306 -1.681972

29
R????????????Maximum Likelihood by R
  • ????????(1????1?)??
  • Pure disaggregate data
  • (one line for one sample)
  • glm(????????1????n,familybinomial(linklog
    it))
  • ?????????? Share data
  • glm(????????1????n,familyquasibinomial(link
    logit))

30
R???????????????????(share data)
  • ans2 lt- glm(pc tsacsa, familyquasibinomial(lin
    k"logit"))
  • summary(ans2)

Call glm(formula pc tsa csa, family
quasibinomial(link "logit")) Deviance
Residuals Min 1Q Median
3Q Max -0.008856 -0.007615 -0.002659
0.007188 0.013667 Coefficients
Estimate Std. Error t value Pr(gtt)
(Intercept) 0.3991916 0.0446219 8.946
0.000109 tsa -0.0787542 0.0060030
-13.119 1.21e-05 csa -0.0038095
0.0003174 -12.001 2.03e-05 --- Signif. codes
0 0.001 0.01 0.05 . 0.1 1
(Dispersion parameter for quasibinomial family
taken to be 0.0001007740) Null deviance
0.02932541 on 8 degrees of freedom Residual
deviance 0.00060564 on 6 degrees of
freedom AIC NA Number of Fisher Scoring
iterations 4
31
?????????????R???,???????????
  • nb lt- c(39,11,16,22,31,15,21,25,50)
  • nc lt- c(104,28,51,61,94,63,62,73,155)
  • nn lt- nb nc
  • nnf lt-numeric(length10)
  • for (i in 19)
  • nnfi1nnfinni
  • chc lt- numeric(lengthnnf10-1)
  • tim lt- numeric(lengthnnf10-1)
  • cst lt- numeric(lengthnnf10-1)
  • for (i in 19)
  • chcnnfi(nnfinni-1) lt- c(rep(1,nbi),
    rep(0,nci))
  • timnnfi(nnfinni-1) lt-
    rep((tbi-tci),nni)
  • cstnnfi(nnfinni-1) lt-
    rep((cbi-cci),nni)

32
?????????????pure disaggregate data
  • ans3 lt- glm(chc timcst, familybinomial(link"l
    ogit"))
  • summary(ans3)

Call glm(formula chc tim cst, family
binomial(link "logit")) Deviance Residuals
Min 1Q Median 3Q Max
-0.8215 -0.7630 -0.7470 -0.1019 1.8016
Coefficients Estimate Std. Error z
value Pr(gtz) (Intercept) -0.385889 0.507795
-0.760 0.447 tim -0.079514 0.061803
-1.287 0.198 cst -0.003873 0.003465
-1.118 0.264 (Dispersion parameter for
binomial family taken to be 1) Null deviance
1034.7 on 919 degrees of freedom Residual
deviance 1032.4 on 917 degrees of freedom AIC
1038.4 Number of Fisher Scoring iterations 4
33
??????????????????
34
?????????????
  • ????????????????e???????????????????

35
??????
36
??????(??)
???1??????? Prob(U1gtU2) Prob(V1e1gtV2e2) Prob(e
2ltV1-V2e1)
e2
V1-V2e1
e1
????????????????? (???????????)
e2
??(????)??????, ??????????????? ??????????????????
?.
e1
37
?????????????
  • ????(LOGIT)???
  • ???????????????
  • Gumbel?????
  • ????????
  • ?k?????????,
  • ?????(PROBIT)???
  • ??????????????????????
  • ????????????????????
  • ?????????????????????????

???????? ??????????
38
????????????????????????
????
???????????????ß????
39
???????(2)
40
??????????Newton Raphson Method
41
?????????Multinomial Logit Model
42
????????
43
?????????Multinomial Logit Model
?????? ??????? ?????? ???????
44
???????
45
???
??????????,???????????????????
46
??????????????(??????)ehime.csv
  • SEQ,??,??,????,?????,??,??,?????,??,??,4????,??,??
  • 3869,1,7,5,1,37.2 ,250,1,129.0 ,850,1,25.61,120.61
  • 7447,1,7,5,1,37.2 ,250,1,121.3 ,1174.33,1,25.61,12
    0.61
  • 7924,1,7,5,1,42.1 ,230,1,148.3 ,960,1,29.85,142.34
  • 2460,1,5,5,1,39.0 ,230,1,106.6 ,970,1,37.06,177.84
  • 3800,1,5,5,1,39.0 ,230,1,91.3 ,850,1,37.06,177.84
  • 3347,1,3,5,1,22.0 ,140,1,77.9 ,300,1,9.41,34.04
  • 4143,1,3,5,1,22.0 ,140,1,77.9 ,300,1,9.41,34.04
  • 2529,1,1,5,1,45.0 ,320,1,94.8 ,910,1,34.42,165.4
  • 4985,1,1,5,1,45.0 ,320,1,128.5 ,1050,1,34.42,165.3
    9
  • 6424,1,6,4,1,83.3 ,570,1,179.8 ,1604.61,1,62.26,51
    1.51
  • 7791,1,6,4,1,83.3 ,570,1,172.0 ,1720,1,62.26,511.5
    1
  • 1498,1,5,4,1,43.6 ,650,1,169.3 ,1932.33,1,77.59,40
    0.49
  • 1962,1,5,4,1,54.1 ,609,1,136.0 ,1182.28,1,61.78,31
    3.43
  • 2367,1,5,4,1,120.3 ,1100,1,112.2
    ,1449.06,1,60.44,306.36
  • 2369,1,5,4,1,120.3 ,1100,1,112.2
    ,1449.06,1,60.44,306.36
  • 3985,1,5,4,1,54.1 ,609,1,134.2 ,1182.28,1,61.78,31
    3.43
  • 4307,1,5,4,1,43.6 ,650,1,183.8 ,2082.33,1,77.59,40
    0.49
  • 4931,1,5,4,1,155.0 ,1100,1,143.1
    ,1449.06,1,60.44,306.36

47
??????????????????(??????)
  • Multi Nomial Logit (MNL) estimation program
    (Original code by EHIME University)
  • ????????????
  • Datalt-read.csv("ehime.csv",headerT)
  • hhlt-nrow(Data) ????Data ???????
  • print(hh)
  • chlt- 3 ??????????
  • b0lt-c(0, 0, 0, 0, 0, 0)
  • Srail lt- sum(Data,14 1) Sbus lt-
    sum(Data,14 2) Scar lt- sum(Data,14 3)
  • cat("rail",Srail," bus",Sbus," car",Scar,"\n")
  • Logit model ??????????
  • fr lt- function(x)
  • LL0
  • ?????
  • rail lt- x1Data, 6/100 x2Data, 7/100
    x5matrix(1,nrow hh,ncol1)
  • bus lt- x1Data, 9/100 x2Data,10/100
    x3(Data, 3gt6) x6matrix(1,nrowhh,ncol1
    )
  • car lt- x1Data,12/100 x2Data,13/100
    x4(Data, 4gt2)
  • ??????
  • Erail lt- exp(rail)Data, 5
  • Ebus lt- exp(bus )Data, 8

48
????????????????????
  • rail 493 bus 432 car 708
  • roh 0.2432912
  • rohbar 0.2398755
  • par
  • 1 -1.7411817 -0.1757195 1.7302273 2.5890795
    2.0644240 2.3457336
  • value
  • 1 -1329.232
  • counts
  • function gradient
  • 38 14
  • convergence
  • 1 0
  • message
  • NULL
  • hessian
  • ,1 ,2 ,3 ,4 ,5 ,6
  • 1, -80.15815 -538.9584 -67.42988 65.52220
    27.40143 -114.7780
  • 2, -538.95843 -4708.3230 -493.74059 503.37025
    123.55640 -800.5406
  • 3, -67.42988 -493.7406 -127.96682 31.64655
    79.67259 -127.9668

49
????????????????????
  • rail 493 bus 432 car 708
  • roh 0.2432912
  • rohbar 0.2398755
  • par
  • ?? ?? ??B ??C ?? ??
  • 1 -1.7411817 -0.1757195 1.7302273 2.5890795
    2.0644240 2.3457336
  • 1 -5.857365 -5.520454 12.528884 17.136179
    13.928912 10.259022
  • value
  • 1 -1329.232
  • ????? -0.0174/?,??? -0.00176/???????????????
    ?????10?/????,????

50
????????? (?????)Multinomial Logit Model
  • install.packages("mlogit")
  • library("mlogit")
  • Dehimelt-read.csv("ehime.csv",headerT)
  • Ehime lt-mlogit.data(Dehime,varyingc(513),
  • shape"wide",choice"choice")
  • MNL without constant term
  • summary(mlogit(choicetimecost-1,dataEhime))
  • MNL with constant term
  • summary(mlogit(choicetimecost,dataEhime))

51
?????????(?????) Multinomial Logit Model
  • Call
  • mlogit(formula Choice time cost - 1, data
    Ehime)
  • Frequencies of alternatives
  • bus car rail
  • 0.26454 0.43356 0.30190
  • Newton-Raphson maximisation
  • gradient close to zero. May be a solution
  • 5 iterations, 0h0m0s
  • g'(-H)-1g 7.47E-31
  • Coefficients
  • Estimate Std. Error t-value
    Pr(gtt)
  • time -0.00329405 0.00197725 -1.6660 0.0957185 .
  • cost -0.00096882 0.00025323 -3.8259 0.0001303
  • ---
  • Signif. codes 0 0.001 0.01 0.05
    . 0.1 1
  • Log-Likelihood -1715.7

52
?????????(?????) Multinomial Logit Model
  • Call
  • mlogit(formula Choice time cost, data
    Ehime)
  • Frequencies of alternatives
  • bus car rail
  • 0.26454 0.43356 0.30190
  • Newton-Raphson maximisation
  • gradient close to zero. May be a solution
  • 5 iterations, 0h0m0s
  • g'(-H)-1g 9.17E-26
  • Coefficients Estimate Std. Error t-value
    Pr(gtt)
  • altcar -1.07985435 0.14856671 -7.2685
    3.635e-13
  • altrail -0.95903599 0.11625041 -8.2497
    2.220e-16
  • time -0.01607098 0.00261456 -6.1467
    7.910e-10
  • cost -0.00119568 0.00027125 -4.4081
    1.043e-05
  • Log-Likelihood -1680.5
  • McFadden R2 0.68776
  • Likelihood ratio test chisq 152.13 (p.valuelt
    2.22e-16

53
MNL??????????
  • ????????(I.I.A??)
  • ?????????????????
  • ????????????????????
  • ???,????????1/2?????
  • ????????,??????????
  • ????,???,????????1/3??
  • ?????????????1/2??2/3????
  • ??????????????????????,????????????

54
??????(???)???????Nested Logit Model (NL)
????????????????????????
55
??????(???)???????Nested Logit Model (NL)
???????????????,????????????????????
56
??????(???)???????Nested Logit Model (NL)
  • ?????????????????,?????????????????????
  • ???????????????????,?????
  • ?????????????????,???????????????????????

57
??????????????????????(??????)
  • Nested Logit estimation program (Original
    code by EHIME University)
  • ????????????
  • Datalt-read.csv(ehime.csv",headerT)
  • hhlt-nrow(Data) ????Data ???????
  • print(hh)
  • chlt- 3 ??????????
  • b0lt-c(0, 0, 0, 0, 0, 0, 1) ????????(??0)
  • ????????????????
  • Srail lt- sum(Data,2rail) Sbus lt-
    sum(Data,2 bus) Scar lt- sum(Data,2car
    )
  • cat("rail",Srail," bus",Sbus," car",Scar,"\n")
  • Logit model ??????????
  • fr lt- function(x)
  • LL0
  • ?????
  • rail lt- x1Data, 6/100 x2Data, 7/100
    x5matrix(1,nrow hh,ncol1)
  • bus lt- x1Data, 9/100 x2Data,10/100
    x3(Data, 3gt6) x6matrix(1,nrow

58
NL????????(ehime)
???Arohbar 0.2652 (?????) ????? -0.8978
0.01277 1.178 0.5003 0.03899 -0.43394 4.873 t ?
-5.62 1.41 8.43 6.39 0.42
-3.40 7.04 ?? ?? ??B ??C ?? ??
???? ???Brohbar 0.2416 ????? -1.327 -0.1613
1.244 2.413 1.877 2.382 1.354 t ? -4.86
-6.01 7.20 14.97 11.86 12.29 9.82 ?? ??
??B ??C ?? ?? ???? ???Crohbar
0.2470 ????? -2.357 -0.1976 2.297 3.008 1.992
2.814 0.5830 t ? -5.69 -4.70 11.29 15.79
9.53 9.81 8.72 ??
?? ??B ??C ?? ?? ????
??????????1??
Write a Comment
User Comments (0)
About PowerShow.com