Page 1 of 1

error: "apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Not proceeding with estimation!"

Posted: 04 Aug 2020, 13:20
by irinikalk
Hi,
when using the Apollo package to estimate a binary choice model I get the error: "apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Not proceeding with estimation!" I have checked my code and looked into a few forums to try and find where my mistake is but I can't seem to find it. I posted the code below hoping that someone can help me. Thank you in advance!!

-Irini

rm(list=ls())
install.packages("apollo")
library(apollo)
database <- read.csv2("Dutch_daten.csv")
str(database)
database$cost <- as.numeric(as.character(database$cost))
database$ivtt <- as.numeric(as.character(database$ivtt))
database$rpovt <- as.numeric(as.character(database$rpovt))

### Initialise code
apollo_initialise()

### Set core controls
apollo_control= list(
modelName="ApolloNetherlands_Exc",
modelDescr="BinaryChoiceModel",
indivID = "idx.alt"
)

### Define model parameters for specification 0

apollo_beta <- c(b0_rail =0,
b1_cost = 0,
b2_time = 0)
apollo_fixed = c()

### GROUP AND VALIDATE INPUTS
apollo_inputs = apollo_validateInputs()

### DEFINE MODEL AND 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()


V <- list()

V[['rail']] <- b0_rail + b1_cost*cost+ b2_time*(ivtt+rpovt)
V[['car']] <- b1_cost*cost+ b2_time*(ivtt+rpovt)

mnl_settings = list(
alternatives = c(car=1, rail=2),
avail = list(car=1, rail=1),
choiceVar = idx.alt,
V = V
)

P[["model"]]=apollo_mnl(mnl_settings, functionality)


P = apollo_panelProd(P, apollo_inputs, functionality)

P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}

# ################################################################# #
#### MODEL ESTIMATION ####
# ################################################################# #

model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)

Re: error: "apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Not proceeding with estimation!"

Posted: 04 Aug 2020, 13:28
by stephanehess
Hi

is this the only error you receive. Normally, Apollo will provide you with more detail of why the estimation fails. Just scroll up in the output.

But it seems quite clear that your model cannot be estimated as you have two alternatives and include the same attribute with the same parameter in both alternatives. So neither b1_cost nor b2_time will have an impact on the choice probabilities as only differences in utility matter.

Best wishes

Stephane

Re: error: "apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Not proceeding with estimation!"

Posted: 11 Aug 2020, 18:45
by irinikalk
Hi Stephane,

I changed my utility functions to:

V[['rail']] <- b0_rail + b1_cost*cost_rail + b2_time*(ivtt_rail +rpovt_rail)
V[['car']] <- b1_cost*cost_car + b2_time*(ivtt_car + rpovt_car)

But I get the same problem. What am I doing wrong now? I simply can't find my mistake.
I am sorry for asking again but I am very new to Apollo.

Kind regards
Irini

Re: error: "apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Not proceeding with estimation!"

Posted: 11 Aug 2020, 19:01
by stephanehess
Can you please post the entire output as there is likely an earlier error message

Re: error: "apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Not proceeding with estimation!"

Posted: 12 Aug 2020, 11:59
by irinikalk
> rm(list=ls())
> library(apollo)
>
> netherlands <- read.delim("netherlands.dat")
> netherlands$mode <- as.factor(netherlands$choice)
> levels(netherlands$mode) <- c("car", "rail", "car", "rail")
> netherlands$idx.alt <- as.numeric(netherlands$mode)
> levels(netherlands$idx.alt) <- c(car=1, rail=2)
>
> database <- na.omit(netherlands)
>
> rm(netherlands)
>
>
> ### Initialise code
> apollo_initialise()
Apollo ignition sequence completed
>
> ### Set core controls
> apollo_control= list(
+ modelName="ApolloNetherlands_Exc",
+ modelDescr="BinaryChoiceModel",
+ indivID = "idx.alt"
+ )
>
> ### Define model parameters for specification 0
>
> apollo_beta <- c(b0_rail =0,
+ b1_cost = 0,
+ b2_time = 0)
> apollo_fixed = c()
>
> ### GROUP AND VALIDATE INPUTS
> apollo_inputs = apollo_validateInputs()
Missing setting for mixing, set to default of FALSE
Missing setting for nCores, set to default of 1
Missing setting for workInLogs, set to default of FALSE
Missing setting for seed, set to default of 13
Missing setting for HB, set to default of FALSE
Several observations per individual detected based on the value of idx.alt.
Setting panelData set to TRUE.
All checks on apollo_control completed.
All checks on data completed.
>
> ### DEFINE MODEL AND 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()
+
+
+ V <- list()
+
+ V[['rail']] <- b0_rail + b1_cost*cost_rail + b2_time*(ivtt_rail+rpovt_rail)
+ V[['car']] <- b1_cost*cost_car + b2_time*(ivtt_car+rpovt_car)
+
+ mnl_settings = list(
+ alternatives = c(rail=1, car=2),
+ avail = list(rail=1, car=1),
+ choiceVar = idx.alt,
+ V = V
+ )
+
+ P[["model"]]=apollo_mnl(mnl_settings, functionality)
+
+
+ P = apollo_panelProd(P, apollo_inputs, functionality)
+
+ P = apollo_prepareProb(P, apollo_inputs, functionality)
+ return(P)
+ }
>
> # ################################################################# #
> #### MODEL ESTIMATION ####
> # ################################################################# #
>
> model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
Validating inputs of likelihood function (apollo_probabilities)

Overview of choices for model component "MNL"
rail car
Times available 1739.00 1739.00
Times chosen 1251.00 488.00
Percentage chosen overall 71.94 28.06
Percentage chosen when available 71.94 28.06

Testing likelihood function
Log-likelihood calculation fails at starting values!
Affected individuals:
ID LL
1 -Inf
Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
Not proceeding with estimation

Re: error: "apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, : Not proceeding with estimation!"

Posted: 12 Aug 2020, 20:39
by stephanehess
Hi

Apollo shows you that there is a problem at the starting values for the first person. Is there something different about that person, maybe something odd in the data? Or do you maybe have a very large number of observations for that person in which case you might need to use the workInLogs option (see the manual)

Log-likelihood calculation fails at starting values!
Affected individuals:
ID LL
1 -Inf