Randomising Logic for a 3 x 2 condition without repeats | XM Community
Skip to main content

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!!

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 = arraym];
    array]m] = array i];
    array[i] = t;
  }


  return array;
}


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

Qualtrics.SurveyEngine.setEmbeddedData("author1", shuffleAuthorsh0])
Qualtrics.SurveyEngine.setEmbeddedData("author2", shuffleAuthorsh1])
Qualtrics.SurveyEngine.setEmbeddedData("author3", shuffleAuthorsh2])
Qualtrics.SurveyEngine.setEmbeddedData("author4", shuffleAuthorsh3])
Qualtrics.SurveyEngine.setEmbeddedData("author5", shuffleAuthorsh4])
Qualtrics.SurveyEngine.setEmbeddedData("author6", shuffleAuthorsh5])

var shuffleText = shuffle(h'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