Have an idea?

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

Randomly allocate respondents to question block

Hi,

How do I randomly allocate respondents to a set of questions?

I have two blocks of questions: Pricing Structure for Product 1 and Pricing Structure for Product 2.

Respondents are allocated to the pricing streams based on whether they most prefer Product 1 or Product 2 in an earlier question (Q1), however they also have the option to say that they prefer either product in Q1. For those who prefer either product, I would like to randomly allocate them to just one of the Pricing Structure modules...how do I do this?
asked Aug 12 by anonymous

2 Answers

0 votes
After Q1 has been answered, insert this Perl Script into the footer of a question that is not skipped. We want this script to execute.

First define a Pass-In Field and call it "PSMPath". Define it as a whole number.

Insert this script in to an appropriate question.
[%Begin Unverified Perl 

 SETVALUE("PSMPath",0); 

 if (VALUE("Q1_1")==1 && VALUE("Q1_2")==0)
  {
   SETVALUE("PSMPath",1); 
  }

 elsif (VALUE("Q1_1")==0 && VALUE("Q1_2")==1)
  {
   SETVALUE("PSMPath",2); 
  }

 elsif (VALUE("Q1_1")==1 && VALUE("Q1_2")==1)
  {
   SETVALUE("PSMPath",SYSRAND(1,2)); 
  }
 
End Unverified%]

You can now use PSMPath in skip logic to jump over questions.

Note ...

1/ I have assumed Q1 is a multiple response select question.
2/ I have assume Product 1 is code 1 and Product 2 is code 2.
3/ If only one of the products is mentioned at Q1, that pathway will be allocated (Product 1 will have PSMPath=1 and Product 2 will have PSMPath=2 ).
4/ If both Products 1+2 are mentioned at Q1, one will be randomly selected.

You should see a fairly close pathway split between Products 1+2 where they are both mentioned, but if you wanted to be even stricter on this, you can introduce least fill quotas in to this solution.
answered Aug 12 by Paul Moon Platinum (85,380 points)
0 votes
Great solution as always Paul!  I will add that depending upon overall objective, the least fill quota may want to be considered as you said.  That way you can define one as Q1_1=1 and the other as Q1_2=1 and choose least fill, then it will help maintain an overall balance in the event both were chosen.  However, if the overall balance doesn't matter and you just want a fairly even split between the ones that chose both, then Paul's initial solution is definitely the way to go.
answered Aug 12 by Jay Rutherford Gold (38,005 points)
Correct Jay.

You can just switch thew following ...
elsif (VALUE("Q1_1")==1 && VALUE("Q1_2")==1)
  {
   SETVALUE("PSMPath",SYSRAND(1,2)); 
  }

with the least fill quota component ...
elsif (VALUE("Q1_1")==1 && VALUE("Q1_2")==1)
  {
   SETVALUE("PSMPath",VALUE("QTProduct")); 
  }

where QTProduct is the quota question storing the least filled quota value.
Hi Paul,

You are correct.

I think we can shorten the code here.

I would like to add here that if we are creating a least fill quota, we can simply write as below. In case only one condition is met, it will automatically punch that value and will punch value on basis on lowest read if both are true.

[%Begin Unverified Perl  
SETVALUE("PSMPath",VALUE("QTProduct"));
End Unverified%]


Also, this perl and creating pass-in-field variable is also not required here, we can directly use the value of quota variable in skip logics to jump questions.

Regards,
Rahul Mittal
Certainly if the least fill option is such a relevant issue, we can use the quota question to do most of the work.

Even SSI Script instead of Perl if the quota question plays a role ...
[%SetValue(PSMPath,Value(QTProduct))%]

Or just use QTProduct.
...