I ran into the following error when I was running code that modelled that of the Apollo_example_3.r
"Error in apollo_validateData(database, apollo_control, silent = silent) :
All rows for the same individual should be next to each other in the data!"
I reviewed my dataset to make sure that it was in the right format (My dataset can be viewed from the Open Science Framework: https://osf.io/jfz5h and I've attached an image below as well, just in case there is an error on my part in creating the dataset)
I decided to run through the exact example as written in "Apollo_example_3.r" (http://www.apollochoicemodelling.com/fi ... xample_3.r) using the provided dataset "apollo_modeChoiceData.csv"
Description: MNL model with socio-demographics on mode choice SP data
Code: Select all
# ################################################################# #
#### LOAD LIBRARY AND DEFINE CORE SETTINGS ####
# ################################################################# #
### Clear memory
rm(list = ls())
### Load Apollo library
library(apollo)
### Initialise code
apollo_initialise()
### Set core controls
apollo_control = list(
modelName ="Apollo_example_3",
modelDescr ="MNL model with socio-demographics on mode choice SP data",
indivID ="ID"
)
# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #
database <- read.csv("C:/Users/My-Linh/Dropbox/University of Melbourne/Research Toolbox/R vignettes/Apollo choice models/apollo_modeChoiceData.csv")
### Use only SP data
database = subset(database,database$SP==1)
### Create new variable with average income
database$mean_income = mean(database$income)
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta=c(asc_car = 0,
asc_bus = 0,
asc_air = 0,
asc_rail = 0,
asc_bus_shift_female = 0,
asc_air_shift_female = 0,
asc_rail_shift_female = 0,
b_tt_car = 0,
b_tt_bus = 0,
b_tt_air = 0,
b_tt_rail = 0,
b_tt_shift_business = 0,
b_access = 0,
b_cost = 0,
b_cost_shift_business = 0,
cost_income_elast = 0,
b_no_frills = 0,
b_wifi = 0,
b_food = 0)
### Vector with names (in quotes) of parameters to be kept fixed at their starting value in apollo_beta, use apollo_beta_fixed = c() if none
apollo_fixed = c("asc_car","b_no_frills")
# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #
apollo_inputs = apollo_validateInputs()
And ran into the same output error
"Several observations per individual detected based on the value of ID. Setting panelData in apollo_control set
to TRUE.
All checks on apollo_control completed.
Error in apollo_validateData(database, apollo_control, silent = silent) :
All rows for the same individual should be next to each other in the data!"
Any idea what might be going on? Thanks in advance for your help!