Skip to content

Commit 73e253b

Browse files
committedApr 27, 2023
Combined with Tayebeh's code from github.com/Tsaghapour/WP3_ModeChoice
1 parent 83a5fef commit 73e253b

34 files changed

+57838
-2
lines changed
 

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
.RData
44
.Ruserdata
55
/data
6-
/result
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"","Estimate","Std.err.","t-ratio(0)","Rob.std.err.","Rob.t-ratio(0)"
2+
"cons_carp",0.507479410130553,0.166203834450304,3.05335560884604,0.20598549510741,2.46366575406648
3+
"cons_walk",2.38171235675649,0.256683615452297,9.27878607506647,0.338310478568359,7.04001947215844
4+
"cons_bike",0.0869613466622531,0.417735412425233,0.208173269671787,0.4411187768342,0.197138166020393
5+
"cons_ptwalk",0.730350279159625,0.259429734111041,2.81521423001968,0.304074107925196,2.40188250207511
6+
"f_age2_carp",-0.220324831059579,0.11658396917687,-1.88983813653937,0.171332427290584,-1.28594939407414
7+
"f_age2_walk",0.545458344267642,0.145164797211846,3.75751115107907,0.166756390075362,3.27098915982251
8+
"f_age2_bike",1.54526236999993,0.229643453393523,6.7289633001291,0.238063662772004,6.49096276183838
9+
"f_age2_ptwalk",1.32313118216956,0.149679652471536,8.83975316832843,0.167979011522141,7.87676490163865
10+
"f_age4_carp",-0.507854863130737,0.174187045700068,-2.91557194215929,0.246404460312692,-2.06106197301079
11+
"f_age4_walk",-0.386961347871536,0.158303966660159,-2.44441978325313,0.173331963667107,-2.23248695557799
12+
"f_age4_bike",-0.548559518107223,0.291432608752569,-1.88228599556942,0.311141777441598,-1.76305323771633
13+
"f_age4_ptwalk",-0.273974767140126,0.167268830715568,-1.63793078464216,0.172339987096284,-1.58973417461764
14+
"f_age5_carp",-0.446912580961501,0.153006457957432,-2.92087397439027,0.209753352623664,-2.13065762893118
15+
"f_age5_walk",-0.500386810196162,0.156463274527087,-3.19811030229675,0.168127194616694,-2.9762395746683
16+
"f_age5_bike",-0.761670668781613,0.323887056337777,-2.35165516459317,0.354050726280921,-2.15130378853472
17+
"f_age5_ptwalk",-0.436782718090231,0.174004715398064,-2.51017748048391,0.185824644908369,-2.35051017213358
18+
"f_age6_carp",-0.271718599377444,0.121825744622699,-2.23038734726367,0.152663059016978,-1.77985821276662
19+
"f_age6_walk",-0.750769771520214,0.188345993779605,-3.98612020597972,0.188321827591047,-3.98663172041086
20+
"f_age6_bike",-0.854328085722781,0.439044902635437,-1.9458786119473,0.441790444443935,-1.93378579475183
21+
"f_age6_ptwalk",-0.387263808985339,0.198526843860437,-1.95068738038057,0.199323519217902,-1.94289068598061
22+
"f_age7_carp",-0.409412792071481,0.195732281598654,-2.09169784732278,0.229477952419004,-1.78410512973348
23+
"f_age7_walk",-1.21508273260015,0.363039997734491,-3.34696656066201,0.368507988620238,-3.29730364095945
24+
"f_age7_bike",-1.41252905281338,1.14897907171251,-1.22937752966036,0.745006351529117,-1.8959959870331
25+
"f_age7_ptwalk",-1.35055183260594,0.501399391398787,-2.69356496193227,0.482154716749714,-2.80107564167418
26+
"f_female_carp",0.192650704738591,0.0737003160665666,2.61397392874934,0.0947560492828253,2.03312301638466
27+
"f_female_walk",0.204789769793869,0.0918779624936599,2.22893242553132,0.0960745408234956,2.13157167381212
28+
"f_female_bike",-0.80852934522463,0.195429165045223,-4.13719899502991,0.197350260735819,-4.09692564990811
29+
"f_female_ptwalk",0.388053436602188,0.103081573799523,3.76452766773709,0.104392040590739,3.71727034366081
30+
"f_inc1_carp",-0.138121795017738,0.152664322854546,-0.904741804994844,0.17323751822731,-0.797297239253359
31+
"f_inc1_walk",-0.0515070224885789,0.230849434612091,-0.223119552253308,0.220081823245164,-0.234035786004925
32+
"f_inc1_bike",0.247302751898257,0.44780603486865,0.552254173999231,0.439251847478169,0.563009019354319
33+
"f_inc1_ptwalk",-1.04003077217364,0.261127597953405,-3.9828450930691,0.246173766113891,-4.22478312206701
34+
"f_inc2_carp",-0.341092067562769,0.146164935000802,-2.33361077717373,0.189839833872438,-1.79673602007028
35+
"f_inc2_walk",-0.199848185590576,0.185063028618894,-1.07989254840377,0.193905164016498,-1.03064911449998
36+
"f_inc2_bike",-0.400467191036192,0.376277124522252,-1.06428790095771,0.367793267951063,-1.08883774101454
37+
"f_inc2_ptwalk",-1.00739950203732,0.203942796297066,-4.93961797292376,0.203646310713707,-4.94680948801254
38+
"f_inc3_carp",-0.161516752266737,0.106152604314835,-1.52155242265842,0.114016895169749,-1.4166036711162
39+
"f_inc3_walk",-0.0161846840231505,0.176984630662949,-0.0914468333353344,0.178898474848471,-0.0904685410921422
40+
"f_inc3_bike",-0.249793375823188,0.359731187528932,-0.694388989564877,0.348696437304602,-0.716363429905029
41+
"f_inc3_ptwalk",-0.917363229586013,0.20215281101285,-4.53796919760715,0.197027437372988,-4.65601766849039
42+
"f_inc4_carp",-0.124248257452291,0.0930178129098681,-1.33574692379281,0.0894102810004584,-1.38964172869174
43+
"f_inc4_walk",0.126647812827062,0.165208019205215,0.766596037143602,0.176038647403978,0.719431867346875
44+
"f_inc4_bike",0.264707267525009,0.336198336696847,0.787354482850099,0.34970409712105,0.756946429007324
45+
"f_inc4_ptwalk",-0.461141530787376,0.182066455113997,-2.53281984591089,0.18065739832643,-2.55257484641808
46+
"f_inc6_carp",-0.0999734672620078,0.0875156095894692,-1.14235012166375,0.0946124996026969,-1.05666236154655
47+
"f_inc6_walk",-0.360546323478436,0.152615866119658,-2.36244325472524,0.153454888129095,-2.34952648217451
48+
"f_inc6_bike",-0.222948837138062,0.31977781005621,-0.697199211849229,0.323288637706866,-0.689627815933993
49+
"f_inc6_ptwalk",-0.600730881051986,0.164328185075273,-3.65567769629301,0.167628716763724,-3.58369909792204
50+
"f_cars_carp",-0.480013795391433,0.121956402573384,-3.93594584017513,0.163574647428703,-2.93452440788941
51+
"f_cars_walk",-1.03703700080034,0.0837275058562858,-12.3858580306974,0.105812799137006,-9.80067637618763
52+
"f_cars_bike",-1.86343133117003,0.141999643996198,-13.1227887530474,0.157384037254429,-11.840027512813
53+
"f_cars_ptwalk",-1.60090743629154,0.0894003507477487,-17.9071717605298,0.104463155323563,-15.3250917161453
54+
"f_bikes_carp",-0.0254261925224113,0.0239036496212308,-1.06369499742953,0.0243768389313396,-1.04304715611517
55+
"f_bikes_walk",-0.0651531400117317,0.0373419202706878,-1.74477208294172,0.0377820934096782,-1.72444494552655
56+
"f_bikes_bike",0.849881882708995,0.0699134870626564,12.1561935817524,0.0630050781379368,13.4891013205055
57+
"f_bikes_ptwalk",-0.102282430583155,0.0447251029917717,-2.28691324874026,0.0442864089126212,-2.30956704538773
58+
"f_work2_carp",0.0642742647560107,0.0930445582900222,0.690790154064316,0.0993159729686808,0.647169461616003
59+
"f_work2_walk",-0.0446705800447487,0.174996653700826,-0.255265338508229,0.173249589075651,-0.257839457415641
60+
"f_work2_bike",-0.300950438001821,0.375500097873717,-0.801465671263375,0.408591382374192,-0.736556009216581
61+
"f_work2_ptwalk",0.395512902269971,0.188811512391316,2.09474992949721,0.182580190500287,2.16624213824198
62+
"f_work4_carp",1.57260892089839,0.445074160568217,3.53336378569062,0.642033138301193,2.44942017332545
63+
"f_work4_walk",1.62212642256465,0.319981106308658,5.06944438463166,0.432540464409449,3.75023045480694
64+
"f_work4_bike",-0.107062831415538,0.380926437321585,-0.281059073159455,0.483831438567339,-0.221281262194451
65+
"f_work4_ptwalk",1.84960691660068,0.322501410650671,5.73519015891733,0.440723719949411,4.1967491942866
66+
"f_vgvi_walk",0.000193420051903407,0.000303508145448885,0.637281255227405,0.000384827544757269,0.502614884351398
67+
"f_vgvi_bike",0.00117916881771902,0.000574406172856681,2.05284844320994,0.000562934244137654,2.09468304690783
68+
"f_shannon_walk",3.40560276891574e-05,0.000196991923512892,0.172880324644013,0.000242513246350915,0.140429556742144
69+
"f_shannon_bike",0.000943299584128781,0.00038326556768167,2.46121661759154,0.000401218141610692,2.35108906178046
70+
"f_crime_walk",-0.00191245247082989,0.000510497909087943,-3.74624937102423,0.000557421516986796,-3.4308910089583
71+
"f_crime_bike",0.000847209314197373,0.000904941235271884,0.936203679505038,0.000778922565174628,1.08766821257442
72+
"f_attract_walk",-0.00126642162557651,0.000825266601990786,-1.53456061655898,0.000992307068049235,-1.2762396503596
73+
"f_attract_bike",-0.00218316616087048,0.00150555969848868,-1.45006947453628,0.00146792932986983,-1.48724200576064
74+
"f_stresjct_walk",-0.0335057227632091,0.0118957855249261,-2.8166044766865,0.0130817906601556,-2.56124896305371
75+
"f_stresjct_bike",-0.0138921382666112,0.0217264887131093,-0.639410189564088,0.0232103689983568,-0.598531555771248
76+
"f_poi_walk",-0.000109516475988255,0.000186253380011642,-0.587997253963442,0.000217775601151774,-0.50288680370548
77+
"f_poi_bike",-0.000739479685305999,0.000294196622612378,-2.51355599782092,0.000271504008732154,-2.72364186723856
78+
"f_costcarp",0.00184239741047172,NA,NA,0.0201357792942595,0.0914986891516519
79+
"f_costwalk",0.000321562884451805,1.84428863481235,0.000174356051640757,NA,NA
80+
"f_costbike",0.000201882792466196,NA,NA,0.0013597379048558,0.148471842805328
81+
"f_costpt",-1.42658592924181e-05,8.70628897694836e-05,-0.163856946744932,7.65669200861593e-05,-0.186318834248067
82+
"f_timecarp",-0.000463467063247366,NA,NA,0.000239048743532519,-1.93879731973709
83+
"f_timewalk",0.000325148682088237,1.84428858734529,0.000176300327573063,0.00157363134065497,0.206623161148345
84+
"f_timebike",0.000201882978401901,NA,NA,0.0013298840684446,0.151804945402511
85+
"f_timept",0.000140505627297576,3.53709764318435e-05,3.97234234028898,3.15341264093763e-05,4.45566893065406
86+
"lambda_car",0.337168236058533,0.0977468694126667,3.44940188964088,0.143190502772632,2.35468295403579
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"","Estimate","Std.err.","t-ratio(0)","Rob.std.err.","Rob.t-ratio(0)"
2+
"cons_carp",0.509268936900891,0.166025615833636,3.06741182283099,0.204677333773241,2.48815502680479
3+
"cons_walk",2.35703630596734,0.256143750633132,9.20200590543885,0.336448233230429,7.005643285257
4+
"cons_bike",0.0296851149127498,0.420202677726555,0.0706447542727638,0.452169744318002,0.0656503786150558
5+
"cons_ptwalk",0.73134564626186,0.259310824496541,2.82034368477207,0.303202727351313,2.41206816525258
6+
"s_age2_carp",-0.221634935854714,0.116784415769144,-1.89781260106516,0.171110380181084,-1.29527463862894
7+
"s_age2_walk",0.547670402071205,0.145276292774714,3.76985392186803,0.166695580200979,3.28545244817468
8+
"s_age2_bike",1.57068770840294,0.229797224315241,6.83510304827807,0.239640538691278,6.55434893019673
9+
"s_age2_ptwalk",1.32243041431933,0.149743458699348,8.83130672822563,0.167958228349664,7.8735672989252
10+
"s_age4_carp",-0.511677589462636,0.174814669955732,-2.92697168717138,0.246431991087079,-2.07634401363835
11+
"s_age4_walk",-0.379490684420154,0.158148596294176,-2.39958300808598,0.173249223923116,-2.1904322329811
12+
"s_age4_bike",-0.502541741633947,0.29163590139117,-1.72318201989779,0.311251002334407,-1.61458674145575
13+
"s_age4_ptwalk",-0.273448739394977,0.167356738438514,-1.6339272738363,0.172493169716597,-1.58527285366863
14+
"s_age5_carp",-0.45052641012067,0.153725213801449,-2.93072553928967,0.210244226751475,-2.14287173104271
15+
"s_age5_walk",-0.494975658216898,0.156422635942577,-3.16434801928925,0.168088811244623,-2.9447269842164
16+
"s_age5_bike",-0.760052954601182,0.324268409080524,-2.34390071100772,0.359351053307237,-2.11507089684625
17+
"s_age5_ptwalk",-0.437300088589476,0.174099379459288,-2.51178430358355,0.185995252221167,-2.35113575947349
18+
"s_age6_carp",-0.273190251171411,0.122065376376951,-2.23806503760551,0.152415376117678,-1.79240610842626
19+
"s_age6_walk",-0.739091883113249,0.188596937487599,-3.9188965258879,0.188269903981509,-3.92570382989009
20+
"s_age6_bike",-0.870496002512777,0.440989320584488,-1.97396164006652,0.450454902222984,-1.93248202698406
21+
"s_age6_ptwalk",-0.385298054635035,0.19859818274785,-1.94008852097215,0.199574158235627,-1.93060092569767
22+
"s_age7_carp",-0.41036575371164,0.195734348886901,-2.09654440339829,0.228246193989875,-1.79790841870443
23+
"s_age7_walk",-1.19987428968692,0.363520852911422,-3.30070277970901,0.368720560910353,-3.25415617378237
24+
"s_age7_bike",-1.39811556415545,1.14351299039137,-1.22264948094463,0.749565179231034,-1.86523547637279
25+
"s_age7_ptwalk",-1.34976781159371,0.501480293022754,-2.69156700746457,0.482484996132853,-2.7975332340118
26+
"s_female_carp",0.194480450726623,0.0741172358171752,2.62395714819084,0.0951920117110285,2.04303330952813
27+
"s_female_walk",0.206247240871513,0.0920054566207931,2.24168487877383,0.0960857744690838,2.146490903686
28+
"s_female_bike",-0.77450768140059,0.195984189619992,-3.95188858296344,0.197771686982243,-3.91617067750516
29+
"s_female_ptwalk",0.390369221693732,0.103151163267548,3.78443838467641,0.104491273669555,3.73590260683628
30+
"s_inc1_carp",-0.137267948191981,0.152809374462013,-0.89829533479377,0.172503327328417,-0.795740872468194
31+
"s_inc1_walk",-0.0367546035363561,0.23090833849854,-0.159173998545698,0.21907414417163,-0.167772439213827
32+
"s_inc1_bike",0.348831267226766,0.451875704897887,0.771962872634619,0.450677494480286,0.774015280325975
33+
"s_inc1_ptwalk",-1.04034089856245,0.261116211745367,-3.98420646350738,0.246072987910072,-4.22777366747238
34+
"s_inc2_carp",-0.343209820756881,0.146507303249492,-2.34261236910775,0.189723855740014,-1.80899665684211
35+
"s_inc2_walk",-0.188729074961134,0.185146350328334,-1.019350771033,0.193919174401868,-0.973235759399542
36+
"s_inc2_bike",-0.320115340933468,0.379071484540391,-0.844472227505044,0.377597929177514,-0.847767734401365
37+
"s_inc2_ptwalk",-1.00911810784858,0.204111616654047,-4.94395235504383,0.203911950015121,-4.9487933776012
38+
"s_inc3_carp",-0.164131963756948,0.106963223980386,-1.53447098590676,0.115183362809612,-1.42496242298675
39+
"s_inc3_walk",-0.00213150585604317,0.177149209093739,-0.0120322628983078,0.179133522754423,-0.0118989780542935
40+
"s_inc3_bike",-0.227194435722261,0.361729159659206,-0.628078853074235,0.353563198733592,-0.642585078243538
41+
"s_inc3_ptwalk",-0.918662665411732,0.202255898596544,-4.54208095677972,0.19743470110481,-4.65299494096558
42+
"s_inc4_carp",-0.123839838844323,0.0933014432228412,-1.32730893077982,0.0895533920890887,-1.38286039149836
43+
"s_inc4_walk",0.139427891416415,0.165216958857025,0.843907867454894,0.175966592119349,0.792354331223557
44+
"s_inc4_bike",0.344934729134648,0.338330260330981,1.01952077475188,0.356991775308811,0.966225983319271
45+
"s_inc4_ptwalk",-0.460701633584978,0.182153896794004,-2.52918900827019,0.180882085005142,-2.54697215355451
46+
"s_inc6_carp",-0.0997432558342403,0.0877087662707886,-1.13720965503376,0.0945337664381097,-1.05510718119479
47+
"s_inc6_walk",-0.347035512929158,0.152700072911252,-2.272661082034,0.153699251914451,-2.25788680560605
48+
"s_inc6_bike",-0.155351740739708,0.321574053397193,-0.483097871543215,0.331446061414887,-0.468708966027648
49+
"s_inc6_ptwalk",-0.599657946688988,0.16439811235561,-3.64759630202972,0.167878780512989,-3.57196987526719
50+
"s_cars_carp",-0.482591727117049,0.121888481054635,-3.95928903979641,0.162896302131149,-2.96257017994498
51+
"s_cars_walk",-1.03164633535737,0.083678627219351,-12.3286718441624,0.105460638691531,-9.78228795271101
52+
"s_cars_bike",-1.86216339919743,0.142727967121503,-13.0469412320025,0.159042392766653,-11.7085977317356
53+
"s_cars_ptwalk",-1.60243818220378,0.0893869281737548,-17.9269856895505,0.104266685291426,-15.3686498973756
54+
"s_bikes_carp",-0.0258704212903598,0.024047988634862,-1.07578316353892,0.0245658973200747,-1.05310304579101
55+
"s_bikes_walk",-0.0672098541782865,0.0373808769656128,-1.7979742487078,0.0380046592072587,-1.76846354052952
56+
"s_bikes_bike",0.852961855993308,0.0702566621642694,12.1406544193484,0.0638293702248594,13.3631563806517
57+
"s_bikes_ptwalk",-0.102292826037778,0.0447404506684168,-2.2863611007385,0.0442799673572329,-2.31013779239088
58+
"s_work2_carp",0.0632228513032646,0.0933134461394792,0.677532059085708,0.0992838839046586,0.636788659113869
59+
"s_work2_walk",-0.0407338044228215,0.175135688485338,-0.232584259525332,0.173259067240795,-0.235103449831054
60+
"s_work2_bike",-0.317307229194617,0.375194812289879,-0.845713263619067,0.403838647435268,-0.785727743517858
61+
"s_work2_ptwalk",0.393128619668908,0.18892940623985,2.08082281892011,0.182910525260664,2.14929468442925
62+
"s_work4_carp",1.58085303735414,0.44465338418105,3.55524796075871,0.6392690802652,2.47290708428808
63+
"s_work4_walk",1.63998462511737,0.319743855628358,5.12905751353529,0.43116513040189,3.80361144601081
64+
"s_work4_bike",-0.0846235832486165,0.381658945518076,-0.221725664346071,0.485293557078822,-0.174376069935896
65+
"s_work4_ptwalk",1.85694656458666,0.322240226051645,5.76261563411717,0.439041973048604,4.22954222734665
66+
"s_vgvi_walk",0.000422806238712554,0.000312271343759229,1.35397066417516,0.000387337591218733,1.09157037245525
67+
"s_vgvi_bike",0.00184713334131606,0.000617302069354336,2.99226818281698,0.000648106618826556,2.85004548273312
68+
"s_shannon_walk",0.000317783530312974,0.000207137913582812,1.53416400125092,0.000243762574449566,1.30366005130423
69+
"s_shannon_bike",0.00141805182966083,0.000427560586213554,3.31661026620577,0.000484935810898609,2.92420522013649
70+
"s_crime_walk",-0.00200064102818799,0.000509748424318864,-3.92476157402799,0.000553570680926818,-3.61406609330974
71+
"s_crime_bike",-0.000202117303166551,0.000917541427478247,-0.220281392331294,0.000770543734631099,-0.262304777889494
72+
"s_attract_walk",-0.00215924003932225,0.000876660909831424,-2.46302762574124,0.0010451851817781,-2.06589231933893
73+
"s_attract_bike",-0.00421239755107441,0.00175251516361676,-2.40362973087266,0.00193797567589512,-2.17360702895756
74+
"s_stresjct_walk",-0.0233427857461449,0.0119077450062869,-1.96030278896808,0.0134553696518002,-1.73483050634895
75+
"s_stresjct_bike",-0.0066480332822966,0.0209323433540561,-0.317596227514985,0.0215873252995586,-0.307960027008651
76+
"s_poi_walk",-0.000287436711150409,0.000187924095754653,-1.52953622044124,0.000219132656486048,-1.31170185110547
77+
"s_poi_bike",-0.00101675222716147,0.000318752577815517,-3.18978511210638,0.000297010660478944,-3.42328529730853
78+
"s_costcarp",0.00181129281157179,25.8232376293118,7.01419720320353e-05,0.041141172072033,0.044026281225057
79+
"s_costwalk",0.000829375180344637,0.000220131797908487,3.76763006628158,0.000268818777685922,3.08525761289507
80+
"s_costbike",0.000447507161241614,0.000432222953127688,1.03536186128785,0.000608222514505156,0.735762242549836
81+
"s_costpt",-1.46558236850283e-05,8.70975262791501e-05,-0.168269115222124,7.66547935709395e-05,-0.191192526941778
82+
"s_timecarp",-0.000463729058626665,0.0860776187015913,-0.00538733605345534,0.000278567982388121,-1.6646890093082
83+
"s_timewalk",-0.000204290142157986,0.000193096937575164,-1.05796676386162,0.000240287294169936,-0.85019119659947
84+
"s_timebike",0.000549706372159927,0.000846907821016374,0.649074620069306,0.00143320312551359,0.383550916387332
85+
"s_timept",0.000140479098911861,3.53761697822747e-05,3.97100929174782,3.14886359377244e-05,4.46126339641035
86+
"lambda_car",0.338711827028058,0.0975427437436053,3.47244514587753,0.142335551417661,2.3796713024574
Binary file not shown.
Binary file not shown.

