Inhaltsverzeichnis

Randomization Using Urns

A random draw can be carried out without replacement by using the urn function – this ensures, for example, that experimental groups remain even.

The chapter describes step by step how to create an urn and how to draw a ballot (e.g. a random number) out of the urn. The chapter randomization describes how the ballot drawn is used in randomization.

Important: A Random Generator is more appropritate than urns for most use cases. If your goal is to “just” sort respondents into experimental groups, and present questions, images or texts to them, then please read Randomization.

Important: Urns are the best solution only for very few special ue cases. Please en sind nur für wenige spezielle Anwendungsfälle die beste Lösung. Please be sure to read the chapter on Randomization, before you continue reading here (if that should be necessary at all then).

Drawing without Replacement

A random draw “without replacement” can be likened to a draw from a lottery wheel (“urn”). The use of urns in SoSci Survey (like the the Zufallsgenerator) guarantees experimental groups of the same size. In the context of conjoint analysis, an urn ensures that predefined combinations are equally likely to be drawn.

Advice: Entire questionnaires cannot be randomized using urns. An urn cannot be used to “choose” between different questionnaires. In order to use an urn, all random conditions in the questionnaire have to be set using a filter (see Randomization).

Note: Be sure to carry out a technical test to check whether the drawing of lots in the urn are counted correctly, in particular, if you store the combinations manually.

The basic steps to draw from an urn are as follows:

  1. Add a new question in the List of Questions using the type Internal Variables (e.g. with ID IV01)
  2. In Special FeaturesRandomization Using UrnsCreate new urn, e.g. with the ID (“group”) and enter ballots 1, 2, 3, 4 (each number on a separate line)
  3. PHP code is used to carry out the actual random draw.
urnDraw('group', 'IV01');

Note: Only the question ID is entered as the second parameter in the function urnDraw(), and not the variable ID. This means SoSci Survey can decide, depending on the content of the urn, if only one variable is used (if each ballot only contains one value) or several variables (if you are working with combinations of values).

Note: You can decide whether the ballot drawn should be stored immediately or not until later. Read the the reference to the PHP function urnDraw() for more information.

Note: Normally the urn is re-filled after the last ballot is drawn and stored. If you do not want this to happen, you can prevent this happening directly with the drawing: see urnDraw()

Create an Urn

First of all, you need to create an urn. An urn contains multiple ballots – and each ballot can have one value (normally a number) or a combination of several values.

Most often, urns are used to divide participants into experimental groups. When this is the case, one number per line is recommended. If you have 4 groups, the content of the urn will look as follows:

1
2
3
4

You can get a weighting by writing a row multiple times in the urn. By using the following urn, twice as many participants will be placed in Group 1 than in Group 2 or 3:

1
1
2
3

If you have 3 groups, where a second factor should be varied within the third experimental group, the content of the urn would look as follows (on this occasion, the combinations change):

1, 0
1, 0
2, 0
2, 0
3, 1
3, 2

Note: In order to ensure that respondents cannot just choose any ballot they please, a ballot will only be drawn once per questionnaire. This means, that even if they try to update the page (F5 button in the browser, i.e. “reload page”) during testing, they will always get the same ballot. In order to get a new ballot, you have to start a new questionnaire.

Create Internal Variables

The ballot, or combination, drawn has to be be saved in the data record. To do so, you need internal variables.

Important: Please use this question of type “Internal Variables” for the urn exclusively. Although it is technically possible to create further variables in the question, do not store data there via put(). If you need to store additional data, create another question. Drawing from the urn will not work if something is stored in any variable of the question.

Draw a Ballot from the Urn

PHP code is now used in the questionnaire to draw a ballot from the urn. The function urnDraw() is available in order to do this. The content of the urn drawn (either an individual random number or a combination) is stored in the internal variables, which you set up beforehand. Subsequently, you can use the value(s) drawn in filters or placeholders (see randomization).

When using urnDraw(), you need the IDs that you noted down above (urn ID, “internal variable” question ID). Additionally, you need to decide, when the ballot should be stored, Normally, (not specified or 'now') the ballot is stored straight away. If the participants in a test group systematically drop out more frequently, then there are fewer complete questionnaires in this group. If you expect to encounter problems because of this, use 'end' or 'man' (see reference to urnDraw()'). Note: If you want to manually store a ballot from an urn (third parameter 'man'), make sure that you also employ the function urnPutAway()''.

urnDraw('group', 'IV01');

For the uses of ballots (or combinations) drawn, please read the chapter randomization.