Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

Structure of choice-data

Ask questions about data format and processing of data, including the use of pre-estimation functions in Apollo. If your question relates to a specific error you are getting, please provide some of the output.
Post Reply
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Structure of choice-data

Post by JuliavB »

Dear all,

unfortunately, my choice data (incl. design) so far is organized like this, representing one choice (so I have it in three rows instead of one row per choice set as described in the apollo manual):
Resp_ID, Task, Alternative1, Attr1, Attr2, Attr3, Choice made (0 or 1)
Resp_ID, Task, Alternative2, Attr1, Attr2, Attr3, Choice made (0 or 1)
Resp_ID, Task, Alternative3, Attr1, Attr2, Attr3, Choice made (0 or 1)

Is there a way that apollo can also read and use the data in this format or even a script that reshapes the data to the required form?
Any help is highly appreciated, as my request is quite urgent.

Thank you very much in advance.
Best,
J.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Structure of choice-data

Post by stephanehess »

Hi

this is in long format rather than wide format. You'll have to reshape the data. We don't have a function for doing this automatically as it very much depends on the data you have. However, we could produce such a function for future versions. If you want to encourage that development, then you could share your data with me offline and I'll see what I can do for you

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: Structure of choice-data

Post by JuliavB »

Hi Stephane,

thank you for your reply.
I just managed to reshape my data with the tidyr package and pivot_wider function which worked out pretty well. Maybe that is also interesting for other users ;)

Best,
J.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Structure of choice-data

Post by stephanehess »

Great

feel free to post your code (or part of it) here to inspire others

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: Structure of choice-data

Post by JuliavB »

Please find below the part of my code which I´ve used to reshape my data from long to wide format:

library(tidyr)
Daten_Choice_Pivot <- pivot_wider(Daten_Choice_Design[,-7], names_from = Concept,
values_from = c("Attr1", "Attr2", "Attr3"))

Daten_Choice_Design <- Daten_Choice_Design[which(Daten_Choice_Design$Response==1),]
Daten_Choice_Pivot$Choice <- Daten_Choice_Design$Concept
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: Structure of choice-data

Post by stephanehess »

Thanks. I've written a function that will be included in Apollo 0.2.8 that allows the user to reshape the data very easily from long to wide format (though not using tidyr)
--------------------------------
Stephane Hess
www.stephanehess.me.uk
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: Structure of choice-data

Post by JuliavB »

That sounds great, thank you very much!
Post Reply