Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to reshape data for analysis (Discrete choice experiment)

    Hi there,
    hello to the community.
    I'd need some help with how to prepare/shape data for analysis from a binary discrete choice experiment.
    What I have is a binary choice between two generic options A vs B that represent two different configurations of the same service. Both A and B are defined over 14 variables: 13 variables are dummy, 1 variable has 8 levels (i.e., 3,6,9,12,15,18,21,24 dollars). The price levels represent the price of a service, the dummies represent features of the service (0 not available, 1 available). The design I used is a blocked fractional factorial, I have 8 blocks of 8 choice sets each (so 64 in total). Each respondent is randomly assigned to one block, so I have 8 responses from each individual in my dataset. Logit is how I plan to analyse data for now, and I'd use the cluster option to take into account respondent repetitions.
    QUESTION: What is not clear to me is how the data should be structured. If you can help me or point me to some example/article it would be much appreciated.
    Carlo

  • #2
    Hi Carlo, and welcome to Statalist!

    It will be a *lot* easier to help if you can post a small snippet of your data using Stata's dataex command (SSC install dataex). If you need help with that, I created a YouTube video to help walk people through the process.

    See Statalist - Using CODE delimiters and Stata's dataex command (I would watch at speed 1.5x or 2x ).
    Part on using code delimiters on Statalist (1:30 to 3:00)
    Part on using -dataex- (3:00 to 5:30, I keep going on, but you can stop there).

    As far as reshaping data from wide to long, a couple of good video tutorials are here and here.

    Comment


    • #3
      Hi David,
      thanks for the dataex tip. I realized I probably didn't give enough details as I'm dealing with a bit of a mess here: the binary fractional blocked design has been created in SAS and, once imported in Stata, it looks like this:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double(block set alt status_update notes comments wall_posts private_messages chats groups newsfeed like photos_videos events gaming fan_pages price)
      1 1 1 2 1 2 1 1 1 1 1 2 2 1 1 1 4
      1 1 2 1 2 1 2 1 2 2 1 2 1 1 2 2 5
      1 2 1 2 1 1 2 2 2 2 2 1 2 2 1 1 7
      1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1
      1 3 1 1 1 2 2 1 1 2 2 1 1 2 2 1 1
      1 3 2 1 2 1 2 2 1 1 2 2 2 1 1 1 6
      1 4 1 1 1 2 2 2 2 1 1 1 2 2 1 2 2
      1 4 2 2 2 2 2 1 2 1 2 2 1 1 2 1 4
      1 5 1 2 1 1 2 1 2 1 2 1 1 1 1 2 6
      1 5 2 2 2 1 1 2 1 2 1 1 1 2 2 1 7
      1 6 1 2 2 1 1 2 1 1 2 2 2 2 2 2 3
      1 6 2 1 1 2 2 2 2 1 1 1 2 2 1 2 2
      1 7 1 1 2 1 2 2 1 2 1 1 1 1 1 2 2
      1 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
      1 8 1 1 2 1 2 1 2 2 1 2 1 1 2 2 5
      1 8 2 1 1 1 1 2 1 1 2 2 1 2 1 1 8
      2 1 1 2 1 2 1 1 2 2 1 1 1 2 2 2 6
      2 1 2 1 2 1 2 2 1 2 1 1 1 1 1 2 2
      2 2 1 2 2 2 2 1 1 2 2 1 2 2 1 2 6
      2 2 2 2 1 2 1 2 2 1 1 1 2 1 2 1 7
      2 3 1 2 2 1 1 2 2 1 1 2 2 1 1 2 1
      2 3 2 1 1 1 1 1 2 1 2 1 1 2 2 1 3
      2 4 1 1 1 2 2 2 1 1 2 1 2 1 2 2 4
      2 4 2 1 2 2 1 1 2 2 1 1 2 2 1 1 1
      2 5 1 2 2 2 2 1 1 1 1 2 1 2 1 1 2
      2 5 2 1 1 1 1 1 1 2 2 2 2 1 1 2 5
      2 6 1 2 1 1 2 2 2 1 1 2 1 2 1 2 3
      2 6 2 1 2 2 1 2 2 2 2 2 2 1 1 1 8
      2 7 1 1 1 1 1 1 1 2 2 2 2 1 1 2 5
      2 7 2 1 2 1 2 2 2 1 1 2 2 2 2 1 8
      2 8 1 2 1 2 1 2 2 1 1 1 2 1 2 1 7
      2 8 2 2 1 1 2 1 1 2 2 2 2 2 2 1 4
      3 1 1 1 2 1 2 1 1 2 2 2 1 2 1 2 7
      3 1 2 2 2 2 2 2 2 1 1 1 1 2 2 1 5
      3 2 1 1 1 2 2 2 1 2 1 2 1 1 2 1 8
      3 2 2 2 2 1 1 2 1 1 2 2 2 2 2 2 3
      3 3 1 2 2 1 1 1 1 1 1 1 2 1 2 2 6
      3 3 2 1 1 2 2 1 2 2 1 1 1 1 1 1 3
      3 4 1 1 1 2 2 2 1 1 2 1 2 1 2 2 4
      3 4 2 1 2 1 2 1 1 2 2 2 1 2 1 2 7
      3 5 1 2 1 2 1 2 1 1 2 1 2 2 1 1 5
      3 5 2 2 2 2 2 1 2 2 1 1 2 1 2 2 8
      3 6 1 2 1 2 1 1 1 1 1 2 2 1 1 1 4
      3 6 2 1 1 1 1 2 2 2 2 1 2 1 2 2 2
      3 7 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1
      3 7 2 1 1 1 1 2 2 1 1 2 1 1 2 1 6
      3 8 1 2 1 1 2 2 2 1 1 2 1 2 1 2 3
      3 8 2 1 2 2 1 1 2 2 1 1 2 2 1 1 1
      4 1 1 1 2 2 1 1 1 1 1 2 1 1 2 2 7
      4 1 2 2 2 1 1 2 2 2 2 1 1 1 1 1 5
      4 2 1 2 1 2 1 1 2 1 2 2 2 2 2 1 2
      4 2 2 2 2 2 2 2 1 2 1 2 2 1 1 2 3
      4 3 1 2 1 2 1 1 2 2 1 1 1 2 2 2 6
      4 3 2 1 1 1 1 2 1 1 2 2 1 2 1 1 8
      4 4 1 1 2 1 2 1 2 1 2 1 2 1 2 1 1
      4 4 2 2 1 2 1 1 1 2 2 1 1 1 1 2 8
      4 5 1 2 1 1 2 2 1 2 1 1 2 1 2 1 5
      4 5 2 1 2 2 1 2 1 1 2 1 1 2 2 2 2
      4 6 1 1 1 2 2 2 2 2 2 2 1 2 1 1 6
      4 6 2 2 2 2 2 1 2 2 1 1 2 1 2 2 8
      4 7 1 1 1 1 1 2 1 2 1 1 2 2 1 2 4
      4 7 2 1 2 1 2 1 2 1 2 1 2 1 2 1 1
      4 8 1 1 1 2 2 2 1 2 1 2 1 1 2 1 8
      4 8 2 2 2 1 1 1 2 2 1 2 1 2 1 1 4
      5 1 1 1 2 2 1 1 2 1 2 2 1 2 1 2 5
      5 1 2 2 1 1 2 2 2 2 2 1 2 2 1 1 7
      5 2 1 2 2 1 1 2 1 2 1 1 1 2 2 1 7
      5 2 2 1 1 2 2 2 2 1 1 1 2 2 1 2 2
      5 3 1 2 1 1 2 1 2 2 1 2 2 1 1 1 2
      5 3 2 1 2 1 2 2 2 2 2 1 1 2 2 2 4
      5 4 1 2 2 2 2 1 1 2 2 1 2 2 1 2 6
      5 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1
      5 5 1 1 2 2 1 2 2 1 1 1 1 1 1 2 4
      5 5 2 2 1 1 2 1 1 1 1 1 1 2 2 2 8
      5 6 1 1 2 2 1 2 2 1 1 1 1 1 1 2 4
      5 6 2 2 1 2 1 1 2 1 2 2 2 2 2 1 2
      5 7 1 2 1 1 2 2 1 1 2 2 1 1 2 2 1
      5 7 2 1 2 2 1 1 1 2 2 1 2 1 2 1 3
      5 8 1 1 1 1 1 1 2 2 1 2 2 2 2 2 7
      5 8 2 2 2 1 1 2 2 2 2 1 1 1 1 1 5
      6 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1
      6 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 8
      6 2 1 1 2 2 1 1 2 1 2 2 1 2 1 2 5
      6 2 2 2 1 1 2 1 2 2 1 2 2 1 1 1 2
      6 3 1 2 1 2 1 2 1 1 2 1 2 2 1 1 5
      6 3 2 1 2 1 2 2 2 2 2 1 1 2 2 2 4
      6 4 1 1 1 2 2 1 1 1 1 2 2 2 2 2 5
      6 4 2 2 1 2 1 2 2 2 2 2 1 1 2 2 3
      6 5 1 1 1 1 1 2 2 1 1 2 1 1 2 1 6
      6 5 2 2 1 2 1 1 1 2 2 1 1 1 1 2 8
      6 6 1 2 2 1 1 1 2 2 1 2 1 2 1 1 4
      6 6 2 1 2 2 1 1 1 2 2 1 2 1 2 1 3
      6 7 1 1 1 1 1 2 2 2 2 1 2 1 2 2 2
      6 7 2 2 2 2 2 2 1 1 2 1 1 1 1 1 7
      6 8 1 2 2 2 2 2 1 1 2 1 1 1 1 1 7
      6 8 2 1 2 1 2 2 2 1 1 2 2 2 2 1 8
      7 1 1 2 2 1 1 1 1 1 1 1 2 1 2 2 6
      7 1 2 1 2 2 1 2 2 2 2 2 2 1 1 1 8
      7 2 1 1 1 2 2 1 2 1 2 2 2 1 1 2 7
      7 2 2 1 2 2 1 2 1 2 1 2 2 2 2 1 6
      end
      label values notes notes
      label def notes 1 "1", modify
      label def notes 2 "0", modify
      label values comments comments
      label def comments 1 "1", modify
      label def comments 2 "0", modify
      label values chats chats
      label def chats 1 "1", modify
      label def chats 2 "0", modify
      label values groups groups
      label def groups 1 "1", modify
      label def groups 2 "0", modify
      label values newsfeed newsfeed
      label def newsfeed 1 "1", modify
      label def newsfeed 2 "0", modify
      label values like like
      label def like 1 "1", modify
      label def like 2 "0", modify
      label values events events
      label def events 1 "1", modify
      label def events 2 "0", modify
      label values gaming gaming
      label def gaming 1 "1", modify
      label def gaming 2 "0", modify
      label values price price
      label def price 1 "$3", modify
      label def price 2 "$6", modify
      label def price 3 "$9", modify
      label def price 4 "$12", modify
      label def price 5 "$15", modify
      label def price 6 "$18", modify
      label def price 7 "$21", modify
      label def price 8 "$24", modify
      on the other hand, the experiment data come from Qualtrics in this form (I just put the first 2 blocks and N=60):

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str244 ID double(Block1Set1 Block1Set2 Block1Set3 Block1Set4 Block1Set5 Block1Set6 Block1Set7 Block1Set8 Block2Set1 Block2Set2 Block2Set3 Block2Set4 Block2Set5 Block2Set6 Block2Set7 Block2Set8)
      "ARLGZWN6W91WD"        . . . . . . . . . . . . . . . .
      "A2541C8MY0BYV3"       . . . . . . . . . . . . . . . .
      "A358YR7MWC6LRH"       . . . . . . . . . . . . . . . .
      "ANPCXN619ACW9"        2 2 1 1 2 1 1 2 . . . . . . . .
      "A2S96ZZ70YFPSK"       . . . . . . . . 2 2 2 2 1 1 1 1
      "A1FKDB1SJ3YL7A"       . . . . . . . . . . . . . . . .
      "A1DJDT4B5B19Q2"       . . . . . . . . . . . . . . . .
      "A2W3A42TRMJ861"       . . . . . . . . . . . . . . . .
      "A1ZD9SJXQ9C6EW"       . . . . . . . . . . . . . . . .
      "A3GZYWA9S6J0K9"       . . . . . . . . 2 2 1 1 1 1 2 1
      "A3HNEYFOIJWPH1"       . . . . . . . . . . . . . . . .
      "AQV468FB908WI"        . . . . . . . . 2 2 2 2 1 2 1 1
      "A3BJTC39BU7R4V"       . . . . . . . . . . . . . . . .
      "A3G5IPGLH1IIZN"       . . . . . . . . . . . . . . . .
      "A230VUDYOCRZ4N"       . . . . . . . . . . . . . . . .
      "A1I9ZBV75AVWUS"       . . . . . . . . . . . . . . . .
      "A39YBLQYIUBR76"       . . . . . . . . . . . . . . . .
      "A3GQRD3530XFM3"       . . . . . . . . . . . . . . . .
      "A3MS21UJPMHLK0"       . . . . . . . . . . . . . . . .
      "A2MQ6VUSKCQ9FH"       . . . . . . . . . . . . . . . .
      "A1HQL1FCG3DL81"       . . . . . . . . 2 1 2 2 1 1 1 2
      "A150GMV1YQWWB3"       . . . . . . . . . . . . . . . .
      "A1STU8IA7S3WOK"       . . . . . . . . . . . . . . . .
      "A157QHCC2VO7YA"       . . . . . . . . . . . . . . . .
      "A3DTBL9NV7SDQC"       . . . . . . . . . . . . . . . .
      "A2A07J1P6YEW6Z"       . . . . . . . . . . . . . . . .
      "A1QX1RYLCFXZJ9"       . . . . . . . . . . . . . . . .
      "A2HR7ZIX42FEPG"       . . . . . . . . . . . . . . . .
      "A3UJO2A7THUZTV"       . . . . . . . . . . . . . . . .
      "AA7LA8WQNABDT"        . . . . . . . . . . . . . . . .
      "AOAZMLP27GD81"        . . . . . . . . . . . . . . . .
      "AVOF14300525D"        1 2 1 1 2 1 1 2 . . . . . . . .
      "A2SYRFPPV9WDEG"       . . . . . . . . . . . . . . . .
      "A2MJAXJEJ4SEQM"       . . . . . . . . . . . . . . . .
      "A3IHLWMZNBLUR4"       . . . . . . . . 2 2 2 1 1 1 2 1
      " COPIEDAJ74BNWTCX0MJ" . . . . . . . . . . . . . . . .
      "A3LMI7ZDFO8JHR"       . . . . . . . . . . . . . . . .
      "A3U21PUMQ6NGT2"       . . . . . . . . . . . . . . . .
      "A2UO3QJZNC2VOE"       1 2 1 1 1 2 2 1 . . . . . . . .
      "A1PJLZSOUQ4MIL"       . . . . . . . . . . . . . . . .
      "A2NJ7N8INZOB00"       1 2 1 1 1 2 2 1 . . . . . . . .
      "A29VL3MZE7YPBZ"       1 2 1 1 1 2 1 1 . . . . . . . .
      "A100VV1V2XDQI7"       . . . . . . . . . . . . . . . .
      "AELOYBHVZFDW9"        2 2 1 1 2 2 1 1 . . . . . . . .
      "ACCXC5V05C9R9"        . . . . . . . . . . . . . . . .
      "A3E8SXH0BAYG85"       . . . . . . . . 1 1 2 2 1 1 1 2
      "A2OJMQGSQBEKEQ"       . . . . . . . . . . . . . . . .
      "A2LCFORIW0NF1S"       . . . . . . . . . . . . . . . .
      "AA21VG9GOHM54"        1 2 1 1 1 2 1 1 . . . . . . . .
      "A248P03SBIGVNH"       . . . . . . . . . . . . . . . .
      "A1Q2C5GJTB09WW"       . . . . . . . . 2 1 2 1 1 1 1 2
      "A1RYC2OETJVEG7"       . . . . . . . . . . . . . . . .
      "ATKG4FI2S5MVL"        1 2 1 1 2 2 1 1 . . . . . . . .
      "A1L0G5ZGQPEF5I"       . . . . . . . . . . . . . . . .
      "A3RQN5RZD1N2KP"       . . . . . . . . . . . . . . . .
      "A1LXW53Z5S9XG"        . . . . . . . . . . . . . . . .
      "APR6H3HAOE9OU"        . . . . . . . . . . . . . . . .
      "A2WTNZHRALOHX8"       . . . . . . . . . . . . . . . .
      "A2KG59JUICJLP0"       . . . . . . . . . . . . . . . .
      "A194E79BDFEZIU"       1 2 1 1 2 2 1 1 . . . . . . . .
      end
      label values Block1Set1 Block1Set1
      label def Block1Set1 1 "A", modify
      label def Block1Set1 2 "B", modify
      label values Block1Set2 Block1Set2
      label def Block1Set2 2 "B", modify
      label values Block1Set3 Block1Set3
      label def Block1Set3 1 "A", modify
      label values Block1Set4 Block1Set4
      label def Block1Set4 1 "A", modify
      label values Block1Set5 Block1Set5
      label def Block1Set5 1 "A", modify
      label def Block1Set5 2 "B", modify
      label values Block1Set6 Block1Set6
      label def Block1Set6 1 "A", modify
      label def Block1Set6 2 "B", modify
      label values Block1Set7 Block1Set7
      label def Block1Set7 1 "A", modify
      label def Block1Set7 2 "B", modify
      label values Block1Set8 Block1Set8
      label def Block1Set8 1 "A", modify
      label def Block1Set8 2 "B", modify
      label values Block2Set1 Block2Set1
      label def Block2Set1 1 "A", modify
      label def Block2Set1 2 "B", modify
      label values Block2Set2 Block2Set2
      label def Block2Set2 1 "A", modify
      label def Block2Set2 2 "B", modify
      label values Block2Set3 Block2Set3
      label def Block2Set3 1 "A", modify
      label def Block2Set3 2 "B", modify
      label values Block2Set4 Block2Set4
      label def Block2Set4 1 "A", modify
      label def Block2Set4 2 "B", modify
      label values Block2Set5 Block2Set5
      label def Block2Set5 1 "A", modify
      label values Block2Set6 Block2Set6
      label def Block2Set6 1 "A", modify
      label def Block2Set6 2 "B", modify
      label values Block2Set7 Block2Set7
      label def Block2Set7 1 "A", modify
      label def Block2Set7 2 "B", modify
      label values Block2Set8 Block2Set8
      label def Block2Set8 1 "A", modify
      label def Block2Set8 2 "B", modify
      So, I need to merge design and data together and this sounds very time consuming as I don't use stata very often, so before start merging I'd like to know how my output should look like in order to be analysed.
      My understanding is that I should create 16 rows for each respondent keeping the data structure of the choice design and adding to it two variables, the ID and the chosen_option.
      Thanks for any cue on how to structure the data and, more in general, for a smart direction to take with data manipulation.

      Attached Files

      Comment


      • #4
        Facing same problem now. Hope you did it anyway. How did you do it?

        Comment

        Working...
        X