Long to wide
Posted: 25 Nov 2024, 10:03
Dear Stephane
I have the following error when running to Long to wide function:
"Erreur dans apollo_longToWide(databaseLong2, longToWide_settings = settings) : INPUT ISSUE - A single alternative needs to be chosen in each separate choice scenario!"
I have checked in the database that:
(1) "Quchoice" takes the values 1,2,3 for each individual ("idLS") and choice ("Choicenumber")
(2) there is one and only one 1 in "Choice_long" (2x 0 and 1x1).
Find below my code and by email my csv database.
Thanks for your help.
Marianne
### Clear memory
rm(list = ls())
### Load Apollo library
library(apollo)
### Initialise code
apollo_initialise()
### set working directory
setwd("C:/Users/marianne.lefebvre/Nextcloud/RECHERCHE/BEHAVE/BEHAVEPartagePauline/EAU/DCE_Eau/Data_analysis/Stata")
### Set core controls
apollo_control = list(
modelName = "MMNL_DCEEau_WTPspace",
modelDescr = "MMNL on Behave water DCE data in WTP space",
indivID = "idLS",
nCores = 3,
outputDirectory = "output"
)
# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #
### Loading data from package
databaseLong2 = read.csv("Final_Result_Long.csv",header=TRUE)
settings<-list(
alternative_column="Quchoice",
alternative_specific_attributes=c("DeclaFarm","DeclaPlotSoil","DeclaAuto","ManualWeekly","Smart","Vol"),
choice_column="Choice_long",
ID_column="idLS",
observation_column="Choicenumber"
)
database = apollo_longToWide(databaseLong2,longToWide_settings=settings)
I have the following error when running to Long to wide function:
"Erreur dans apollo_longToWide(databaseLong2, longToWide_settings = settings) : INPUT ISSUE - A single alternative needs to be chosen in each separate choice scenario!"
I have checked in the database that:
(1) "Quchoice" takes the values 1,2,3 for each individual ("idLS") and choice ("Choicenumber")
(2) there is one and only one 1 in "Choice_long" (2x 0 and 1x1).
Find below my code and by email my csv database.
Thanks for your help.
Marianne
### Clear memory
rm(list = ls())
### Load Apollo library
library(apollo)
### Initialise code
apollo_initialise()
### set working directory
setwd("C:/Users/marianne.lefebvre/Nextcloud/RECHERCHE/BEHAVE/BEHAVEPartagePauline/EAU/DCE_Eau/Data_analysis/Stata")
### Set core controls
apollo_control = list(
modelName = "MMNL_DCEEau_WTPspace",
modelDescr = "MMNL on Behave water DCE data in WTP space",
indivID = "idLS",
nCores = 3,
outputDirectory = "output"
)
# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #
### Loading data from package
databaseLong2 = read.csv("Final_Result_Long.csv",header=TRUE)
settings<-list(
alternative_column="Quchoice",
alternative_specific_attributes=c("DeclaFarm","DeclaPlotSoil","DeclaAuto","ManualWeekly","Smart","Vol"),
choice_column="Choice_long",
ID_column="idLS",
observation_column="Choicenumber"
)
database = apollo_longToWide(databaseLong2,longToWide_settings=settings)