‎result/Manchester/mandatory/Version2/probabilities_M1jibe.csv

+4,541
Large diffs are not rendered by default.

‎result/Manchester/mandatory/Version2/probabilities_M2jibe.csv

+4,541
Large diffs are not rendered by default.

‎result/Manchester/mandatory/Version2/probabilities_M3jibe.csv

+4,541
Large diffs are not rendered by default.

‎result/Manchester/mandatory/Version2/probabilities_M4jibe.csv

+4,541
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.

‎result/Melbourne/probabilities_modelshtM1.csv

+8,778
Large diffs are not rendered by default.

‎result/Melbourne/probabilities_modelshtM2.csv

+8,778
Large diffs are not rendered by default.

‎result/Melbourne/probabilities_modelshtM3.csv

+8,778
Large diffs are not rendered by default.

‎result/Melbourne/probabilities_modelshtM4.csv

+8,778
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
### Clear memory
2+
rm(list = ls())
3+
4+
suppressPackageStartupMessages(library(sf)) # for spatial things
5+
suppressPackageStartupMessages(library(lwgeom)) # for advanced spatial things
6+
suppressPackageStartupMessages(library(dplyr)) # for manipulating data
7+
suppressPackageStartupMessages(library(tidyr)) # for pivoting data
8+
suppressPackageStartupMessages(library(fitdistrplus)) # for log normal distributions
9+
suppressPackageStartupMessages(library(ggplot2)) # for plotting data
10+
suppressPackageStartupMessages(library(purrr)) # for nested dataframes
11+
suppressPackageStartupMessages(library(stringr))# for editing columns
12+
suppressPackageStartupMessages(library(tidyverse))# for manipulating data
13+
suppressPackageStartupMessages(library(expss))# for manipulating data
14+
15+
#Writing and reading csv
16+
trads <- readRDS("C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/TRADS_safe_routed.rds")
17+
write.csv(trads[["trips"]],file = "C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/trip_manchester.csv",row.names=F)
18+
write.csv(trads[["households"]],file = "C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/hh_manchester.csv",row.names=F)
19+
write.csv(trads[["indiv"]],file = "C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/pers_manchester.csv",row.names=F)
20+
trips <- read.csv("C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/trip_manchester.csv",header=T)
21+
households <- read.csv("C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/hh_manchester.csv",header=T)
22+
indiv <- read.csv("C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/pers_manchester.csv",header=T)
23+
24+
#creating unique id for individuals
25+
indiv <- indiv %>%
26+
unite("indiv.id", c('hh.id', 'p.id'), sep ='', na.rm = TRUE, remove = FALSE)%>%
27+
relocate(indiv.id, .after = hh.id)
28+
trips <- trips %>%
29+
unite("indiv.id", c('hh.id', 'p.id'), sep ='', na.rm = TRUE, remove = FALSE)%>%
30+
relocate(indiv.id, .after = hh.id)
31+
32+
#merging trip data with household and person data
33+
trips_hh <- merge(trips,households, by="hh.id")
34+
trips_hh_p <- merge(trips_hh,indiv, by="indiv.id")
35+
36+
#recoding sex var
37+
trips_hh_p$sex[trips_hh_p$p.female=="TRUE"] = 1
38+
trips_hh_p$sex[trips_hh_p$p.female=="FALSE"] = 0
39+
trips_hh_p <- trips_hh_p[!(is.na(trips_hh_p$sex)),]
40+
41+
#trips_hh_p$sex <- factor(trips_hh_p$sex, levels = c(1,0),labels = c("female", "male"))
42+
43+
#recoding age var
44+
trips_hh_p$agegroup[trips_hh_p$p.age_group=="5-9"|trips_hh_p$p.age_group=="10-14"] = 1
45+
trips_hh_p$agegroup[trips_hh_p$p.age_group=="15-19"|trips_hh_p$p.age_group=="20-24"] = 2
46+
trips_hh_p$agegroup[trips_hh_p$p.age_group=="25-29"|trips_hh_p$p.age_group=="30-34"] = 3
47+
trips_hh_p$agegroup[trips_hh_p$p.age_group=="35-39"|trips_hh_p$p.age_group=="40-44"] = 4
48+
trips_hh_p$agegroup[trips_hh_p$p.age_group=="45-49"|trips_hh_p$p.age_group=="50-54"] = 5
49+
trips_hh_p$agegroup[trips_hh_p$p.age_group=="55-59"|trips_hh_p$p.age_group=="60-64"] = 6
50+
trips_hh_p$agegroup[trips_hh_p$p.age_group=="65-69"|trips_hh_p$p.age_group=="70-74"|trips_hh_p$p.age_group=="75-79"|trips_hh_p$p.age_group=="80-44"|
51+
trips_hh_p$p.age_group=="85+"] = 7
52+
trips_hh_p <- trips_hh_p[!(trips_hh_p$agegroup==""),]
53+
54+
#trips_hh_p$agegroup <- factor(trips_hh_p$agegroup,
55+
#levels = c(1,2,3,4,5,6,7),labels = c("5-14", "15-24", "25-34","35-44","45-54","55-64","65+"))
56+
57+
#recoding work type
58+
trips_hh_p$worktype[trips_hh_p$p.ws_workOver30h=="TRUE"] = 1 #working full time
59+
trips_hh_p$worktype[trips_hh_p$p.ws_work16to30h=="TRUE"|trips_hh_p$p.ws_workUnder16h=="TRUE"|trips_hh_p$p.ws_volunteer=="TRUE"] = 2 #working part time/casual/volunteer
60+
trips_hh_p$worktype[trips_hh_p$p.ws_retired=="TRUE"] = 3
61+
trips_hh_p$worktype[trips_hh_p$p.ws_studyFullTime=="TRUE"|trips_hh_p$p.ws_studyPartTime=="TRUE"] = 4 #studying full/part time
62+
trips_hh_p$worktype[trips_hh_p$p.ws_homeMaker=="TRUE"|trips_hh_p$p.ws_unemployed=="TRUE"|trips_hh_p$p.ws_other=="TRUE"|trips_hh_p$p.ws_longTermDisabled=="TRUE"] = 5 #not in work force/other
63+
64+
#trips_hh_p$worktype <- factor(trips_hh_p$worktype,
65+
#levels = c(1,2,3,4,5),labels = c("full time", "part time/casual/volunteer", "retired","studying full/part time","not in work force/other"))
66+
67+
# recoding No of cars in HH
68+
trips_hh_p$carsno[trips_hh_p$hh.cars == 0] = 0
69+
trips_hh_p$carsno[trips_hh_p$hh.cars == 1] = 1
70+
trips_hh_p$carsno[trips_hh_p$hh.cars== 2] = 2
71+
trips_hh_p$carsno[trips_hh_p$hh.cars >=3] = 3 #more than 3 cars
72+
73+
# recoding No of bikes in HH
74+
trips_hh_p$bikesno[trips_hh_p$hh.bikes == 0] = 0
75+
trips_hh_p$bikesno[trips_hh_p$hh.bikes == 1] = 1
76+
trips_hh_p$bikesno[trips_hh_p$hh.bikes== 2] = 2
77+
trips_hh_p$bikesno[trips_hh_p$hh.bikes ==3] = 3
78+
trips_hh_p$bikesno[trips_hh_p$hh.bikes >=4] = 4 #more than 4 bikes
79+
80+
#recoding household income var
81+
trips_hh_p$hhincome[trips_hh_p$hh.income=="less than £5000"|trips_hh_p$hh.income=="£5000 to £9999"|trips_hh_p$hh.income=="£10000 to £14999"] = 1 #hh income less than £14999
82+
trips_hh_p$hhincome[trips_hh_p$hh.income=="£15000 to £19999"|trips_hh_p$hh.income=="£20000 to £24999"] = 2
83+
trips_hh_p$hhincome[trips_hh_p$hh.income=="£25000 to £34999"] = 3
84+
trips_hh_p$hhincome[trips_hh_p$hh.income=="£35000 to £49999"] = 4
85+
trips_hh_p$hhincome[trips_hh_p$hh.income=="£50000 to £74999"|trips_hh_p$hh.income=="£75000"] = 5 #hh income more than £50000
86+
trips_hh_p$hhincome[trips_hh_p$hh.income=="unknown"] = 6 # missing/refused to respond
87+
88+
#trips_hh_p$hhincome <- factor(trips_hh_p$hhincome,
89+
#levels = c(1,2,3,4,5,6),labels = c("less than £14999", "£15000 to £24999", "£25000 to £34999","£35000 to £49999",
90+
# "more than £50000","missing/refused to respond"))
91+
92+
#recoding household structure var
93+
trips_hh_p$hhstructure[trips_hh_p$hh.structure2=="2 adults, 1 child"|trips_hh_p$hh.structure2=="2 adults, 2 children"|trips_hh_p$hh.structure2=="2 adults, 3+ children"|
94+
trips_hh_p$hh.structure2=="3+ adults, 1+ children"|trips_hh_p$hh.structure2=="Single parent family"] = 1 # hh with children
95+
trips_hh_p$hhstructure[trips_hh_p$hh.structure2=="Single Adult 16 to 64"|trips_hh_p$hh.structure2=="Single Adult 65+"|trips_hh_p$hh.structure2=="Three of more Adults" |
96+
trips_hh_p$hh.structure2=="Two Adults Hoh or HRP 16 to 64"|trips_hh_p$hh.structure2=="Two Adults Hoh or HRP 65+"] = 0 # hh without children
97+
98+
#trips_hh_p$hhstructure <- factor(trips_hh_p$hhstructure, levels = c(1,0),labels = c("households with children", "households without children"))
99+
100+
#generating mainmode
101+
trips_hh_p$mainmode[trips_hh_p$t.m_carDriver=="TRUE"|trips_hh_p$t.m_motorcycle=="TRUE"] = 1
102+
trips_hh_p$mainmode[trips_hh_p$t.m_carPassenger=="TRUE"|trips_hh_p$t.m_taxi=="TRUE"] = 2
103+
trips_hh_p$mainmode[trips_hh_p$t.m_walk=="TRUE"] = 3
104+
trips_hh_p$mainmode[trips_hh_p$t.m_cycle=="TRUE"] = 4
105+
trips_hh_p$mainmode[trips_hh_p$t.m_train=="TRUE"|trips_hh_p$t.m_metrolink=="TRUE"|trips_hh_p$t.m_bus=="TRUE"] = 5
106+
trips_hh_p <- trips_hh_p[!(trips_hh_p$t.m_main=="Other"),]
107+
108+
#trips_hh_p$mainmode <- factor(trips_hh_p$mainmode, levels = c(1,2,3,4,5),labels = c("card", "carp", "walk","bike","ptwalk"))
109+
110+
#generating availability of modes
111+
trips_hh_p$availcard <- 1
112+
trips_hh_p$availcard[trips_hh_p$t.route.car_time == 0] = 0
113+
trips_hh_p$availcard[trips_hh_p$mainmode == 1] = 1
114+
trips_hh_p$availcarp <- 1
115+
trips_hh_p$availcarp[trips_hh_p$t.route.car_time == 0] = 0
116+
trips_hh_p$availcarp[trips_hh_p$mainmode == 2] = 1
117+
trips_hh_p$availwalk <- 1
118+
trips_hh_p$availwalk[trips_hh_p$troutewalk_short_time == 0] = 0
119+
trips_hh_p$availwalk[trips_hh_p$mainmode == 3] = 1
120+
trips_hh_p$availbike <- 1
121+
trips_hh_p$availbike[trips_hh_p$troutebike_short_time == 0] = 0
122+
trips_hh_p$availbike[trips_hh_p$mainmode == 4] = 1
123+
trips_hh_p$availpt <- 1
124+
trips_hh_p$availpt[trips_hh_p$troutept_totaltraveltime == 0] = 0
125+
trips_hh_p$availpt[trips_hh_p$mainmode == 5] = 1
126+
127+
#replacing NAs in time and cost variables with 0
128+
trips_hh_p$t.route.car_time[is.na(trips_hh_p$t.route.car_time)] = 0
129+
trips_hh_p$t.route.car_cost[is.na(trips_hh_p$t.route.car_cost)] = 0
130+
trips_hh_p$t.route.walk_short_time[is.na(trips_hh_p$t.route.walk_short_time)] = 0
131+
trips_hh_p$t.route.walk_short_cost[is.na(trips_hh_p$t.route.walk_short_cost)] = 0
132+
trips_hh_p$t.route.bike_short_time[is.na(trips_hh_p$t.route.bike_short_cost)] = 0
133+
trips_hh_p$t.route.bike_short_cost[is.na(trips_hh_p$t.route.bike_short_cost)] = 0
134+
trips_hh_p$t.route.pt_totalTravelTime[is.na(trips_hh_p$pt_totalTravelTime)] = 0
135+
trips_hh_p <- trips_hh_p[!is.na(trips_hh_p$t.route.bike_short_POI),]
136+
137+
#trips_hh_p$t.route.pt_accessDistance[is.na(trips_hh_p$t.route.pt_accessDistance)] = 0
138+
#trips_hh_p$t.route.t.route.pt_egressDistance[is.na(trips_hh_p$t.route.pt_egressDistance)] = 0
139+
#generating pt cost (travel cost was not provided: total distance to pt stop and distance to destination used as the cost of PT)
140+
#trips_hh_p$troutept_accessdistance <- as.numeric(trips_hh_p$t.route.pt_accessDistance)
141+
#trips_hh_p$troutept_accessdistance[is.na(trips_hh_p$troutept_accessdistance)] = 0
142+
#trips_hh_p$troutept_egressdistance <- as.numeric(trips_hh_p$t.route.pt_egressDistance)
143+
#trips_hh_p$troutept_egressdistance[is.na(trips_hh_p$t.route.pt_egressDistance)] = 0
144+
#trips_hh_p$t.route.pt_totalTravelCost <- trips_hh_p$troutept_accessdistance + trips_hh_p$troutept_egressdistance
145+
146+
#extracting work and education trips
147+
tripsWE<- subset(trips_hh_p, t.startPurpose=="Home"& t.endPurpose=="Usual place of work"|t.endPurpose=="Unpaid, voluntary work"|
148+
t.endPurpose=="Education as pupil, student" | t.endPurpose== "Work - Business, other")
149+
#write_labelled_csv(tripsWE,file = "C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/mandatory_trips.csv",row.names=FALSE, single_file = TRUE)
150+
write.csv(tripsWE,file = "C:/Users/e18933/OneDrive - RMIT University/WORK/JIBE/DATA Analysis/R/Manchester/mandatory_trips.csv",row.names=FALSE)
151+

