This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
en:create:randomization [06.06.2017 12:52] – [Drawing of a Random Number] admin | en:create:randomization [19.12.2018 11:05] – [Urns for Subgroup I] freekgille | ||
---|---|---|---|
Line 6: | Line 6: | ||
Tip: Read the chapters [[php|Introduction to PHP]] and [[array|Introduction to Arrays]] for a better understanding of the complex example codes shown below. | Tip: Read the chapters [[php|Introduction to PHP]] and [[array|Introduction to Arrays]] for a better understanding of the complex example codes shown below. | ||
+ | |||
+ | |||
+ | ===== General Usage ===== | ||
+ | |||
+ | The experimental logic (between-subject) assumes that the participants of an experiment are divided into experimental groups. Depending on the group assignment, a question, text, image or video (the treatment or stimulus) is then varied. | ||
+ | |||
+ | Even if your goal " | ||
+ | |||
+ | |||
+ | ==== Step 1: Assignment to experimental groups ==== | ||
+ | |||
+ | Create a question of type [[: | ||
+ | |||
+ | < | ||
+ | Control Group | ||
+ | Positive Exemplars | ||
+ | Negative Exemplars | ||
+ | </ | ||
+ | |||
+ | After saving, SoSci Survey adds a numeric code for each group, e.g. | ||
+ | |||
+ | < | ||
+ | 1 = Control Group | ||
+ | 2 = Positive Exemplars | ||
+ | 3 = Negative Exemplars | ||
+ | </ | ||
+ | |||
+ | With the //Type of drawing// you can decide whether you want to select "Equal distribution in completed questionnaires" | ||
+ | |||
+ | For //Codes drawn per interview// leave the value 1. Thus, the participant is only assigned to one of the experimental conditions/ | ||
+ | |||
+ | |||
+ | ==== Step 2: Presentation of the Stimulus ==== | ||
+ | |||
+ | In **Combine Questionnaire**, | ||
+ | |||
+ | The random generator will now randomly draw one of the defined groups and store its code in a variable with the random generator' | ||
+ | |||
+ | Place an element " | ||
+ | |||
+ | If the stimulus is a question (i.e. in group A another question from the **List of Questions** is to be displayed than in group B), the function '' | ||
+ | |||
+ | The following PHP code would display the question " | ||
+ | |||
+ | <code php> | ||
+ | if (value(' | ||
+ | question(' | ||
+ | } elseif (value(' | ||
+ | question(' | ||
+ | } else { | ||
+ | // You may omit the else part, | ||
+ | // nothing happens here | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The function '' | ||
+ | |||
+ | The other sections of this manual explain various areas of application of randomization. | ||
+ | |||
===== Drawing of a Random Number ===== | ===== Drawing of a Random Number ===== | ||
Line 16: | Line 75: | ||
* An option to the random generator is [[: | * An option to the random generator is [[: | ||
* Very rarely, the different variants of the questionnaire are so diverse that using filters is impractical. If this is the case, the participant can be allocated at random to different questionnaires ([[random_questionnaire|Random Selection for Questionnaires]]). Drawing with replacement is always used when a questionnaire is selected at random. Therefore, the resulting group sizes may vary considerably. | * Very rarely, the different variants of the questionnaire are so diverse that using filters is impractical. If this is the case, the participant can be allocated at random to different questionnaires ([[random_questionnaire|Random Selection for Questionnaires]]). Drawing with replacement is always used when a questionnaire is selected at random. Therefore, the resulting group sizes may vary considerably. | ||
+ | |||
+ | **Tip:** Use '' | ||
Line 42: | Line 103: | ||
This example shows graphic " | This example shows graphic " | ||
- | Instead of using '' | + | Instead of using '' |
+ | |||
+ | The following PHP code presents the same image like the avove PHP code. Yet, this code does not use the full HTML code for each image, but a placeholder '' | ||
+ | <code php> | ||
+ | $code = value(' | ||
+ | |||
+ | // Grafikdatei in Abhängigkeit von der Zufallszahl in einen Platzhalter schreiben | ||
+ | if ($code == 1) { | ||
+ | replace(' | ||
+ | } elseif ($code == 2) { | ||
+ | replace(' | ||
+ | } elseif ($code == 3) { | ||
+ | replace(' | ||
+ | } elseif ($code == 4) { | ||
+ | replace(' | ||
+ | } | ||
+ | // The HTML code may be embedded via html() | ||
+ | // or (not shown here) as text element | ||
+ | html('< | ||
+ | </ | ||
+ | |||
+ | **Tip:** Placeholders are especially helpful if the stimulus requires more HTML code then shown in the example above (e.g., to embed videos). | ||
+ | |||
+ | **Tip:** The name of the PHP variable (the examples use '' | ||
+ | |||
+ | If your stimuli require extensive HTML code (e.g., videos), when there are substantial differences in the experiment groups' | ||
+ | |||
+ | <code php> | ||
+ | $code = value(' | ||
+ | |||
+ | // Embed text or HTML code | ||
+ | if ($code == 1) { | ||
+ | text(' | ||
+ | } elseif ($code == 2) { | ||
+ | text(' | ||
+ | } elseif ($code == 3) { | ||
+ | text(' | ||
+ | } elseif ($code == 4) { | ||
+ | text(' | ||
+ | } | ||
+ | </ | ||
Line 50: | Line 151: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
// enter complete HTML code every time | // enter complete HTML code every time | ||
if ($number == 1) { | if ($number == 1) { | ||
Line 58: | Line 161: | ||
</ | </ | ||
- | < | + | < |
+ | $number = value(' | ||
// only determine the image' | // only determine the image' | ||
if ($number == 1) { | if ($number == 1) { | ||
Line 74: | Line 179: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
text(' | text(' | ||
Line 106: | Line 213: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
text(' | text(' | ||
Line 127: | Line 236: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
+ | // Display one question or another | ||
if ($number == 1) { | if ($number == 1) { | ||
question(' | question(' | ||
Line 137: | Line 249: | ||
<code php> | <code php> | ||
- | // show the one or the other question | ||
$number = value(' | $number = value(' | ||
+ | |||
+ | // Display one question or another | ||
if ($number == 1) { | if ($number == 1) { | ||
question(' | question(' | ||
Line 148: | Line 261: | ||
<code php> | <code php> | ||
$number = value(' | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
question(' | question(' | ||
Line 163: | Line 277: | ||
<code php> | <code php> | ||
$number = value(' | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
setPageOrder(' | setPageOrder(' | ||
Line 173: | Line 288: | ||
You can find further explanations and examples in the section '' | You can find further explanations and examples in the section '' | ||
+ | |||
+ | |||
+ | ==== Stimuli and Questions on different pages ==== | ||
+ | |||
+ | If there is a distinct question for each stimulus variant, and both shall be presented on different pages, use a filter on both pages. As soon as a random number has been drawn once (e.g., as variable '' | ||
+ | |||
+ | <code php> | ||
+ | // PHP code in the page with the stimulus | ||
+ | $number = value(' | ||
+ | |||
+ | if ($number == 1) { | ||
+ | text(' | ||
+ | } elseif ($number == 2) { | ||
+ | text(' | ||
+ | } elseif ($number == 3) { | ||
+ | text(' | ||
+ | } elseif ($number == 4) { | ||
+ | text(' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | // PHP code on a later page that displays the question | ||
+ | $number = value(' | ||
+ | |||
+ | if ($number == 1) { | ||
+ | question(' | ||
+ | } elseif ($number == 2) { | ||
+ | question(' | ||
+ | } elseif ($number == 3) { | ||
+ | question(' | ||
+ | } elseif ($number == 4) { | ||
+ | question(' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | **Note: | ||
+ | |||
+ | **Tip:** This variable also allows the distribution of a stimulus (e.g., pages 1 to 3 of a newspaper article) on different pages. | ||
Line 332: | Line 486: | ||
===== Draw Multiples out of Urns ===== | ===== Draw Multiples out of Urns ===== | ||
+ | |||
+ | **Important: | ||
If you want to draw from different urns you also need several questions with the type " | If you want to draw from different urns you also need several questions with the type " | ||
Line 416: | Line 572: | ||
It may be the case that you need to ensure equal distribution of experimental groups in two subgroups -- for instance, if you have 3 stimuli and both the women in the study, as well as the men, should be equally divided between all three conditions. | It may be the case that you need to ensure equal distribution of experimental groups in two subgroups -- for instance, if you have 3 stimuli and both the women in the study, as well as the men, should be equally divided between all three conditions. | ||
- | To do so, you require an internal variable and two urns (with the same content). The following example assumes that the sex was queried on an earlier page in the multiple-choice question SD02. Also, that you have set up two urns with the IDS " | + | To do so, you require an internal variable and two urns (with the same content). The following example assumes that the sex was queried on an earlier page in the multiple-choice question SD02. Also, that you have set up two urns with the IDS " |
<code php> | <code php> |