Have an idea?

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

Random-Payoff-Mechanism with previously answered CBC

Hi all,

we want to create a Random-Payoff-Mechanism (= one randomly selected decision by the participant was implemented as an actual purchase) out of previously answered CBCs.

Therefore in the end of the study we need to choose one of those CBC Choice Tasks randomly and display the previously given answer of that.

Anyone having an idea how to implement that?

Thanks very much in advance for any help!
Lena
asked Nov 13 by Lena

1 Answer

0 votes
Assuming a discrete choice non-fixed CBC, please create a numeric question on the page where you want to display the random task.  Add this script to the numeric question:

<style>
#[% QuestionName() %] {
    display: none;
}
</style>

<script>
$(document).ready(function(){
    $('#[% QuestionName() %]').val($('#randomTask').val());
})
</script>

[% Begin Unverified Perl
# Parameters
my $exerciseName = 'cbc';
my $numberOfAttributes = 4;
my $numberOfTasks = 8;
my $noneConcept = -1;
my $noneText = 'None option';

# Run
my $task = RANDNUM(RESPNUM(), 1, $numberOfTasks);
my $question = $exerciseName . '_Random' . $task;
my $concept = GETVALUE($question);

my $out;

$out .= '<input type="hidden" id="randomTask" value="' . $task . '"/>';

if ($concept == $noneConcept) {
    $out .= $noneText;
}
else {
    my @levels;
    for (my $attribute = 1; $attribute <= $numberOfAttributes; $attribute++) {
        push (@levels, CBCDESIGNLEVELTEXT($question, $concept, $attribute));
    }
    $out .= join('<br/>', @levels);
}

return $out;
End Unverified %]


Line 15 must be updated with the name of the exercise.  Line 16 with the number of attributes.  Line 17 with the number of tasks.  If the exercise has a traditional none option, line 18 must be updated with the none option concept number and line 19 with the text to display when the none option was chosen.

The value stored in the numeric response is which task was selected.
answered Nov 13 by Zachary Platinum Sawtooth Software, Inc. (129,150 points)
edited Nov 13 by Zachary
Dear Zachary,

thank you very much for your support! Would this script also work with several CBC exercises with only fixed tasks?

In total we have 20 different CBC exercises with 5-6 fixed tasks each.

Is there still any possibility to randomly choose one of those tasks afterwards and display it again?

Thanks a lot and best regards
Lena
If an exercise is all fixed tasks, that's an easy change.  You should just need to set the number of tasks to the number of fixed tasks and replace "_Random" with "_Fixed" in the code.  It's just when you have a mix of fixed and random tasks that makes things a tiny bit trickier.

When you say you have multiple exercises, do you mean that you want to show just one selected task from any one of those exercises?  If so, that could be done, but I would want to clarify how the randomness ought to work.  If CBC1 has 5 tasks and CBC2 has 6 tasks, should I make it so that both exercises have a 50% chance of being selected (meaning that each of CBC1's tasks will appear slightly more often than each of CBC2's tasks) or make it so that each task has an equal chance of being selected (meaning CBC2 is slightly more likely to be chosen than CBC1)?
Hi Zachary,

by now we decided to just include 8 CBC exercises with 6 tasks each. So we don't need to decide on the mentioned chance to be selected anymore.

Anyway now we have another question...
How do we have to fill out the number of attributes when this is differing between all of the CBC exercises?

F.e. when we have 2 exercises à 4 attributes + 2 exercises à 5 attributes, do we have to include the TOTAL number of attributes (=18) or how do we have to insert this?
Same with the number of tasks? Do we have to insert the TOTAL number or the individual gradations?

Best regards
Lena
We can start by creating a free format question with a hidden, text variable named "_task."  Give the free format this code:

[% Begin Unverified Perl
# Parameters
my @exercises = (
    {
        'exercise' => 'cbc1',
        'attributes' => 3,
        'tasks' => 6,
        'none' => -1,
        'nonetext' => ''
    },
    {
        'exercise' => 'cbc2',
        'attributes' => 4,
        'tasks' => 6,
        'none' => 5,
        'nonetext' => 'my none text'
    }
);

# Run
my $chosenExerciseSettings = RANDNUM(RESPNUM() * 5, 0, scalar @exercises - 1);
my $chosenExercise = $exercises[$chosenExerciseSettings]{'exercise'};
my $chosenTask = RANDNUM(RESPNUM() * 11, 1, $exercises[$chosenExerciseSettings]{'tasks'});
my $question = $chosenExercise . '_Fixed' . $chosenTask;
my $response = GETVALUE($question);

my $out = '<input type="hidden" name="' . QUESTIONNAME() . '_task" id="' . QUESTIONNAME() . '_task" value="' . $question . '"/>';
if ($response == $exercises[$chosenExerciseSettings]{'none'}) {
    $out .= $exercises[$chosenExerciseSettings]{'nonetext'};
}
else {
    my @levels;
    for (my $attribute = 1; $attribute <= $exercises[$chosenExerciseSettings]{'attributes'}; $attribute++) {
        push (@levels, CBCDESIGNLEVELTEXT($question, $response, $attribute));
    }
    $out .= join('<br/>', @levels);
}
return $out;
End Unverified %]


Notice how I have filled lines 4 through 17 with the relevant settings for two exercises.  You will want to do this for all of your CBCs.  For each exercise, the code needs to know the name of the exercise, the number of attributes, the number of tasks, the position of the none concept (if any), and the none option text (if any).  Notice how each exercise's details appear between a "{" character and a "}" character, with a comma needed after every exercise except the last.

Line 36 doesn't seem to want to print out very well.  Between the apostrophes is meant to be this:

<br/>
Hi Zachary,

thank you very much - this is working out very well!
We are now wondering if the script makes sure that only those product sets are chosen and displayed randomly that the respondent really selected in the tasks before? I just wanted to double check with you.
The code is meant to show the selected concept of a randomly selected task of a randomly selected exercise, but I always encourage users of this forum to test the behavior of my scripts to ensure that it is meeting their requirements.  If you export your CBC designs and open them up in Excel or a similar spreadsheet tool, you can double check that the text that is getting displayed is in fact the texts of the selected concept for the task saved in the free format variable.
Hey, is there a way to display the entire CBC table by the random payment mechanism? So not just the selected option, but the entire selection set (CBC set) that contains the selected option?
Hi Zachary,

we are urgently looking for a way to additionally(!) display the entire CBC exercise belonging to the randomly selected task - saying something like "The random generator chose product: x. You have previously chosen this product out of this choice set: x, y, z"

Do you have any idea how we can implement this within the script / within the questionnaire?

Thank you very much in advance for your support and best regards
Lena
That's a larger request; I don't know what your CBCs look like.  What version of SSI Web / Lighthouse Studio are you using?  Are you using the out-of-the-box CBC appearance or are you displaying the tasks with free format questions?  Is mobile CBC styling supposed to be used to show the concepts?
Hi Zachary, we use Lighthouse Studio 9.8.0. There are 8 different CBC exercises with only fixed tasks that are relevant for the random selection in the end. We are using the out-of-the box CBC appearance and no free format questions at all. We only use desktop research and no mobile application. Thank you very much!! Lena
...