Data Pivot Longer for Discrete Choice Data

Hi everyone!
I have to work with some Discrete Choice Datasets (theory behind this concept for anyone interested) and therefore am trying to familiarize and understand ways to analyze them.

Basically, I want to pivot data from wide format

To long format

I've done this with R but I wanted to know if there's a way to do the same with EasyMorph.

Please share with me the workflows that can enable me to do so using EasyMorph alone.

Here is the original dataset: Dataset

Here's the paper discussing the dataset and below is the dataset description

Many thanks!

Do you know always know how many choices there? There seems to be 5 in your example dataset. Will it always be 5?

Well, DCE do vary in terms of the profiles(choices) available per option.
But say for simplicity, they do have only 5 choices.

After thinking about it, it doesn't matter how many choices there are. :grinning:

I had to add a column name to the first column in your CSV to make it valid Car.csv (64.2 KB)

And here is a morph which I think does what you wanted. In simple terms, it unpivots the data, splits the column label into the text and number parts, then repivots the data using just the text part of the column name. All of the other actions are just adding back in the columns that weren't needed as part of the pivot and formatting it as your example output.

DCD.morph (6.2 KB)

I've left in an extra column "column_num" which indicates the order the values appeared in the relevant column groups.

There were a couple of columns in your example output that didn't appear in your raw data example.

1 Like

Works like a charm!
Many thanks

1 Like