Randomising Logic for a 3 x 2 condition without repeats | XM Community
Question

Randomising Logic for a 3 x 2 condition without repeats

  • 9 July 2020
  • 1 reply
  • 1 view

Hi all,
I am running a study with 2 independent 'author' variables, namely GENDER (male, female, org) x FORMALITY (formal, informal). This leads to 6 possible version of 'authors'. (i.e. Male Formal, Female Formal, Org Formal, Male Informal, Female Informal, Org Informal).
I have 6 texts to be presented to participants, and the 6 'authors' to are to be paired with each text, such that one author can only be paired to one text once, without repeats.
I have created all the possible conditions in separate blocks (sample):
E.g. Org F 1 denotes: Org Formal Text1 and so on.
User:

I need to do a randomisation where

  1. the text order presented to the participant is randomised (e.g. text 1, text 3, text 5...).

  2. the 'author' attached to said text is randomised.


But also such that if an 'author' is used in the preceding text presented, then it will be taken out of the pool, and not available for subsequent randomisation. I have attached 3 possible outcome flows for 3 different participants here:
User:


How do i structure the logic of the randomiser to achieve said effect? Thank you so much!!


1 reply

Userlevel 2
Badge +3

Another approach could be to have only six blocks and using embedded data and piped text to determine how the six blocks are presented. It depends on how you're meaning to present everything, but if you can pipe in text based on authors and text, you can randomize the order of both in javascript. Something like this (I barely actually know js; I found the shuffle function online, so please don't blindly trust me) can shuffle your six author types and six texts and assign them to embedded data fields author1... author6 and text1... text6 (just make sure you're also adding those embedded data fields to your survey flow too).
Qualtrics.SurveyEngine.addOnload(function()
{

function shuffle(array) {
  var m = array.length, t, i;


  // While there remain elements to shuffle…
  while (m) {


    // Pick a remaining element…
    i = Math.floor(Math.random() * m--);


    // And swap it with the current element.
    t = array[m];
    array[m] = array[i];
    array[i] = t;
  }


  return array;
}


var shuffleAuthors = shuffle(['maleFormal','maleInformal','femaleFormal','femaleInformal','orgFormal','orgInformal'])

Qualtrics.SurveyEngine.setEmbeddedData("author1", shuffleAuthors[0])
Qualtrics.SurveyEngine.setEmbeddedData("author2", shuffleAuthors[1])
Qualtrics.SurveyEngine.setEmbeddedData("author3", shuffleAuthors[2])
Qualtrics.SurveyEngine.setEmbeddedData("author4", shuffleAuthors[3])
Qualtrics.SurveyEngine.setEmbeddedData("author5", shuffleAuthors[4])
Qualtrics.SurveyEngine.setEmbeddedData("author6", shuffleAuthors[5])

var shuffleText = shuffle(['textValue1','textValue2','textValue3','textValue4','textValue5','textValue6'])

Qualtrics.SurveyEngine.setEmbeddedData("text1", shuffleText[0])
Qualtrics.SurveyEngine.setEmbeddedData("text2", shuffleText[1])
Qualtrics.SurveyEngine.setEmbeddedData("text3", shuffleText[2])
Qualtrics.SurveyEngine.setEmbeddedData("text4", shuffleText[3])
Qualtrics.SurveyEngine.setEmbeddedData("text5", shuffleText[4])
Qualtrics.SurveyEngine.setEmbeddedData("text6", shuffleText[5])


});
From there, you can have question1 pipe in text based on author1 and text1, question 2 pipe from author2 and text2, etc... You won't be repeating any authors or texts and they'll be randomly ordered and combined. Data analysis would be slightly tricky as each question will be presented differently to different respondents, so you may have to re-map some responses to match them to authors and texts. But I think that's doable?

Leave a Reply