Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rm(list = ls())
- library(apollo)
- library(tidyverse)
- library(dplyr)
- library(psych)
- library(utils)
- library(fastDummies)
- library(cutoff)
- library(lavaan)
- library(semPlot)
- library(StatMatch)
- library(semTools)
- library(SciViews)
- library(readxl)
- # ─────────────────────────────────────────────────────────────────────────────
- # 1. Data wrangling ---------------------------------------------------------
- # ─────────────────────────────────────────────────────────────────────────────
- data <- read_excel("D:/adeeba/Dataset_long.xlsx")
- data <- data %>%
- mutate(across(c(2, 4, 62, 63, 76, 79, 81, 83, 85, 88, 90, 182:186, 188,
- 222, 223), as.factor)) %>%
- dummy_cols(
- select_columns = c("marry_stat", "education", "student", "emp_stat",
- "emp_arrange", "license", "hh_living_stat", "hh_years",
- "personal_income", "family_income"),
- remove_selected_columns = TRUE
- ) %>%
- mutate(
- edu_below_uni = education_1 + education_2,
- student = student_3 + student_2,
- employed = emp_stat_3 + emp_stat_4,
- hybrid_worker = emp_arrange_3 + emp_arrange_4 + emp_arrange_5,
- living_with_family = hh_living_stat_3 + hh_living_stat_4 + hh_living_stat_5,
- hh_years_above_5 = hh_years_4 + hh_years_5,
- personal_income_above_25k= personal_income_3 + personal_income_4 +
- personal_income_5 + personal_income_6 +
- personal_income_7 + personal_income_8,
- personal_income_above_50k= personal_income_4 + personal_income_5 +
- personal_income_6 + personal_income_7 +
- personal_income_8,
- family_income_above_50k = family_income_4 + family_income_5 +
- family_income_6 + family_income_7 +
- family_income_8 + family_income_9 +
- family_income_10 + family_income_11,
- family_income_above_100k = family_income_6 + family_income_7 +
- family_income_8 + family_income_9 +
- family_income_10 + family_income_11
- )
- database <- data
- database$bus.crowd2 <- ifelse(database$bus.crowd == 2, 1, 0)
- database$bus.crowd3 <- ifelse(database$bus.crowd == 3, 1, 0)
- database$transit.crowd2 <- ifelse(database$transit.crowd == 2, 1, 0)
- database$transit.crowd3 <- ifelse(database$transit.crowd == 3, 1, 0)
- database$best <- case_when(
- database$choice == "privatecar" ~ 1,
- database$choice == "ubercar" ~ 2,
- database$choice == "cng" ~ 3,
- database$choice == "bike" ~ 4,
- database$choice == "rickshaw" ~ 5,
- database$choice == "bus" ~ 6,
- database$choice == "transit" ~ 7
- )
- # remove any previously calculated LV columns that may exist
- database <- database[ , !names(database) %in%
- c("decisionoverload","hassle","knowledge",
- "socialnorms","attmultimodality")]
- # ─────────────────────────────────────────────────────────────────────────────
- # 2. Apollo set-up ----------------------------------------------------------
- # ─────────────────────────────────────────────────────────────────────────────
- apollo_initialise()
- apollo_control <- list(
- modelName = "Congestion Mode Choice Model (ICLV_OL_500_orig spec)",
- modelDescr = "Mixed Logit model with OL",
- indivID = "id",
- nCores = 4
- )
- apollo_beta = c(
- ### Alternative Specific Constants (ASC) – base case is PrivateCar
- asc_pc = 0,
- asc_ubercar = 0, # Ride-hailing car
- asc_cng = 0, # Ride-hailing cng
- asc_bike = 0, # Ride-hailing bike
- asc_rickshaw = 0, # Rickshaw
- asc_bus = 0, # Bus
- asc_transit = 0, # Transit (MRT/BRT)
- ### Travel Time Coefficients
- b_attc = -0.0591, # Average travel time for PrivateCar
- b_attr = -0.0321, # Average travel time for Rickshaw
- b_attb = -0.0351, # Average travel time for Bus
- b_attt = -0.0600, # Average travel time for Transit
- b_attbike = -0.0591, # Average travel time for RH bike
- # Means of random parameters
- mu_conttc = -0.006, # PrivateCar
- mu_conttr = -0.008, # Rickshaw
- mu_conttb = -0.015, # Bus
- mu_conttt = -0.013, # Transit
- mu_conttbike= -0.008, # RideHailingBike
- mu_uncerc = -0.006, # PrivateCar
- mu_uncerr = -0.010, # Rickshaw
- mu_uncerb = -0.015, # Bus
- mu_uncerbike= -0.006, # RideHailingBike
- # Standard deviations of random parameters
- sigma_conttc = 0.002,
- sigma_conttr = 0.002,
- sigma_conttb = 0.002,
- sigma_conttt = 0.002,
- sigma_conttbike= 0.002,
- sigma_uncerc = 0.002,
- sigma_uncerr = 0.002,
- sigma_uncerb = 0.002,
- sigma_uncerbike= 0.002,
- ### Cost
- b_cost = -0.0107, # Cost (PrivateCar, Rickshaw, Bus, Transit)
- b_parkfee = -0.03, # Parking fee – only for PrivateCar
- ### Wait Time and Walk Time
- b_wait = -0.08, # Waiting time for Ride-hailing, Rickshaw, Transit, Bus
- b_walk = -0.07, # Walking time for Bus and Transit
- ### Transfers
- b_transfers = -0.5, # Number of transfers (Bus, Transit)
- ### Crowding
- b_crowd_2 = -0.4, # Crowding level 1 (moderately crowded)
- b_crowd_3 = -0.4, # Crowding level 2 (very crowded)
- ### Schedule Reliability
- b_schedule = 0.4, # Schedule dummy = 1 if reliable (Bus and Transit)
- ### Park-and-Ride
- b_pnr = 0.3, # PNR facility dummy – Transit only
- ### Grade-Separated Infrastructure
- b_grade = 0.5, # Dummy: 1 if MRT (fully grade-separated Transit), Dummy: 0 if BRT
- # MIMIC parameters
- # Decision Overload
- g_age_do = 1,
- g_student_do = 1,
- g_edu_below_uni_do = 1,
- g_hh_years_above_5_do = 1,
- g_personal_income_above_50k_do = 1,
- g_family_income_above_50k_do = 1,
- g_license_2_do = 1,
- g_dissonant_user_do = 1,
- g_pv_avail_number_do = 1,
- g_commuting_mmi_do = 1,
- g_passes_yes_do = 1,
- # Hassle
- g_age_hs = 1,
- g_student_hs = 1,
- g_edu_below_uni_hs = 1,
- g_hh_years_above_5_hs = 1,
- g_personal_income_above_50k_hs = 1,
- g_family_income_above_50k_hs = 1,
- g_license_2_hs = 1,
- g_commuting_mmi_hs = 1,
- g_marry_stat_1_hs = 1,
- g_employed_hs = 1,
- g_do_hs = 1, # linking latent variable decisionoverload to hassle
- # Attitude toward Multimodality
- g_age_att = 1,
- g_edu_below_uni_att = 1,
- g_family_income_above_50k_att= 1,
- g_license_2_att = 1,
- g_dissonant_user_att = 1,
- g_marry_stat_1_att = 1,
- g_gender_att = 1,
- g_employed_att = 1,
- g_pv_access_att = 1,
- g_disabled_yes_att = 1,
- g_employed_mm_view = 1,
- # Social Norms
- g_age_sn = 1,
- g_student_sn = 1,
- g_edu_below_uni_sn = 1,
- g_hh_years_above_5_sn = 1,
- g_family_income_above_50k_sn = 1,
- g_license_2_sn = 1,
- g_dissonant_user_sn = 1,
- g_commuting_mmi_sn = 1,
- g_marry_stat_1_sn = 1,
- # Knowledge
- g_age_ka = 1,
- g_edu_below_uni_ka = 1,
- g_hh_years_above_5_ka = 1,
- g_license_2_ka = 1,
- g_dissonant_user_ka = 1,
- g_commuting_mmi_ka = 1,
- g_gender_ka = 1,
- # Measurement equations parameters
- z_do4 = 1, z_do5 = 1,
- z_ka1 = 1, z_ka2 = 1, z_ka3 = 1,
- z_hs1 = 1, z_hs2 = 1, z_hs3 = 1, z_hs4 = 1, z_hs5 = 1, z_hs6 = 1, z_hs7 = 1,
- z_att1= 1, z_att2= 1, z_att3= 1, z_att5= 1, z_att6= 1,
- z_sn1 = 1, z_sn2 = 1, z_sn3 = 1,
- # Decision Overload
- tau_do4_1 = -2, tau_do4_2 = -1, tau_do4_3 = 1, tau_do4_4 = 2,
- tau_do5_1 = -2, tau_do5_2 = -1, tau_do5_3 = 1, tau_do5_4 = 2,
- # Knowledge Adequacy
- tau_ka1_1 = -2, tau_ka1_2 = -1, tau_ka1_3 = 1, tau_ka1_4 = 2,
- tau_ka2_1 = -2, tau_ka2_2 = -1, tau_ka2_3 = 1, tau_ka2_4 = 2,
- tau_ka3_1 = -2, tau_ka3_2 = -1, tau_ka3_3 = 1, tau_ka3_4 = 2,
- # Hassle
- tau_hs1_1 = -2, tau_hs1_2 = -1, tau_hs1_3 = 1, tau_hs1_4 = 2,
- tau_hs2_1 = -2, tau_hs2_2 = -1, tau_hs2_3 = 1, tau_hs2_4 = 2,
- tau_hs3_1 = -2, tau_hs3_2 = -1, tau_hs3_3 = 1, tau_hs3_4 = 2,
- tau_hs4_1 = -2, tau_hs4_2 = -1, tau_hs4_3 = 1, tau_hs4_4 = 2,
- tau_hs5_1 = -2, tau_hs5_2 = -1, tau_hs5_3 = 1, tau_hs5_4 = 2,
- tau_hs6_1 = -2, tau_hs6_2 = -1, tau_hs6_3 = 1, tau_hs6_4 = 2,
- tau_hs7_1 = -2, tau_hs7_2 = -1, tau_hs7_3 = 1, tau_hs7_4 = 2,
- # Attitude Toward Multimodality
- tau_att1_1 = -2, tau_att1_2 = -1, tau_att1_3 = 1, tau_att1_4 = 2,
- tau_att2_1 = -2, tau_att2_2 = -1, tau_att2_3 = 1, tau_att2_4 = 2,
- tau_att3_1 = -2, tau_att3_2 = -1, tau_att3_3 = 1, tau_att3_4 = 2,
- tau_att5_1 = -2, tau_att5_2 = -1, tau_att5_3 = 1, tau_att5_4 = 2,
- tau_att6_1 = -2, tau_att6_2 = -1, tau_att6_3 = 1, tau_att6_4 = 2,
- # Social Norms
- tau_sn1_1 = -2, tau_sn1_2 = -1, tau_sn1_3 = 1, tau_sn1_4 = 2,
- tau_sn2_1 = -2, tau_sn2_2 = -1, tau_sn2_3 = 1, tau_sn2_4 = 2,
- tau_sn3_1 = -2, tau_sn3_2 = -1, tau_sn3_3 = 1, tau_sn3_4 = 2
- )
- apollo_fixed <- c() # nothing fixed
- # ─────────────────────────────────────────────────────────────────────────────
- # 3. Draws and random coefficients -----------------------------------------
- # ─────────────────────────────────────────────────────────────────────────────
- apollo_draws <- list(
- interDrawsType = "halton",
- interNDraws = 100,
- interNormDraws = c("eta_do","eta_ka","eta_hs","eta_att","eta_sn",
- "draws_conttc","draws_conttr","draws_conttb",
- "draws_conttt","draws_conttbike",
- "draws_uncerc","draws_uncerr","draws_uncerb",
- "draws_uncerbike")
- )
- apollo_randCoeff <- function(apollo_beta, apollo_inputs){
- rc <- list()
- ## random coefficients for travel-time congestion & uncertainty ----------
- rc$b_conttc <- -exp(mu_conttc + sigma_conttc * draws_conttc)
- rc$b_conttr <- -exp(mu_conttr + sigma_conttr * draws_conttr)
- rc$b_conttb <- -exp(mu_conttb + sigma_conttb * draws_conttb)
- rc$b_conttt <- -exp(mu_conttt + sigma_conttt * draws_conttt)
- rc$b_conttbike <- -exp(mu_conttbike + sigma_conttbike * draws_conttbike)
- rc$b_uncerc <- -exp(mu_uncerc + sigma_uncerc * draws_uncerc)
- rc$b_uncerr <- -exp(mu_uncerr + sigma_uncerr * draws_uncerr)
- rc$b_uncerb <- -exp(mu_uncerb + sigma_uncerb * draws_uncerb)
- rc$b_uncerbike <- -exp(mu_uncerbike + sigma_uncerbike * draws_uncerbike)
- ## latent variables (MIMIC structure) --------------------------------------
- rc$decisionoverload <- g_age_do*age + g_student_do*student + g_edu_below_uni_do*edu_below_uni +
- g_hh_years_above_5_do*hh_years_above_5 +
- g_personal_income_above_50k_do*personal_income_above_50k +
- g_family_income_above_50k_do*family_income_above_50k +
- g_license_2_do*license_2 + g_dissonant_user_do*dissonant_user +
- g_pv_avail_number_do*pv_avail_number +
- g_commuting_mmi_do*commuting_mmi +
- g_passes_yes_do*passes_yes + eta_do
- rc$hassle <- g_age_hs*age + g_student_hs*student + g_edu_below_uni_hs*edu_below_uni +
- g_hh_years_above_5_hs*hh_years_above_5 +
- g_personal_income_above_50k_hs*personal_income_above_50k +
- g_family_income_above_50k_hs*family_income_above_50k +
- g_license_2_hs*license_2 + g_commuting_mmi_hs*commuting_mmi +
- g_marry_stat_1_hs*marry_stat_1 + g_employed_hs*employed +
- g_do_hs*rc$decisionoverload + eta_hs
- rc$attmultimodality <- g_age_att*age + g_edu_below_uni_att*edu_below_uni +
- g_family_income_above_50k_att*family_income_above_50k +
- g_license_2_att*license_2 + g_dissonant_user_att*dissonant_user +
- g_marry_stat_1_att*marry_stat_1 + g_gender_att*gender +
- g_employed_mm_view*employed + g_pv_access_att*pv_access +
- g_disabled_yes_att*disabled_yes + eta_att
- rc$socialnorms <- g_age_sn*age + g_student_sn*student + g_edu_below_uni_sn*edu_below_uni +
- g_hh_years_above_5_sn*hh_years_above_5 +
- g_family_income_above_50k_sn*family_income_above_50k +
- g_license_2_sn*license_2 + g_dissonant_user_sn*dissonant_user +
- g_commuting_mmi_sn*commuting_mmi + g_marry_stat_1_sn*marry_stat_1 +
- eta_sn
- rc$knowledge <- g_age_ka*age + g_edu_below_uni_ka*edu_below_uni +
- g_hh_years_above_5_ka*hh_years_above_5 + g_license_2_ka*license_2 +
- g_dissonant_user_ka*dissonant_user + g_commuting_mmi_ka*commuting_mmi +
- g_gender_ka*gender + eta_ka
- # export them as plain symbols for apollo_probabilities()
- list2env(rc, parent.frame())
- return(rc)
- }
- # ─────────────────────────────────────────────────────────────────────────────
- # 4. Validate inputs --------------------------------------------------------
- # ─────────────────────────────────────────────────────────────────────────────
- apollo_inputs <- apollo_validateInputs()
- # ─────────────────────────────────────────────────────────────────────────────
- # 5. Likelihood function ----------------------------------------------------
- # ─────────────────────────────────────────────────────────────────────────────
- apollo_probabilities <- function(apollo_beta, apollo_inputs, functionality = "estimate"){
- apollo_attach(apollo_beta, apollo_inputs)
- on.exit(apollo_detach(apollo_beta, apollo_inputs))
- P <- list()
- ## ordered-logit measurement models ---------------------------------------
- P$do4 <- apollo_ol(list(outcomeOrdered = do4,
- V = z_do4 * decisionoverload,
- tau = list(tau_do4_1,tau_do4_2,tau_do4_3,tau_do4_4),
- rows = (sp_scen == 1),
- componentName="do4"), functionality)
- P$do5 <- apollo_ol(list(outcomeOrdered = do5,
- V = z_do5 * decisionoverload,
- tau = list(tau_do5_1,tau_do5_2,tau_do5_3,tau_do5_4),
- rows = (sp_scen == 1),
- componentName="do5"), functionality)
- P$hs1 <- apollo_ol(list(outcomeOrdered = hs1,
- V = z_hs1 * hassle,
- tau = list(tau_hs1_1,tau_hs1_2,tau_hs1_3,tau_hs1_4),
- rows = (sp_scen == 1),
- componentName="hs1"), functionality)
- # … (repeat for hs2-hs7, ka1-ka3, sn1-sn3, att1-att6) … --------------------
- P$hs2 <- apollo_ol(list(outcomeOrdered=hs2,V=z_hs2*hassle,
- tau=list(tau_hs2_1,tau_hs2_2,tau_hs2_3,tau_hs2_4),
- rows=(sp_scen==1),componentName="hs2"),functionality)
- P$hs3 <- apollo_ol(list(outcomeOrdered=hs3,V=z_hs3*hassle,
- tau=list(tau_hs3_1,tau_hs3_2,tau_hs3_3,tau_hs3_4),
- rows=(sp_scen==1),componentName="hs3"),functionality)
- P$hs4 <- apollo_ol(list(outcomeOrdered=hs4,V=z_hs4*hassle,
- tau=list(tau_hs4_1,tau_hs4_2,tau_hs4_3,tau_hs4_4),
- rows=(sp_scen==1),componentName="hs4"),functionality)
- P$hs5 <- apollo_ol(list(outcomeOrdered=hs5,V=z_hs5*hassle,
- tau=list(tau_hs5_1,tau_hs5_2,tau_hs5_3,tau_hs5_4),
- rows=(sp_scen==1),componentName="hs5"),functionality)
- P$hs6 <- apollo_ol(list(outcomeOrdered=hs6,V=z_hs6*hassle,
- tau=list(tau_hs6_1,tau_hs6_2,tau_hs6_3,tau_hs6_4),
- rows=(sp_scen==1),componentName="hs6"),functionality)
- P$hs7 <- apollo_ol(list(outcomeOrdered=hs7,V=z_hs7*hassle,
- tau=list(tau_hs7_1,tau_hs7_2,tau_hs7_3,tau_hs7_4),
- rows=(sp_scen==1),componentName="hs7"),functionality)
- P$ka1 <- apollo_ol(list(outcomeOrdered=ka1,V=z_ka1*knowledge,
- tau=list(tau_ka1_1,tau_ka1_2,tau_ka1_3,tau_ka1_4),
- rows=(sp_scen==1),componentName="ka1"),functionality)
- P$ka2 <- apollo_ol(list(outcomeOrdered=ka2,V=z_ka2*knowledge,
- tau=list(tau_ka2_1,tau_ka2_2,tau_ka2_3,tau_ka2_4),
- rows=(sp_scen==1),componentName="ka2"),functionality)
- P$ka3 <- apollo_ol(list(outcomeOrdered=ka3,V=z_ka3*knowledge,
- tau=list(tau_ka3_1,tau_ka3_2,tau_ka3_3,tau_ka3_4),
- rows=(sp_scen==1),componentName="ka3"),functionality)
- P$sn1 <- apollo_ol(list(outcomeOrdered=sn1,V=z_sn1*socialnorms,
- tau=list(tau_sn1_1,tau_sn1_2,tau_sn1_3,tau_sn1_4),
- rows=(sp_scen==1),componentName="sn1"),functionality)
- P$sn2 <- apollo_ol(list(outcomeOrdered=sn2,V=z_sn2*socialnorms,
- tau=list(tau_sn2_1,tau_sn2_2,tau_sn2_3,tau_sn2_4),
- rows=(sp_scen==1),componentName="sn2"),functionality)
- P$sn3 <- apollo_ol(list(outcomeOrdered=sn3,V=z_sn3*socialnorms,
- tau=list(tau_sn3_1,tau_sn3_2,tau_sn3_3,tau_sn3_4),
- rows=(sp_scen==1),componentName="sn3"),functionality)
- P$att1 <- apollo_ol(list(outcomeOrdered=att1,V=z_att1*attmultimodality,
- tau=list(tau_att1_1,tau_att1_2,tau_att1_3,tau_att1_4),
- rows=(sp_scen==1),componentName="att1"),functionality)
- P$att2 <- apollo_ol(list(outcomeOrdered=att2,V=z_att2*attmultimodality,
- tau=list(tau_att2_1,tau_att2_2,tau_att2_3,tau_att2_4),
- rows=(sp_scen==1),componentName="att2"),functionality)
- P$att3 <- apollo_ol(list(outcomeOrdered=att3,V=z_att3*attmultimodality,
- tau=list(tau_att3_1,tau_att3_2,tau_att3_3,tau_att3_4),
- rows=(sp_scen==1),componentName="att3"),functionality)
- P$att5 <- apollo_ol(list(outcomeOrdered=att5,V=z_att5*attmultimodality,
- tau=list(tau_att5_1,tau_att5_2,tau_att5_3,tau_att5_4),
- rows=(sp_scen==1),componentName="att5"),functionality)
- P$att6 <- apollo_ol(list(outcomeOrdered=att6,V=z_att6*attmultimodality,
- tau=list(tau_att6_1,tau_att6_2,tau_att6_3,tau_att6_4),
- rows=(sp_scen==1),componentName="att6"),functionality)
- ## utility for each alternative ------------------------------------------
- V <- list()
- V$privatecar <- asc_pc +
- b_attc * privatecar.attc +
- b_conttc*privatecar.conttc*privatecar.attc +
- b_uncerc*privatecar.uncer*privatecar.conttc*privatecar.attc +
- b_cost * privatecar.costc +
- b_parkfee*privatecar.parkfeec
- V$ubercar <- asc_ubercar +
- b_attc * ridehailingcar.attc +
- b_conttc*ridehailingcar.conttc*ridehailingcar.attc +
- b_uncerc*ridehailingcar.uncer*ridehailingcar.conttc*ridehailingcar.attc +
- b_cost * ridehailingcar.costu +
- b_wait * ridehailingcar.waitu
- V$cng <- asc_cng +
- b_attc * ridehailingcar.attc +
- b_conttc*ridehailingcar.conttc*ridehailingcar.attc +
- b_uncerc*ridehailingcar.uncer*ridehailingcar.conttc*ridehailingcar.attc +
- b_cost * ridehailingcng.costu +
- b_wait * ridehailingcar.waitu
- V$bike <- asc_bike +
- b_attbike * ridehailingbike.attc +
- b_conttbike*ridehailingbike.conttc*ridehailingbike.attc +
- b_uncerbike*ridehailingcar.uncer*ridehailingbike.conttc*ridehailingbike.attc +
- b_cost * ridehailingbike.costu +
- b_wait * ridehailingcar.waitu
- V$rickshaw <- asc_rickshaw +
- b_attr * rickshaw.attr +
- b_conttr*rickshaw.conttc*rickshaw.attr +
- b_uncerr*rickshaw.uncer*rickshaw.conttc*rickshaw.attr +
- b_cost * rickshaw.costr +
- b_wait * rickshaw.waitr +
- b_transfers*rickshaw.transfersr
- V$bus <- asc_bus +
- b_attb * bus.attb +
- b_conttb*bus.conttc*bus.attb +
- b_uncerb*bus.uncer*bus.conttc*bus.attb +
- b_cost * bus.costb +
- b_walk * bus.walk +
- b_wait * bus.waitr +
- b_transfers*bus.transfers +
- b_crowd_2*bus.crowd2 + b_crowd_3*bus.crowd3 +
- b_schedule*bus.schedule
- V$transit <- asc_transit +
- b_attt * transit.attt +
- b_conttt*transit.conttt*transit.attt +
- b_cost * transit.costt +
- b_walk * transit.walk +
- b_wait * transit.waitu +
- b_transfers*transit.transfers +
- b_crowd_2*transit.crowd2 + b_crowd_3*transit.crowd3 +
- b_schedule*transit.schedule +
- b_pnr*transit.pnrt + b_grade*transit.gradet
- avail <- list(privatecar=pc_avail, ubercar=rhcar_avail, cng=rhcng_avail,
- bike=rhbike_avail, rickshaw=rick_avail,
- bus=bus_avail, transit=transit_avail)
- mnl_set <- list(alternatives = c(privatecar=1, ubercar=2, cng=3, bike=4,
- rickshaw=5, bus=6, transit=7),
- avail = avail,
- choiceVar = best,
- V = V,
- componentName= "choice")
- P$choice <- apollo_mnl(mnl_set, functionality)
- ## combine, average draws, panel etc. --------------------------------------
- P <- apollo_combineModels(P, apollo_inputs, functionality)
- P <- apollo_panelProd (P, apollo_inputs, functionality)
- P <- apollo_avgInterDraws(P, apollo_inputs, functionality)
- P <- apollo_prepareProb (P, apollo_inputs, functionality)
- return(P)
- }
- # ─────────────────────────────────────────────────────────────────────────────
- # 6. Estimation -------------------------------------------------------------
- # ─────────────────────────────────────────────────────────────────────────────
- estimate_settings <- list(maxIterations = 1500, estimationRoutine = "BFGS")
- modechoice_model <- apollo_estimate(
- apollo_beta,
- apollo_fixed,
- apollo_probabilities,
- apollo_inputs,
- estimate_settings
- )
- apollo_modelOutput(modechoice_model)
- ##############output
- Preparing user-defined functions.
- WARNING: The pre-processing of 'apollo_probabilities' failed in initial testing. Your model may still run, but this indicates a potential problem. Please contact the
- developers for assistance!
- Testing likelihood function...
- INFORMATION: No coding provided for Ordered model component "do4", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component do4:
- 1 2 3 4 5
- Times chosen 13.00 463.00 152.00 357.00 86.00
- Percentage chosen overall 1.21 43.23 14.19 33.33 8.03
- INFORMATION: No coding provided for Ordered model component "do5", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component do5:
- 1 2 3 4 5
- Times chosen 26.00 365.00 182.00 391.00 107.00
- Percentage chosen overall 2.43 34.08 16.99 36.51 9.99
- INFORMATION: No coding provided for Ordered model component "hs1", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component hs1:
- 1 2 3 4 5
- Times chosen 3.00 148.00 213.00 598.00 109.00
- Percentage chosen overall 0.28 13.82 19.89 55.84 10.18
- INFORMATION: No coding provided for Ordered model component "hs2", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component hs2:
- 1 2 3 4 5
- Times chosen 7.00 219.00 218.00 451.00 176.00
- Percentage chosen overall 0.65 20.45 20.35 42.11 16.43
- INFORMATION: No coding provided for Ordered model component "hs3", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component hs3:
- 1 2 3 4 5
- Times chosen 19.00 253.00 81.00 570.00 148.00
- Percentage chosen overall 1.77 23.62 7.56 53.22 13.82
- INFORMATION: No coding provided for Ordered model component "hs4", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component hs4:
- 1 2 3 4 5
- Times chosen 49.00 366.00 85.00 480.00 91.0
- Percentage chosen overall 4.58 34.17 7.94 44.82 8.5
- INFORMATION: No coding provided for Ordered model component "hs5", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component hs5:
- 1 2 3 4 5
- Times chosen 18.00 425.00 141.00 397.00 90.0
- Percentage chosen overall 1.68 39.68 13.17 37.07 8.4
- INFORMATION: No coding provided for Ordered model component "hs6", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component hs6:
- 1 2 3 4 5
- Times chosen 18.00 410.00 152.00 384.00 107.00
- Percentage chosen overall 1.68 38.28 14.19 35.85 9.99
- INFORMATION: No coding provided for Ordered model component "hs7", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component hs7:
- 1 2 3 4 5
- Times chosen 6.00 278.00 190.00 489.00 108.00
- Percentage chosen overall 0.56 25.96 17.74 45.66 10.08
- INFORMATION: No coding provided for Ordered model component "ka1", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component ka1:
- 1 2 3 4 5
- Times chosen 1.00 57.00 65.00 687.00 261.00
- Percentage chosen overall 0.09 5.32 6.07 64.15 24.37
- INFORMATION: No coding provided for Ordered model component "ka2", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component ka2:
- 1 2 3 4 5
- Times chosen 3.00 114.00 134.00 533.00 287.0
- Percentage chosen overall 0.28 10.64 12.51 49.77 26.8
- INFORMATION: No coding provided for Ordered model component "ka3", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component ka3:
- 1 2 3 4 5
- Times chosen 2.00 84.00 124.00 624.00 237.00
- Percentage chosen overall 0.19 7.84 11.58 58.26 22.13
- INFORMATION: No coding provided for Ordered model component "sn1", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component sn1:
- 1 2 3 4 5
- Times chosen 7.00 310.00 270.00 409.00 75
- Percentage chosen overall 0.65 28.94 25.21 38.19 7
- INFORMATION: No coding provided for Ordered model component "sn2", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component sn2:
- 1 2 3 4 5
- Times chosen 8.00 310.00 282.00 369.00 102.00
- Percentage chosen overall 0.75 28.94 26.33 34.45 9.52
- INFORMATION: No coding provided for Ordered model component "sn3", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component sn3:
- 1 2 3 4 5
- Times chosen 26.00 313.00 284.00 385.00 63.00
- Percentage chosen overall 2.43 29.23 26.52 35.95 5.88
- INFORMATION: No coding provided for Ordered model component "att1", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component att1:
- 1 2 3 4 5
- Times chosen 12.00 206.00 210.00 597.00 46.0
- Percentage chosen overall 1.12 19.23 19.61 55.74 4.3
- INFORMATION: No coding provided for Ordered model component "att2", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component att2:
- 1 2 3 4 5
- Times chosen 13.00 151.0 201.00 562.00 144.00
- Percentage chosen overall 1.21 14.1 18.77 52.47 13.45
- INFORMATION: No coding provided for Ordered model component "att3", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component att3:
- 1 2 3 4 5
- Times chosen 10.00 152.00 242.0 593.00 74.00
- Percentage chosen overall 0.93 14.19 22.6 55.37 6.91
- INFORMATION: No coding provided for Ordered model component "att5", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component att5:
- 1 2 3 4 5
- Times chosen 7.00 134.00 215.00 615.00 100.00
- Percentage chosen overall 0.65 12.51 20.07 57.42 9.34
- INFORMATION: No coding provided for Ordered model component "att6", so assuming outcomeOrdered goes from 1 to 5
- Overview of choices for OL model component att6:
- 1 2 3 4 5
- Times chosen 7.00 121.0 235.00 627.00 81.00
- Percentage chosen overall 0.65 11.3 21.94 58.54 7.56
- Overview of choices for MNL model component choice:
- privatecar ubercar cng bike rickshaw bus transit
- Times available 149.00 120.0 290.00 890.00 538.00 1225.00 1516.00
- Times chosen 117.00 15.0 61.00 369.00 97.00 293.00 1190.00
- Percentage chosen overall 5.46 0.7 2.85 17.23 4.53 13.68 55.56
- Percentage chosen when available 78.52 12.5 21.03 41.46 18.03 23.92 78.50
- Log-likelihood calculation fails at starting values!
- Affected individuals:
- ID LL
- 51 -Inf
- 52 -Inf
- 56 NaN
- 57 NaN
- 67 -Inf
- 68 -Inf
- 71 NaN
- 74 -Inf
- 77 NaN
- 120 NaN
- 126 -Inf
- 127 -Inf
- 128 NaN
- 130 -Inf
- 132 -Inf
- 133 NaN
- 135 -Inf
- 139 NaN
- 142 NaN
- 144 -Inf
- 145 -Inf
- 147 NaN
- 148 -Inf
- 149 -Inf
- 151 NaN
- 152 NaN
- 153 -Inf
- 154 NaN
- 156 -Inf
- 159 NaN
- 160 -Inf
- 161 -Inf
- 162 -Inf
- 163 -Inf
- 165 NaN
- 172 -Inf
- 173 NaN
- 175 -Inf
- 186 -Inf
- 189 NaN
- 204 -Inf
- 205 -Inf
- 206 -Inf
- 208 NaN
- 210 -Inf
- 211 NaN
- 212 -Inf
- 213 NaN
- 214 -Inf
- 215 NaN
- 216 NaN
- 220 NaN
- 224 -Inf
- 227 -Inf
- 228 -Inf
- 232 -Inf
- 233 -Inf
- 234 -Inf
- 238 NaN
- 240 NaN
- 244 -Inf
- 249 -Inf
- 253 NaN
- 256 -Inf
- 257 NaN
- 258 NaN
- 259 -Inf
- 260 NaN
- 264 NaN
- 265 NaN
- 274 NaN
- 275 -Inf
- 276 -Inf
- 277 -Inf
- 278 NaN
- 279 -Inf
- 280 -Inf
- 281 -Inf
- 282 NaN
- 283 -Inf
- 287 -Inf
- 294 -Inf
- 295 NaN
- 296 -Inf
- 297 -Inf
- 298 -Inf
- 303 -Inf
- 304 -Inf
- 307 -Inf
- 309 -Inf
- 313 -Inf
- 314 -Inf
- 321 NaN
- 322 -Inf
- 324 -Inf
- 326 NaN
- 331 NaN
- 332 -Inf
- 333 -Inf
- 337 -Inf
- 344 NaN
- 348 -Inf
- 349 -Inf
- 350 -Inf
- 351 NaN
- 352 NaN
- 354 NaN
- 356 -Inf
- 358 -Inf
- 359 -Inf
- 360 -Inf
- 361 -Inf
- 363 NaN
- 364 -Inf
- 365 -Inf
- 366 -Inf
- 367 NaN
- 368 -Inf
- 370 NaN
- 372 -Inf
- 373 NaN
- 374 NaN
- 376 NaN
- 379 NaN
- 380 NaN
- 382 -Inf
- 383 -Inf
- 385 -Inf
- 388 -Inf
- 389 -Inf
- 393 -Inf
- 394 NaN
- 395 -Inf
- 397 -Inf
- 399 NaN
- 401 -Inf
- 405 -Inf
- 414 -Inf
- 416 -Inf
- 419 -Inf
- 421 -Inf
- 423 -Inf
- 424 -Inf
- 425 -Inf
- 426 -Inf
- 428 -Inf
- 430 NaN
- 431 -Inf
- 432 -Inf
- 434 -Inf
- 435 -Inf
- 436 NaN
- 437 -Inf
- 438 -Inf
- 439 -Inf
- 440 NaN
- 443 -Inf
- 446 -Inf
- 451 -Inf
- 452 -Inf
- 453 -Inf
- 454 NaN
- 455 -Inf
- 456 -Inf
- 458 -Inf
- 459 -Inf
- 461 NaN
- 464 NaN
- 465 NaN
- 466 NaN
- 472 -Inf
- 474 -Inf
- 477 NaN
- 478 -Inf
- 479 -Inf
- 481 -Inf
- 482 -Inf
- 488 NaN
- 489 -Inf
- 494 NaN
- 497 -Inf
- 498 -Inf
- 499 -Inf
- 500 -Inf
- 502 -Inf
- 506 -Inf
- 507 -Inf
- 512 -Inf
- 513 -Inf
- 515 NaN
- 518 NaN
- 519 NaN
- 521 -Inf
- 525 -Inf
- 526 NaN
- 527 -Inf
- 528 NaN
- 531 -Inf
- 532 NaN
- 533 -Inf
- 534 NaN
- 535 -Inf
- 537 -Inf
- 538 NaN
- 540 -Inf
- 541 -Inf
- 542 -Inf
- 544 NaN
- 545 NaN
- 547 NaN
- 548 -Inf
- 553 -Inf
- 554 NaN
- 556 -Inf
- 557 NaN
- 560 -Inf
- 561 -Inf
- 564 -Inf
- 568 -Inf
- 572 -Inf
- 573 NaN
- 574 -Inf
- 576 -Inf
- 577 NaN
- 578 -Inf
- 580 -Inf
- 582 -Inf
- 585 -Inf
- 589 -Inf
- 590 NaN
- 591 -Inf
- 592 -Inf
- 593 -Inf
- 595 -Inf
- 596 NaN
- 597 -Inf
- 600 -Inf
- 602 NaN
- 605 -Inf
- 606 NaN
- 607 NaN
- 609 NaN
- 610 NaN
- 612 NaN
- 613 -Inf
- 614 NaN
- 615 NaN
- 616 -Inf
- 619 NaN
- 622 NaN
- 625 -Inf
- 631 NaN
- 635 -Inf
- 637 -Inf
- 638 -Inf
- 639 NaN
- 640 -Inf
- 645 -Inf
- 646 NaN
- 647 -Inf
- 648 -Inf
- 649 -Inf
- 650 -Inf
- 651 -Inf
- 654 -Inf
- 655 -Inf
- 657 -Inf
- 658 NaN
- 659 NaN
- 660 -Inf
- 662 -Inf
- 663 NaN
- 664 -Inf
- 665 NaN
- 666 -Inf
- 667 -Inf
- 668 -Inf
- 669 NaN
- 671 NaN
- 673 NaN
- 675 -Inf
- 676 -Inf
- 677 -Inf
- 679 -Inf
- 681 -Inf
- 682 -Inf
- 688 NaN
- 693 NaN
- 695 -Inf
- 697 -Inf
- 698 -Inf
- 700 -Inf
- 701 -Inf
- 702 -Inf
- 704 NaN
- 705 NaN
- 708 -Inf
- 709 -Inf
- 710 -Inf
- 715 -Inf
- 716 NaN
- 718 -Inf
- 721 -Inf
- 722 -Inf
- 723 -Inf
- 727 NaN
- 728 -Inf
- 730 NaN
- 731 -Inf
- 732 -Inf
- 734 -Inf
- 735 -Inf
- 736 -Inf
- 737 -Inf
- 739 -Inf
- 741 -Inf
- 742 -Inf
- 743 NaN
- 746 -Inf
- 748 NaN
- 750 NaN
- 752 NaN
- 753 NaN
- 754 -Inf
- 756 NaN
- 758 -Inf
- 759 -Inf
- 760 NaN
- 761 -Inf
- 762 -Inf
- 764 NaN
- 765 -Inf
- 766 NaN
- 769 -Inf
- 771 -Inf
- 772 -Inf
- 773 -Inf
- 774 -Inf
- 775 -Inf
- 776 -Inf
- 777 -Inf
- 778 NaN
- 783 -Inf
- 784 -Inf
- 785 -Inf
- 786 -Inf
- 789 NaN
- 792 NaN
- 794 -Inf
- 795 -Inf
- 796 NaN
- 797 -Inf
- 800 NaN
- 801 -Inf
- 802 NaN
- 803 -Inf
- 805 NaN
- 806 NaN
- 807 NaN
- 808 -Inf
- 811 NaN
- 812 -Inf
- 813 NaN
- 815 NaN
- 817 NaN
- 818 NaN
- 819 NaN
- 820 -Inf
- 821 -Inf
- 824 NaN
- 827 NaN
- 832 -Inf
- 836 NaN
- 843 -Inf
- 850 NaN
- 853 -Inf
- 854 NaN
- 855 -Inf
- 856 -Inf
- 858 -Inf
- 861 -Inf
- 862 NaN
- 869 NaN
- 870 NaN
- 876 -Inf
- 877 -Inf
- 878 -Inf
- 881 -Inf
- 882 NaN
- 883 -Inf
- 884 NaN
- 886 NaN
- 887 -Inf
- 888 -Inf
- 890 -Inf
- 891 NaN
- 893 -Inf
- 895 -Inf
- 897 -Inf
- 899 NaN
- 900 -Inf
- 901 NaN
- 902 NaN
- 903 NaN
- 904 -Inf
- 906 NaN
- 908 NaN
- 909 -Inf
- 910 -Inf
- 911 -Inf
- 912 NaN
- 914 -Inf
- 921 NaN
- 922 -Inf
- 923 -Inf
- 924 NaN
- 926 -Inf
- 927 -Inf
- 928 -Inf
- 929 -Inf
- 930 -Inf
- 932 -Inf
- 933 -Inf
- 935 NaN
- 936 NaN
- 940 -Inf
- 942 NaN
- 944 -Inf
- 946 NaN
- 948 -Inf
- 952 NaN
- 954 NaN
- 957 -Inf
- 959 NaN
- 960 -Inf
- 962 NaN
- 963 -Inf
- 964 -Inf
- 965 NaN
- 967 -Inf
- 972 NaN
- 974 NaN
- 975 NaN
- 979 NaN
- 981 NaN
- 984 -Inf
- 986 -Inf
- 990 NaN
- 991 -Inf
- 993 NaN
- 994 -Inf
- 996 -Inf
- 999 NaN
- 1000 -Inf
- 1002 NaN
- 1003 -Inf
- 1005 -Inf
- 1007 -Inf
- 1008 -Inf
- 1009 NaN
- 1010 NaN
- 1013 -Inf
- 1014 -Inf
- 1015 -Inf
- 1016 -Inf
- 1020 -Inf
- 1021 NaN
- 1022 NaN
- 1025 -Inf
- 1029 -Inf
- 1030 NaN
- 1031 NaN
- 1033 -Inf
- 1034 -Inf
- 1035 -Inf
- 1036 -Inf
- 1038 -Inf
- 1040 -Inf
- 1043 -Inf
- 1048 -Inf
- 1051 -Inf
- 1052 -Inf
- 1054 -Inf
- 1055 NaN
- 1056 -Inf
- 1060 NaN
- 1061 NaN
- 1063 -Inf
- 1065 -Inf
- 1066 -Inf
- 1068 NaN
- 1070 NaN
- 1071 -Inf
- 1072 -Inf
- 1073 -Inf
- 1075 -Inf
- 1077 NaN
- 1081 -Inf
- 1083 -Inf
- 1084 NaN
- [ reached 'max' / getOption("max.print") -- omitted 257 rows ]
- Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
- CALCULATION ISSUE - Log-likelihood calculation fails at values close to the starting values!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement