This is an old revision of the document!
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.
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.
The ballot, or combination, drawn has to be be saved in the data record. To do so, you need internal variables.
IV01
).
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.
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.