‎script/Manchester/modeChoice/mandatory/Version1/MultinomialLogit_Manchester.R

+240
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version1/NestedLogit_Manchester_Fast.R

+275
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version1/NestedLogit_Manchester_JIBE.R

+275
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version1/NestedLogit_Manchester_Short.R

+276
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version1/NestedLogit_Manchester_tree2.R

+252
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version2/Manchester_TripDataPreparation_v2.R

+274
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version2/MultinomialLogit_Manchester.R

+240
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version2/NestedLogit_Manchester_Fast_v2.R

+278
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version2/NestedLogit_Manchester_JIBE_v2.R

+278
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version2/NestedLogit_Manchester_Short_TS2.R

+252
Large diffs are not rendered by default.

‎script/Manchester/modeChoice/mandatory/Version2/NestedLogit_Manchester_Short_v2.R

+279
Large diffs are not rendered by default.

‎script/Manchester/read.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ indiv <- indiv %>%
8787
transmute(hh.id = IDNumber,
8888
p.id = PersonNumber,
8989
p.ID = Person_ID,
90-
p.female = na_if(Gender,99) == "Female",
90+
p.female = na_if(Gender,"99") == "Female",
9191
p.age_group = Age,
9292
p.ethnicity = Ethnicity,
9393
p.licence = DrivingLicence,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
### Clear memory
2+
rm(list = ls())
3+
4+
# Libraries ---------------------------------------------------------------
5+
library(tidyverse)
6+
library(sf) # for spatial things
7+
library(lwgeom) # for advanced spatial things
8+
library(fitdistrplus) # for log normal distributions
9+
tripdata <- read.csv("data/Melbourne/DOT_VISTA/processed/T_VISTA_MAIN.csv",header=T, na.strings="N/A")
10+
df <- tripdata %>%
11+
mutate(
12+
orig_long = origlong,
13+
orig_lat = origlat,
14+
dest_long = destlong,
15+
dest_lat = destlat
16+
)
17+
############################################################################################################################################
18+
# filtering data based on geographic extent-----------------------------------------------------------------------------------------------------
19+
20+
21+
studyRegion <- st_read("~/Documents/melbourne/absRegionsReprojected.sqlite",layer="GCCSA_2016_AUST") %>%
22+
st_buffer(1)
23+
24+
orig_within_region <- df %>%
25+
st_as_sf(coords=c("origlong","origlat"),crs=4326) %>%
26+
st_transform(28355) %>%
27+
st_snap_to_grid(0.1) %>%
28+
filter(lengths(st_intersects(., studyRegion,prepared=TRUE,sparse=TRUE)) > 0)
29+
30+
dest_within_region <- df %>%
31+
st_as_sf(coords=c("destlong","destlat"),crs=4326) %>%
32+
st_transform(28355) %>%
33+
st_snap_to_grid(0.1) %>%
34+
filter(lengths(st_intersects(., studyRegion,prepared=TRUE,sparse=TRUE)) > 0)
35+
36+
#trips within greater Melbourne
37+
write.csv(orig_within_region,file = "data/Melbourne/DOT_VISTA/processed/origmelb_trips.csv",row.names= F)
38+
write.csv(dest_within_region,file = "data/Melbourne/DOT_VISTA/processed/destmelb_trips.csv",row.names=F)
39+
orig <- read_csv("data/Melbourne/DOT_VISTA/processed/origmelb_trips.csv", col_names = T,show_col_types = F)
40+
dest <- read_csv("data/Melbourne/DOT_VISTA/processed/destmelb_trips.csv", col_names = T,show_col_types = F)
41+
melbtrips <- semi_join(orig,dest, by="tripid")
42+
############################################################################################################################################
43+
# joining trip data with household&person data-----------------------------------------------------------------------------------------------------
44+
hhdata <- read.csv("data/Melbourne/DOT_VISTA/processed/H_VISTA_1220_Coord.csv")
45+
pdata <- read.csv("data/Melbourne/DOT_VISTA/processed/P_VISTA_1220_Coord.csv")
46+
tripshh <- merge(melbtrips,hhdata, by="hhid")
47+
tripshhp <- merge(tripshh,pdata, by="persid")
48+
49+
# filtering data based on surveyperiod
50+
trips <- subset(tripshhp, surveyperiod=="2016-17" | surveyperiod=="2017-18" | surveyperiod=="2018-19" | surveyperiod=="2019-20")
51+
52+
#recoding linkmode var (old tree structure)
53+
#trips$mainmode[mandatory_trips$linkmode=="Vehicle Driver"] = "card"
54+
#trips$mainmode[trips$linkmode=="Motorcycle"] = "card"
55+
#trips$mainmode[trips$linkmode=="Vehicle Passenger"] = "carp"
56+
#trips$mainmode[trips$linkmode=="Taxi"] = "carp"
57+
#trips$mainmode[trips$linkmode=="Walking"] = "walk"
58+
#trips$mainmode[trips$linkmode=="Jogging"] = "walk"
59+
#trips$mainmode[trips$linkmode=="Bicycle"] = "bike"
60+
#trips$mainmode[trips$linkmode=="Public Bus"] = "bus"
61+
#trips$mainmode[trips$linkmode=="School Bus"] = "bus"
62+
#trips$mainmode[trips$linkmode=="Train"] = "train"
63+
#trips$mainmode[trips$linkmode=="Tram"] = "tram"
64+
#trips$mainmode[trips$linkmode=="Other"] = "Other"
65+
#trips <- WE_trips[!(WE_trips$mainmode=="Other"),]
66+
67+
#recoding modes
68+
trips <- trips %>%
69+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'Motorcycle', 'Vehicle Driver', .)))%>%
70+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'Taxi', 'Vehicle Passenger', .))) %>%
71+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'Jogging', 'Walking', .)))%>%
72+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'Public Bus', 'PT', .)))%>%
73+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'Mobility Scooter', 'Bicycle', .)))%>%
74+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'School Bus', 'PT', .)))%>%
75+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'Train', 'PT', .)))%>%
76+
mutate_at(c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'),funs(ifelse(. == 'Tram', 'PT', .)))
77+
trips <- trips[!(trips$linkmode=="Other"),]
78+
79+
# concatenating modes
80+
trips <- trips %>%
81+
unite("combinedmode", c('mode1', 'mode2', 'mode3','mode4','mode5','mode6','mode7','mode8','mode9','mode10'), sep ='_', na.rm = TRUE, remove = FALSE)
82+
trips$combinedmode2 <- sapply(trips$combinedmode, function(x) paste(unique(unlist(str_split(x,"_"))), collapse = "_"))
83+
trips$combinedmode2 <- gsub('_Other', '', trips$combinedmode2)
84+
trips$combinedmode2 <- gsub('Other_', '', trips$combinedmode2)
85+
rep_str = c('Vehicle Driver'='Vehicle Driver','Vehicle Passenger'='Vehicle Passenger','Walking'='Walking', 'Bicycle'='Bicycle','Bicycle_PT'= 'PT_walk_Bike',
86+
'Bicycle_PT_Walking'='PT_walk_Bike', 'Bicycle_Walking_PT'='PT_walk_Bike', 'PT_Walking'='PT_walk_Bike', 'Vehicle Driver_PT_Walking'='PT_Car', 'Bicycle_PT'='PT_Walk_Bike',
87+
'Vehicle Driver_Vehicle Passenger_PT_Walking'='PT_Car','Vehicle Driver_Walking_PT'='PT_Car','Vehicle Passenger_PT_Walking'='PT_Car',
88+
'Vehicle Passenger_Vehicle Driver_Walking_PT'='PT_Car', 'Vehicle Passenger_Walking_PT'='PT_walk_Bike', 'Walking_PT'='PT_walk_Bike','Walking_PT_Vehicle Driver'='PT_Car',
89+
'Walking_PT_Vehicle Passenger'='PT_walk_Bike','Vehicle Driver_Bicycle'='Vehicle Driver','Vehicle Driver_Vehicle Passenger'='Vehicle Driver',
90+
'Vehicle Driver_Vehicle Passenger_Walking'='Vehicle Driver','Vehicle Driver_Walking'='Vehicle Driver','Vehicle Driver_Walking_Vehicle Passenger'='Vehicle Driver',
91+
'Vehicle Passenger_Vehicle Driver_Walking'='Vehicle Driver','Vehicle Passenger_Walking'='Vehicle Passenger','Vehicle Passenger_Walking_Vehicle Driver'=
92+
'Vehicle Driver','Walking_Bicycle'='Walking', 'Bicycle_Walking'='Bicycle', 'Walking_Vehicle Driver'='Vehicle Driver','Walking_Vehicle Passenger'='Vehicle Passenger',
93+
'Vehicle Passenger_Vehicle Driver'='Vehicle Driver','Vehicle Passenger_PT_Walking'='PT_Walk_Bike','Vehicle Passenger_Walking_PT'='PT_Walk_Bike','Vehicle Driver_Vehicle Passenger'=
94+
'Vehicle Driver','Vehicle Passenger_PT_Walking'='PT_Walk_Bike','Vehicle Driver_PT_walking'='PT_Car','PT_walk_Bike_Walking'='PT_walk_Bike','Vehicle Driver_PT_walk_Bike'='PT_Car',
95+
'Vehicle Passenger_PT_walk_Bike'='PT_Car','PT_walk_Bike_Vehicle Driver'='PT_Car','PT_walk_Bike_Vehicle Passenger'='PT_Car','Vehicle Passenger_PT_Car'='PT_Car','Vehicle Driver_PT'='PT_Car',
96+
'Vehicle Passenger_PT'='PT_Car','Bicycle_Vehicle Driver'='Vehicle Driver','PT_Vehicle Driver'='PT_Car','PT_Car_Vehicle Passenger'='PT_Car','Vehicle Passenger_Bicycle'='Bicycle',
97+
'PT_Car_Bicycle'='PT_Car','PT_Vehicle Passenger'='PT_Car','PT_walk_Bike_Bicycle'='PT_walk_Bike')
98+
99+
trips$mainmode <- str_replace_all(trips$combinedmode2, rep_str)
100+
trips$mainmode[trips$mainmode=="PT"] = "PT_walk_Bike"
101+
102+
# mandatory data "home to work/education + work/education to home"
103+
mandatory_hwe<-subset(trips, trips$origplace1=="Accommodation"& trips$destpurp1=="Work Related" | trips$destpurp1=="Education")
104+
mandatory_weh<-subset(trips, trips$origplace1=="Workplace" | trips$origplace1=="Place of Education"& trips$destpurp1=="At or Go Home")
105+
mandatory_tot<-rbind(mandatory_hwe,mandatory_weh)
106+
trips<-mandatory_tot
107+
108+
#generaing age groups
109+
trips$agegroup[trips$age<=14] = 1
110+
trips$agegroup[15<=trips$age & trips$age<=24] = 2
111+
trips$agegroup[25<=trips$age & trips$age<=34] = 3
112+
trips$agegroup[35<=trips$age & trips$age<=44] = 3
113+
trips$agegroup[45<=trips$age & trips$age<=54] = 4
114+
trips$agegroup[55<=trips$age & trips$age<=64] = 5
115+
trips$agegroup[trips$age>=65] = 6
116+
117+
# recoding sex var
118+
trips$female[trips$sex=="F"] = 1
119+
trips$female[trips$sex=="M"] = 0
120+
121+
# recoding carlicence var
122+
trips$licence[trips$carlicence=="Full Licence"] = 1
123+
trips$licence[trips$carlicence=="Green Probationary Licence"] = 1
124+
trips$licence[trips$carlicence=="Learners Permit"] = 1
125+
trips$licence[trips$carlicence=="Red Probationary Licence"] = 1
126+
trips$licence[trips$carlicence=="No Car Licence"] = 0
127+
128+
# recoding No of cars in HH
129+
trips$carsno[trips$cars == 0] = 0
130+
trips$carsno[trips$cars == 1] = 1
131+
trips$carsno[trips$cars== 2] = 2
132+
trips$carsno[trips$cars >=3] = 3
133+
134+
# recoding No of bikes in HH
135+
trips$bikes[trips$adultbikes == 0] = 0
136+
trips$bikes[trips$adultbikes == 1] = 1
137+
trips$bikes[trips$adultbikes== 2] = 2
138+
trips$bikes[trips$adultbikes >=3] = 3
139+
140+
# recoding No of bikes in HH
141+
trips$hh.size[trips$adultbikes == 0] = 0
142+
trips$hh.size[trips$adultbikes == 1] = 1
143+
trips$hh.size[trips$adultbikes== 2] = 2
144+
trips$hh.size[trips$adultbikes >=3] = 3
145+
146+
#recoding sex var
147+
trips$gender[trips$sex=="M"] = 1
148+
trips$gender[trips$sex=="F"] = 0
149+
150+
#recoding household income var
151+
trips$hhinc_an = trips$hhinc*52
152+
trips$hhincat[trips$hhinc_an<=59999] = 1
153+
trips$hhincat[60000<=trips$hhinc_an & trips$hhinc_an<=94999] = 2
154+
trips$hhincat[95000<=trips$hhinc_an & trips$hhinc_an<=139999] = 3
155+
trips$hhincat[140000<=trips$hhinc_an & trips$hhinc_an<=189999] = 4
156+
trips$hhincat[trips$hhinc_an>=190000] = 5
157+
trips$hhincat[is.na(trips$hhinc_an)] = 6 # missing/refused to respond
158+
159+
#recoding work type
160+
trips$work.type[trips$worktype=="Fixed Hours"] = 1 #working full time
161+
trips$work.type[trips$worktype=="Flexible Hours"|trips$worktype=="Work from Home"] = 2
162+
trips$work.type[trips$worktype=="Rostered Shifts"] = 3
163+
trips$work.type[trips$worktype=="Not in Work Force"] = 4
164+
165+
#recoding mainmode
166+
trips$mainmode2[trips$mainmode == "Vehicle Driver"] = 1
167+
trips$mainmode2[trips$mainmode == "Vehicle Passenger"] = 2
168+
trips$mainmode2[trips$mainmode == "Walking"] = 3
169+
trips$mainmode2[trips$mainmode == "Bicycle"] = 4
170+
trips$mainmode2[trips$mainmode == "PT_Car"] = 5
171+
trips$mainmode2[trips$mainmode == "PT_walk_Bike"] = 6
172+
173+
#joining with route attributes
174+
route_attributes <- read.csv("data/Melbourne/DOT_VISTA/processed/route_attributes.csv")
175+
trips <- merge(trips, route_attributes, by="tripid")
176+
#joining car and pt travel times
177+
ptcar_time <- read.csv("data/Melbourne/DOT_VISTA/processed/carandpt_time.csv")
178+
trips <- merge(trips, ptcar_time, by="tripid")
179+
180+
#generating availability of modes (should be edited)
181+
trips$availcard <- 1
182+
trips$availcard[trips$time_car == 0] = 0
183+
#trips$availcard[trips$carsno == 0] = 0
184+
#trips$availcard[trips$mainmode2 == 1] = 1
185+
trips$availcarp <- 1
186+
trips$availcarp[trips$time_car == 0] = 0
187+
#trips$availcarp[trips$carsno == 0] = 0
188+
#trips$availcarp[trips$mainmode2 == 2] = 1
189+
trips$availwalk <- 1
190+
trips$availwalk[trips$troutewalk_short_tt_s == 0] = 0
191+
#trips$availwalk[trips$troutewalk_fast_tt_s == 0] = 0 #to be activated before running models with fast route attributes
192+
#trips$availwalk[trips$troutewalk_jibe_tt_s == 0] = 0 #to be activated before running models with jibe route attributes
193+
#trips$availwalk[trips$mainmode == 3] = 1
194+
trips$availbike <- 1
195+
trips$availbike[trips$troutebike_short_tt_s == 0] = 0
196+
#trips$availbike[trips$troutebike_fast_tt_s == 0] = 0 #to be activated before running models with fast route attributes
197+
#trips$availbike[trips$troutebike_jibe_tt_s == 0] = 0 #to be activated before running models with jibe route attributes
198+
#trips$availbike[trips$bikes == 0] = 0
199+
#trips$availbike[trips$mainmode2 == 4] = 1
200+
trips$availptcar <- 1
201+
trips$availptcar[trips$time_ptcar == 0] = 0
202+
#trips$availptcar[trips$mainmode2 == 5] = 1
203+
trips$availptwalk <- 1
204+
trips$availptwalk[trips$time_ptwalk == 0] = 0
205+
#trips$availptwalk[trips$mainmode2 == 6] = 1
206+
trips <- trips[!(trips$time_car==0 & trips$mainmode2==1),]
207+
trips <- trips[!(trips$time_car==0 & trips$mainmode2==2),]
208+
trips <- trips[!(trips$time_ptcar==0 & trips$mainmode2==5),]
209+
trips <- trips[!(trips$time_ptwalk==0 & trips$mainmode2==6),]
210+
211+
#modifying stress junction var
212+
trips$stressjct_walk_short <- trips$troutewalk_short_stressjct*trips$troutewalk_short_distance_m
213+
trips$stressjct_bike_short <- trips$troutebike_short_stressjct*trips$troutebike_short_distance_m
214+
trips$stressjct_walk_fast <- trips$troutewalk_fast_stressjct*trips$troutewalk_fast_distance_m
215+
trips$stressjct_bike_fast <- trips$troutebike_fast_stressjct*trips$troutebike_fast_distance_m
216+
trips$stressjct_walk_jibe <- trips$troutewalk_jibe_stressjct*trips$troutewalk_jibe_distance_m
217+
trips$stressjct_bike_jibe <- trips$troutebike_jibe_stressjct*trips$troutebike_jibe_distance_m
218+
219+
# generating log transforamtion of distance
220+
trips$logdist_walk_short = log(trips$troutewalk_short_distance_m)
221+
trips$logdist_bike_short = log(trips$troutewalk_short_distance_m)
222+
trips$logdist_walk_fast = log(trips$troutewalk_fast_distance_m)
223+
trips$logdist_bike_fast = log(trips$troutewalk_fast_distance_m)
224+
trips$logdist_walk_jibe = log(trips$troutewalk_jibe_distance_m)
225+
trips$logdist_bike_jibe = log(trips$troutewalk_jibe_distance_m)
226+
227+
#generating a weighting variable based on walk and bike log distances
228+
trips <- with(trips,trips[order(trips$logdist_walk_short,trips$logdist_bike_short),])
229+
trips <- trips %>% rowwise() %>%
230+
mutate(weight_short = mean(c(logdist_walk_short, logdist_bike_short)))
231+
trips <- with(trips,trips[order(trips$logdist_walk_fast,trips$logdist_bike_fast),])
232+
trips <- trips %>% rowwise() %>%
233+
mutate(weight_fast = mean(c(logdist_walk_fast, logdist_bike_fast)))
234+
trips <- with(trips,trips[order(trips$logdist_walk_jibe,trips$logdist_bike_jibe),])
235+
trips <- trips %>% rowwise() %>%
236+
mutate(weight_jibe = mean(c(logdist_walk_jibe, logdist_bike_jibe)))
237+
238+
# mandatory tours
239+
240+
#joining with gnaf point for area-based measures
241+
#orig long&lat of mandatory trips were joined to gnaf points using near analysis in qgis
242+
#gnaf <- read.csv("C:/Users/e18933/OneDrive - RMIT University/WORK/Lucy/Data/ganf_points_selectedBEmeasures.csv",header=T, na.strings="N/A")
243+
#mandatory_gnaf <- read_csv("data/Melbourne/DOT_VISTA/processed/Mandatory_tours_origgnaf.csv")
244+
#mandatory_gnaf <- rename(mandatory_gnaf, gnaf_pid = HubName)
245+
#mandatory_gnaf <- rename(mandatory_gnaf, origdist_gnaf = HubDist)
246+
#trips_alljoined <-merge(mandatory_gnaf, gnaf, by="gnaf_pid")
247+
248+
# filtering trips started from home
249+
#hb_trips <- mandatory_tours %>%
250+
# group_by(persid)
251+
#hb_trips <- hb_trips[hb_trips$tripno == 1 & hb_trips$origpurp1 == "At Home", ]
252+
253+
# filtering mandatory(work&education) trips
254+
#mandatory_trips <- subset(hb_trips, trippurp=="Education"|trippurp=="Work Related")
255+
#mandatory_trips <- mandatory_trips %>%
256+
# relocate(gnaf_pid, .before = origdist_gnaf)
257+
258+
# exporting work and education trips to csv format
259+
write.csv(trips,file = "data/Melbourne/DOT_VISTA/processed/mandatory_trips.csv")
260+
261+

‎script/Melbourne/modeChoice/MultinomialLogit_Melbourne_short.R

+255
Large diffs are not rendered by default.

‎script/Melbourne/modeChoice/NestedLogit_Melbourne_Fast.R

+267
Large diffs are not rendered by default.

‎script/Melbourne/modeChoice/NestedLogit_Melbourne_JIBE.R

+268
Large diffs are not rendered by default.

‎script/Melbourne/modeChoice/NestedLogit_Melbourne_Short.R

+268
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.