Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Double randomization of the list

Hello, everyone!

I have the question B2 (select, checkbox). There are 8 alternatives:

1. Alternative 1
2. Alternative 2
3. Alternative 3
4. Alternative 4
5. Alternative 5
6. Alternative 6
7. Respondent specify
8. Exclusive

The alternatives should be groupped in 3 virtual blocks:

-block 1 (alternatives 1-3)
-block 2 (alternatives 4-6)
-block 3 (alternatives 7-8)

Randomization is to be carried out as follows.

Block 3 should be always at the bottom as is. Blocks 1,2 must be randomized, moreover alternatives within blocks 1,2 should be randomized as well.

Thank you in advance!
asked Feb 27 by Vasyl Bronze (725 points)
edited Feb 27 by Vasyl

1 Answer

+2 votes
Vasyl, this should get you sorted.

First, create your parent list as follows (call it B2List) ...

1. Alternative 1
2. Alternative 2
3. Alternative 3
4. Alternative 4
5. Alternative 5
6. Alternative 6
7. Respondent specify
8. Exclusive

Note: Each of the below constructed lists will use the parent list - B2List.

Now create this constructed list to randomise items 1-3 (call it B21ConList) ...
ADD(B2List,1,3)
Randomize()

Now create this constructed list to randomise items 4-6 (call it B22ConList) ...
ADD(B2List,4,6)
Randomize()

And finally, create this constructed list to bring all items together (call it B2TConList) ...
Begin Unverified Perl

 my $BlockSelector1=SYSRAND(1,2);
 my $BlockSelector2=0;

 if ($BlockSelector1==1)
  {
   $BlockSelector2=2;
  }
 else
  {
   $BlockSelector2=1;
  }
 
 ADD("B2".$BlockSelector1."ConList");
 ADD("B2".$BlockSelector2."ConList");
 ADD("B2List",7,8);
 
End Unverified

Be careful to name your constructed lists as I suggested. Feel free to change the names but you will need to modify the script in B2TConList.

Let me know how you go. Good luck mate.
answered Feb 27 by Paul Moon Platinum (76,175 points)
Dear Paul,

So many thanks, for your prompt and detailed reply. I will definitely try your approach.

Sincerely,
Vasil
Paul, that's a very good approach.

I am dealing with a quite similar problem, but I have 4 blocks that have to randomize and I don't get it sorted out how to extend the "$Blockselector" section in your script so that I get all my 4 blocks together. Can you help?

Thanks,
Guido
Dear Guido, maybe this will help you.

For example, you have a question Q1 with 8 alternatives, which should be randomized as 4 blocks:

Q1List

1.alt 1
2.alt 2
3.alt 3
4.alt 4
5.alt 5
6.alt 6
7.alt 7
8.alt 8

You can create 4 constructed lists:

Q1CL1
ADD(ParentListName(),1,2)
Randomize()


Q1CL2
ADD(ParentListName(),3,4)
Randomize()


Q1CL3
ADD(ParentListName(),5,6)
Randomize()


Q1CL4

ADD(ParentListName(),7,8)
Randomize()


Then you can create construsted list Q1CL

Begin Unverified Perl

use List::Util qw(shuffle);
my @array = shuffle(1,2,3,4);

foreach my $i (@array ){
    
    ADD("Q1CL".$i);
} 

End Unverified



This list will randomize 4 blocks of alternatives.

Best regards,
Vasyl
There's many ways we can do this.

My code would need to be changed to something like the below steps.

Create a parent list called OrderList and give it the following values / labels ...
1-1
2-2
3-3
4-4

Now create a constructed list called OrderConList ...
ADD(OrderList)
Randomize()

Create 4 constructed lists naming them B21ConList, B22ConList, B23ConList and B24ConList (as in the examples above). Each of these lists need to add your respective codes and randomise. You never mentioned your blocks / batches but I'm sure you get the picture.

This constructed list will pull it all together ...
Begin Unverified Perl
 
 ADD("B2".LISTVALUE("OrderConList",1)."ConList");
 ADD("B2".LISTVALUE("OrderConList",2)."ConList");
 ADD("B2".LISTVALUE("OrderConList",3)."ConList");
 ADD("B2".LISTVALUE("OrderConList",4)."ConList");
 
End Unverified
Thanks Vasyl. Works like a charm.
...and thanks Paul for providing a second option. Will try this one in the next programming :)
Guido, you are welcome!
...