Tip: This page explains in detail how to create a random generator and when such a generator can be used. You can then find concrete examples in the instructions for the individual applications (see below).
The random generator is a functional building block for the questionnaire. The element draws one from a given list of elements ( notes ) and stores its value into a variable. The drawn value can be read using value()
and used in a filter to randomly vary content of the questionnaire. For example, participants can be randomly assigned to experimental groups (Randomization).
By default, the random number generator ensures that all slips are drawn the same number of times (Drawing Type of drawing). This is important especially if the experimental groups are to be of equal size. With unrestricted random selection, on the other hand, it can happen (especially with manageable samples) that the group sizes deviate massively.
Tip: If the random variation does not work as desired, the debug information in the questionnaire usually provides a quick answer. For more information see Problem Solution for Filters and Explanatory video Experimental Randomization at the end.
There are several ways how to use a random generator. This are some functions which the random generator can execute:
Here is explained how to create a simple random generator in general. How this random generator must then be used in particular is then explained in more detail in the individual chapters (see links below).
The random generator as a functional building block is created as a new question in a rubric (An Online Questionnaire in 5 Minutes). Select by adding the question the questiontype Random Generator. Therefore you can tipe the first letters so the questiontype will accure in the selection list. Give the question a description and a question ID and click save ().
You need the question ID in following PHP-codes.
In the next step you enter the Codes (Contents) from which you want to draw later.
For example, if you want to randomize the participants into different groups (e.g., in Randomization), just enter the group names.
Example: Group 1 Group 2 Control group
By saving the question, the system now automatically assigns values (starting with 1) to the individual labels:
Example: 1= Group 1 2= Group 2 3= Control group
Now, when the random number generator is placed in the questionnaire, it assigns a random value (slip of paper) to the participant. These values can be read out later and used in filters.
In some cases it is necessary to adjust the settings in the random generator:
Depending on the further use of the values of the random generator, it must be placed appropriately in the questionnaire. To do this, the question must be dragged to one side when Compose Questionnaire. In any case, the value must be placed before a PHP code where the value is to be read. Once the value of the random generator has been drawn, this value can be read out again in the questionnaire at any time.
The random generator is needed as a basis for some dynamic content in SoSci Survey. This includes:
If one works with many experimental groups, it can be that the actually successful equal distribution is lost after the adjustment. Especially if the number of cases per group is very small, the cases that have to be deleted during the cleanup (e.g. due to the manipulation check) are significant. Then it may be necessary to slightly adjust the random number generator during the survey.
Attention: Readjustment of random selection should only occur when participants are recruited continuously and from the same population. Otherwise there is a risk of confounding: Imagine an experiment with 4 groups, where the participants are all invited on a certain day. After 2/3 of the participants have completed the questionnaire, one notices that in group 1 an above-average number of cases need to be cleaned up. So from now on more participants will be assigned to group 1. Now there is confounding because participants who respond later to an invitation may be significantly different from participants who respond quickly. So participants in Group 1 would now differ a priori from participants in other groups – and thus differences in the dependent variables would no longer be due to the experimental stimulus alone.
Tip: In case you cannot adjust the random draw afterwards, you can use a urn and configure in urnDraw()
a manual dropping of the codes. Manual filing using urnPutAway()
is only done if a filter has been used to verify that the case is usable. Disadvantages: It is comparatively time-consuming and, especially at the beginning of the survey, there may be significantly unequal group sizes.
If the conditions for readjustment (see above) are met, the procedure is as follows:
Code: Number
(see below).For example, the list of codes and usable cases may look like the following:
111111: 2 111211: 1 111311: 2 111411: 2 112111: 1 112211: 2 112311: 2 112411: 2 u.s.w.
In Excel or OpenOffice Calc, you create such a list by merging the previously created frequency table (with codes, not labels) with the following command (when column A contains the codes and column B contains the frequencies):
=CONCATENATE(A1; ": "; B1)
In GNU R you can output frequency table and list as follows (if the variable of the random generator is called e.g. RG01):
tmp = table(data$RG01) cat(paste(paste(names(tmp), tmp, sep=": "), collapse="\n"))