Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
en:create:questions:random [30.07.2019 22:23] – Update adminen:create:questions:random [11.03.2021 17:21] sophia.schauer
Line 1: Line 1:
-====== Random generator ======+====== Random Generator ======
  
-The random generator is a functional component for the questionnaire. It draws one element from a predefined list of elements (ballots) and saves its value in variable. The picket value can be retrieved via ''[[:en:create:functions:value]]''  and used in a [[:en:create:filters|Filter]], to randomly vary contents of the questionnaire. This would e.g. allow the random assignment of participants to experimental groups.+**Tip:** This page explains in detail how to create a random generator and when such generator can be used. You can then find concrete examples in the instructions for the individual applications (see below).
  
-The random generator developed from the [[:en:create:random_urns|urn-function]] and ensures (like the urn) that all ballots are drawn equally (option //mode of drawing//). This is especially important when experimental groups have to be of equal sizeBecause an unrestricted random sampling could lead to massive deviations in group sizes (especially in case of smaller samples).+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 ''[[:en:create:functions:value]]'' and used in a [[:en:create:filters|filter]] to randomly vary content of the questionnaireFor example, participants can be randomly assigned to experimental groups ([[en:create:randomization|]]).
  
-The extensive examples in the chapter [[:en:create:randomization]]concerning the use of filters for experimental stimuli, are also transferable to the random generator. This can be done by placing the random generator element on the questionaire page (instead of the operator ''[[:en:create:functions:urndraw]]''). The code that was drawn can then be retrieved via ''[[:en:create:functions:value]]'' (as described in the urn thread)Either on the same page (below the random generatorand/or on any subsequent page of the questionnaire.+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 sizeWith unrestricted random selection, on the other hand, it can happen (especially with manageable samplesthat the group sizes deviate massively.
  
-**Hint:** If the random variation doesn’t work as desired, the debug-informations in the questionnaire will provide fast explanations(Read more at [[:en:create:filter-solving]].)+**Tip:** If the random variation does not work as desired, the debug information in the questionnaire usually provides a quick answerFor more information see [[:en:create:filter-solving]] and [[https://cast.itunes.uni-muenchen.de/clips/H2qJPn0rX8/vod/online.html|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:  
 +  * Two values are available for the drawn note: First, the numeric code and second, the entered text for the slip -- this can be, for example, the filename of an image (e.g. [[en:create:randomization-einfaktoriell|]]).
 +  * The random generator can draw multiple slips within an interview (option //Codes drawn per interview//), ensuring that the same slip is not drawn multiple times.
 +  * The random generator returns only one value (and its label) per slip. But combinations can also be implemented using randomization (see [[en:create:randomization-within|]]).
  
-===== Differences between random generator and urn function ===== 
  
-  * For the second drawn ballot two kinds of values are available: first the numeric code and second the inscribed text for the ballot (e.g. the file name of image, as seen in the example below) +===== Create Random Generator===== 
-  * The random generator can draw multiple ballots during one interview (option //Amount of ballots per interview//) ensuring that no ballot can be drawn twice +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 yields only one value (including it’s inscription) per ballot. Combinations are only possible using the following workaround: The combination is saved as an inscription and separated after the drawing using [[http://php.net/manual/de/function.explode.php|explode()]].+
  
 +====Step 1: Add a Random Generator====
  
-===== ExampleVarying screen-stimulus =====+The random generator as a functional building block is created as a new question in a rubric ([[en:create:basics|]]). 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 ({{:button.save.png?nolink|Save}}).
  
-This example describes the use of the random generator in an experiment with 3 experimental groups (with one image stimulus each) and a control group (no stimulus).+{{:de:create:questions:scr.random.create.png?nolink|Zufallsgenerator anlegen}}
  
 +You need the question ID in following PHP-codes.
  
-===== Preperations =====+====Step 2: Add Contents==== 
 +In the next step you enter the //Codes (Contents)// from which you want to draw later.
  
-  * Upload the 3 image stimuli to **Image and Media Files** and note the filenames. Take also care for case sensitivity (so Datei.jpg doesn’t equal datei.JPG). +For example, if you want to randomize the participants into different groups (e.g., in [[en:create:randomization]]), just enter the group names
-  * Create a new question of the „random generator“ type (in the following case the question is named ZG01). Enter the following ballots (Note that file names can deviate from case to case.into the question:+  Example: 
 +  Group 1 
 +  Group 2 
 +  Control group  
 +By saving the questionthe system now automatically assigns values (starting with 1to the individual labels: 
 +  Example: 
 +  1= Group 1 
 +  2= Group 2 
 +  3= Control group
  
-<code> +Now, when the random number generator is placed in the questionnaire, it assigns a random value (slip of paper) to the participantThese values can be read out later and used in filters.
-1 = stimulusA.jpg +
-2 = stimulusB.jpg +
-3 = stimulusC.jpg +
-4 = control_group +
-</code>+
  
-===== Application =====+====Step 3: More Settings==== 
 +In some cases it is necessary to optimize the random generator: 
  
-Under **Create a Questionnaire** you can drag and drop the random generator to the page you want the picture to appear. Now place (s. also [[:en:create:php]]) the following PHP code beneath (!) the random generator:+  Specify how many codes must be drawn:\\ In some cases it is necessary to draw several slips (for example 20 images out of 300). Enter the corresponding value under //Codes drawn per interview//
 +  Type of drawing:\\ As mentioned above, you should think about which draw you need before you create the random number generator. By default, equal distribution is provided. However, this can lead to unequal groups if the groups are small and many dropouts are expected. So, under //Type of draw// there are different settings how the slips are drawn. 
 +  * Display contents:\\ it is also possible to already specify file names as slips and to include them directly on the questionnaire page using //show content// (see [[en:create:randomization-einfaktoriell]])
  
-<code php> 
-// Retrieve the numeric codes  (1 bis 4) 
-$code = value('ZG01'); 
-// The control group has to be treated differently 
-if ($code == 4) { 
-  // Kontrollgruppe - nichts anzeigen 
-} else { 
-  // The inscription is saved as a value label – in this example the image name 
-  $img = value('ZG01', 'label'); 
-  // The HTML-Tag <img> shows an image, the filename will be shown with src 
-  html(' 
-    <div style="margin: 3em; text-align: center"> 
-      <img src="'.$img.'" alt="" /> 
-    </div> 
-  '); 
-} 
-</code> 
  
 +====Step 4: Placing 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.
  
-//in case your image width does not display properly, you can include this coding for width for the html code:+=====Using the Random Generator=====
  
-html('  +The random generator is needed as a basis for some dynamic content in SoSci SurveyThis includes: 
-      <img src="'.$img.'" alt="" width="100%" /> +  * [[en:create:randomization|]] 
-    </div> +  * [[en:create:rotation|]] 
-  ');+  * [[en:create:random_questionnaire]] 
 +  * [[en:create:vouchers]]
  
  
-==== Addition 1 ====+===== Readjust Drawings =====
  
-Not every experimental variation is resolved by displaying a single imageThe following PHP code shows how to display another image on another position. The variation happens contingent by the first imageso if someone got the image 1a displayed he will on this position get image 1b. +If one works with many experimental groups, it can be that the actually successful equal distribution is lost after the adjustmentEspecially 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.
-This time the filename for the image will not be saved directly into the random generator (like above) but in an array ([[:en:create:array]]), which will assign a filename to every experimental group using ''%%=>%%''.+
  
-<code php> +**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:  
-// Retrieving of the numeric codes (1 to 4) +Imagine an experiment with groups, where the participants are all invited on a certain day. After 2/3 of the participants have completed the questionnaireone 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.
-$code = value('ZG01'); +
-// The control group must (here to) be treated differently +
-if ($code == 4) { +
-  // Control group – display nothing +
-} else { +
-  // Array, that saves an image for every group +
-  $bilder = array( +
-    => 'stimulusA2.jpg', +
-    2 => 'stimulusB2.jpg', +
-    3 => 'stimulusC2.jpg' +
-  ); +
-  // With the square brackets an element from the array is read +
-  $bild = $bilder[$code]; +
-  // Display oft he image as above +
-  html(' +
-    <div style="margin: 3em; text-align: center"> +
-      <img src="'.$bild.'" alt="" /> +
-    </div> +
-  '); +
-+
-</code>+
  
-**Note:** This PHP-code only worksif at an earlier time in the same interview another page with random generator question was used. If you start the interview for testing directly on the page with the PHP-code (but without a random generatorwhich occurs earlier in the interview)you will receive an error message.+**Tip:** In case you cannot adjust the random draw afterwardsyou can use a [[:en:create:random_urns|urn]] and configure in ''urnDraw()'' a manual dropping of the codes. Manual filing using ''[[:en:create:functions:urnputaway]]'' is only done if [[:en:create:filters|filter]] has been used to verify that the case is usable. Disadvantages: It is comparatively time-consuming andespecially at the beginning of the surveythere may be significantly unequal group sizes.
  
-==== Addition 2 ==== +If the conditions for readjustment (see above) are met, the procedure is as follows: 
- +  - The preliminary dataset is cleaned (dropouts, missing responses, manipulation check, no consent to use the information, ...). 
-Instead of an image also a question or a text module can be integrated. The following PHP code displays an individual text module (create under **Text Elements and Labels** -- and in groups 1 and 2 the question ''AB01'', in the other groups the question ''BB01''). +  - A frequency table is created over the variable of the random generator.
- +
-<code php> +
-// Retrieving of the numeric codes (1 to 4) +
-$code = value('ZG01'); +
-// Varriing the text modules +
-if ($code == 1) { +
-  text('text EG1'); +
-} elseif ($code == 2) { +
-  text('text EG2'); +
-} elseif ($code == 3) { +
-  text('text EG3'); +
-} elseif ($code == 4) { +
-  text('text KG'); +
-+
-// Variing the questions +
-if (($code == 1) or ($code == 2)) { +
-  question('AB01'); +
-} else { +
-  question('BB01'); +
-+
-</code> +
- +
-**Note:** view in addition to ''[[:en:create:functions:text]]'' and ''[[:de:create:functions:question]]'' also the orders ''[[:en:create:functions:replace]]'' and ''[[:en:create:functions:setpageorder]]''+
- +
- +
-===== Example: Show multiple images ===== +
-In this example participants should rate 300 images. To achieve this each participant has to rate 20 different pictures - each on a different page. +
- +
-==== Preperation ==== +
-  * Upload all images to **Images and Media Data** +
-  * Create a new question of the „random generator“ type (in the following case the question is named ZG03). +
-    * Enter the file names of the images as ballots into the question, one filename per line. You don’t have to put numbers ahead, they will be provided automatically after saving. +
-    * For the option //Number of ballots per interview//, enter the number of images that you want to show (in this case 20). +
-  * For the ratings create 20 questions with ID’s ranging from ''AB01'' to ''AB20'' – the function “Duplicate Question” (You will find it above the question when you edit it.) will help you to save time. If it’s only one rating per image you could also create one question with 20 images. +
- +
-==== Application ==== +
-Create one (!) page to display the images and the corresponding questions using **Create a Questionnaire**. Place the random generator on this page and beneath it the following PHP code (s. also [[:en:create:php]]). The command ''[[:en:create:functions:looppage]]'' provides that the same page will be shown multiple with different content. The command ''[[http://php.net/manual/de/function.sprintf.php|sprintf()]]'' formats a number – in PHP code a double-digit number will be created with a leading 0 (e.g. 3 will be „03“). +
- +
-<code php> +
-// loopPage(20) provides a number between 0 and 19 (plus one at every repetition) +
-$i = loopPage(20);  // Here you can enter the number of images you want to show +
-// Show the chosen picture +
-$varID = 'ZG03x'.sprintf('%02d', $i + 1);  // Variable IDs are ZG03x01 to ZG03x20 +
-$img = value($varID, 'label'); +
-// The HTML-Tag <img> shows one image, the filename will be shown with src  +
-html(' +
-  <div style="margin: 3em; text-align: center"> +
-    <img src="'.$img.'" alt="" /> +
-  </div> +
-'); +
-// Create the fitting question ID and show the question using question() +
-question(id('AB', $i + 1)); // Question IDs AB01 to AB20 +
-</code> +
- +
-If you didn’t create 20 questions (''AB01'' to ''AB20''), but only one question AB01 with 20 items, substitute the last 3 lines as follows. The +1 behind the variable ''$i'' is needet, because ''loopPage()'' starts counting at 0 instead of 1. +
- +
-<code php> +
-// Shows the item fitting to the question using question()  +
-question('AB01', $i+1); +
-</code> +
- +
- +
-===== Example: Rate multiple political parties ===== +
- +
-In the following example the participants have to evaluate political parties using many different criteria. Altogether 6 parties have to be evaluated – but every participant should only have to evaluate two of them chosen randomly. +
- +
-==== Option 1 ==== +
- +
-This Option will always save the answers to the first drawn party in the same variable. If you use e.g. 20 variables per party, your dataset will have 40 variables for party evaluations. This is overseeable, but a little bit more difficult to analyse, because one half of the answers for e.g. the green party will be saved in set of variables ''P1xx'' while the other half will be saved in set of variables ''P2xx''. Use this option if you have (a) many items to evaluate and (b) are really good in analysing the data. +
- +
-  * Create a category (e.g. “P1”) in your questionnaire, with all questions you want to ask about a party. Instead of the party name enter the [[:en:create:placeholders|placeholder]] ''%partei%''+
-  * Create a copy of the category, by downloading the category as an XML-file (Arrow down symbol in the toolbar above the question) and importing the file under //New category//. In this example the label ''P2'' is used. +
-  * Create a questionnaire under ** Create a Questionnaire ** and place the questions from ''P1'' and ''P2'' on their intendet positions. In this questions it is assumed that at first all questions from ''P1'' and subsequently all questions from ''P2'' will be asked. In order to mix the questions different placeholders (e.g. ''%partei1%'' und ''%partei2%'') would have to be used in the questions and items. +
-  * Create a question of the type "Random generator" (in this example it is assumed to have the label ZG04). In the question, enter the following //ballots (contents)//  and at //Number of ballots per interview// enter the value 2. +
- +
-<code> +
-1 = CDU/CSU +
-2 = SPD +
-3 = Die Grünen +
-4 = Die Linke +
-5 = Piraten +
-6 = AfD +
-</code> +
- +
-Place the random generator under ** Create a Questionnaire ** on the first page with a ''P1''-question (or bevore). Beneath it, place the following PHP code.: +
- +
-<code php> +
-$name = value('ZG04x01', 'label');  // Name of the party (CDU/CSU to AfD) +
-replace('%partei%', $name); +
-</code> +
- +
- +
-From there on the placeholder ''%partei%''  will be replaced in every question by the drawn Names. The numeric code of the party can be read using ''$code = value('ZG04x01');'' to e.g. use a text module or a party logo (s. above)  +
- +
-Place the following PHP-code on the first page with a „P2“-question: +
- +
-<code php> +
-$name = value('ZG04x02', 'label'); +
-replace('%partei%', $name); +
-</code> +
- +
-If you want to mix the questions about the two parties, and if you have therefore used the placeholders ''%partei1%'' and ''%partei2%'', place the following PHP-code beneath the random generator: +
- +
-<code php> +
-$name1 = value('ZG04x01', 'label'); +
-replace('%partei1%', $name1); +
-$name2 = value('ZG04x02', 'label'); +
-replace('%partei2%', $name1); +
-</code> +
- +
- +
-==== Option 2 ==== +
- +
-It’s also possible to create own questions for every party. If you ask for 20 variables per party, the dataset will sum up to 120 variables – but therefore the evaluations of a party will always be saved into the same variables. The creation of that many questions might be more effortful but it’s also way easier to analyse. +
- +
-    * Create a category (e.g. “P1”) in your questionnaire, with all questions you want to ask about the first party. +
-    * In this option you can enter the party name directly into the question (and change it in every copy manually) or +
-    * Instead of entering the party name you can enter the [[:en:create:placeholders|placeholder]] ''%partei%'' and set it up using ''[[:en:create:functions:replace]]'', thus saving a lot of effort. +
-   * Create 5 copies of the category by downloading the category as an XML-file (Arrow down symbol in the toolbar above the question) and subsequently import it multiple times using //New Category//. In this example the copys will be labelled ''P2'' to ''P6''+
-  * Create a question of the type "Random generator" (in this example it is assumed to have the label ZG04). In the question, enter the following //ballots (contents)//  and at //Number of ballots per interview// enter the value 2. +
- +
-<code> +
-1 = CDU/CSU +
-2 = SPD +
-3 = Die Grünen +
-4 = Die Linke +
-5 = Piraten +
-6 = AfD +
-</code> +
- +
-Place the random generator under ** Create a Questionnaire ** on or before the first party question. +
- +
-If you are working with the placeholder ''%partei%'', you have to enter the following PHP-code at the begin of the two blocks: +
- +
-<code php> +
-$name = value('ZG04x01', 'label');  // At the second block then with ZG04x02 +
-replace('%partei%', $name); +
-</code> +
- +
-The questions have the labels ''P101'' for the first question about the first party (CDU/CSU), ''P201'' for the first question about the second party (SPD) etc. Now there are two possible ways to display the desired question. You could use an IF-filter (s. also [[:en:create:filters]]) or the label "assemble". The assembly is way more compact. If the question labels are not perfectly parallel (e.g. because an additional question should be shown for one of the parties) only one filter will work here. +
- +
-Place the following PHP-code where the corresponding question should be asked. So if you have 9 questions per party, place the code 9 times in the first partys block and 9 times in the second partys block. In the second block ''ZU04x01'' has to be replaced with ''ZU04x02''. The question labels have to be adapted in every PHP-code. +
- +
-=== PHP-code with assembly === +
- +
-<code php> +
-$code = value('ZG04x01'); +
-$kennung = 'P'.$code.'01';  // The point (.) connects strings (Texte) +
-question($kennung); +
-</code> +
- +
-=== PHP-code with filters === +
- +
-<code php> +
-$code = value('ZG04x01'); +
-if ($code == 1) { +
-  question('P101'); +
-} elseif ($code == 2) { +
-  question('P201'); +
-} elseif ($code == 3) { +
-  question('P301'); +
-} elseif ($code == 4) { +
-  question('P401'); +
-} elseif ($code == 5) { +
-  question('P501'); +
-} elseif ($code == 6) { +
-  question('P601'); +
-+
-</code> +
- +
- +
-==== Option 3 ==== +
- +
-Another option would be to place all questions to all parties in the questionnaire and to give labels to the pages (s. bellow e.g. "P1Begin", "P1End", "P2Begin", "P2End" etc.) and to subsequently work with ''[[:en:create:functions:setpageorder]]'', in order to show the fitting page blocks. +
- +
-This variant is more vulnerable to errors (e.g. that somebody forgets to answer a question) and makes the questionnaire confusing. The command ''[[:de:create:functions:setpageorder]]'' is quite useful to vary the order of question-blocks -- but there are more elegant solutions for the selection of stimuli or to skip pages. +
- +
-Due to the limited use, we only present some example PHP code on this option. If you still decide for this option, place the following PHP-code on the last page of the generic part (the part everybody has to answer the same way before the branching occurs). He will display the two party blocks separated by an intermediate part between them ("middleBegin" to "middleEnd") and continue to the page with the label "demografie". Again you have to place the PHP-code after placing the random generator as described above. +
- +
-<code php> +
-$pages = array(); +
-// Numeric code of the first party +
-$code1 = value('ZG01x01'); +
-// Write the fitting pages into the array +
-if ($code1 == 1) { +
-  $pages[] = 'P1Begin-P1End'; +
-} elseif ($code1 == 2) { +
-  $pages[] = 'P2Begin-P2End'; +
-} elseif ($code1 == 3) { +
-  $pages[] = 'P3Begin-P3End'; +
-} elseif ($code1 == 4) { +
-  $pages[] = 'P4Begin-P4End'; +
-} elseif ($code1 == 5) { +
-  $pages[] = 'P5Begin-P5End'; +
-} elseif ($code1 == 6) { +
-  $pages[] = 'P6Begin-P6End'; +
-+
-// Complement the pages fort he intermediarry part +
-$pages[] = 'middleBegin-middleEnd'; +
-// Numeric code of the second party +
-$code2 = value('ZG01x02'); +
-// Write the pages for the second party into the array +
-if ($code2 == 1) { +
-  $pages[] = 'P1Begin-P1End'; +
-} elseif ($code2 == 2) { +
-  $pages[] = 'P2Begin-P2End'; +
-} elseif ($code2 == 3) { +
-  $pages[] = 'P3Begin-P3End'; +
-} elseif ($code2 == 4) { +
-  $pages[] = 'P4Begin-P4End'; +
-} elseif ($code2 == 5) { +
-  $pages[] = 'P5Begin-P5End'; +
-} elseif ($code2 == 6) { +
-  $pages[] = 'P6Begin-P6End'; +
-+
-// Determine where it shall continue +
-$pages[] = 'demografie'; +
-// Set the page order +
-setPageOrder($pages); +
-</code> +
- +
-Also this PHP-code can be written more compact if the labels for the pages are "assembled": +
- +
-<code php> +
-$code1 = value('ZG01x01'); +
-$code2 = value('ZG01x02'); +
-setPageOrder( +
-  'P'.$code1.'Begin-P'.$code1-'End', +
-  'middleBegin-middleEnd', +
-  'P'.$code2.'Begin-P'.$code2-'End', +
-  'demografie' +
-); +
-</code> +
- +
-===== Example: Varying page sequence ===== +
-The questionaire of this example belongs to the “Within-Subject” experimental design. This means the questionnaire has a generic part, followed by some pages containing the first stimulus, followed by some puffer pages and some pages with the second stimulus. The sequence of the two units of stimuli should vary randomly. +
-==== Preperation ==== +
-  * Create a new question of the „random generator“ type (in the following case the question is named ZG02). Enter the following ballots (Note that file names can deviate from case to case.) into the question: +
-<code> +
-1 = experimentalgroup 1 +
-2 = experimentalgroup 2 +
-</code> +
-  * Give ID’s to the pages of the questionnaire using ** Create a questionnaire** ([[:en:glossary#page_ids|Page IDs]]). You can basically choose your ID’s freely, for this example the following ID’s where used: +
-  * The first Page which belongs to stimulus A receives the ID “beginA”. +
-  * The last Page which belongs to stimulus A receives the ID “endA”. +
-  * The first Page which belongs to the puffer pages receives the ID “beginMiddle”. +
-  * The last Page which belongs to the puffer pages receives the ID “endMiddle”. +
-  * The first Page which belongs to stimulus B receives the ID “beginB”. +
-  * The last Page which belongs to stimulus B receives the ID “endB”. +
-  * The first Page of the final part (which follows directly to “endB”) receives the ID “final”. +
- +
- +
-==== Application ==== +
- +
-Under **Create a Questionnaire** drag and drop the random generator to the last page of the generic part. The following page should respectively have the ID „beginA“. +
- +
-Place the following PHP-code beneath the random generator (s. auch [[:en:create:php]]). The order ''[[:en:create:functions:setpageorder]]'' provides that the pages appear in the desired sequence. +
- +
-<code php> +
-$code = value('ZG02'); +
-if ($code == 1) { +
-  // Keeps the normal sequence – it is possible to omit this order... +
-  setPageOrder('beginA-endA', 'beginMiddle-endMiddle', 'beginB-endB', 'final'); +
-} else { +
-  // Reverse sequence of the units A and B +
-  setPageOrder('beginB-endB', 'beginMiddle-endMiddle', 'beginA-endA', 'final'); +
-+
-</code> +
- +
- +
-===== Readjust the Drawings ===== +
- +
-If one works with many experimental groups, it is possible that the actually successful equal distribution is lost due to removals required by data cleaning. Especially if the number of cases per group is very small, the cases that have to be removed (e.g. as a result of the manipulation check) may cause a substantial tilt. Then it may be necessary to adjust the random number generator slightly during the survey. +
- +
-**Warning:** The random selection should be readjusted __only__ if the participants are continuously recruited from the same population. Otherwise there is a danger of confounding: Imagine an experiment with 4 groups, in which the participants are all invited on a certain day. After two thirds of the participants have completed the questionnaire, one notices that a lot of cases in group 1 are invalid, and the random generator is readjusted. So from now on more participants will be assigned to group 1. Now there is a confounding, because participants who respond to an invitation later can systematically differ from participants who respond quickly. So the 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 solely due to the experimental stimulus. +
- +
-**Tip:** In a situation where you can't adjust the random drawing afterwards, you can use an [[:en:create:random_urns|Urn]]] and configure ''urnDraw()'' to store the codes manually. The manual filing with ''[[:en:create:functions:urnputaway]]'' is done after checking with a [[:de:create:filters|filter]] that the case is usable. Disadvantages: This is comparatively difficult and there can be considerably unequal group sizes especially at the beginning of the survey. +
- +
-If the conditions for readjustment (see above) are fulfilled, the procedure is as follows: +
- +
-  - The preliminary data set is cleaned up (dropout, missing answers, manipulation check, no consent to the use of the data, ...). +
-  - A frequency table of the random generator variable is created.+
   - This frequency table is converted into a format ''Code: Number'' (see below).   - This frequency table is converted into a format ''Code: Number'' (see below).
-  - This list is drawn into the field //drawn so far// in the random generator -- the order of the values does not matter, the only important thing is that code and number are contained.+  - This list is entered in the random generator into the field //Previously drawn// -- the order of the values does not matter, it is only important that code and number are included in each case.
   - After saving, the list is automatically sorted and further random draws are made in such a way that previous inequalities are compensated.   - After saving, the list is automatically sorted and further random draws are made in such a way that previous inequalities are compensated.
  
-The list of codes and usable cases can look like this:+For example, the list of codes and usable cases may look like the following:
  
 <code> <code>
Line 399: Line 92:
 </code> </code>
  
-In Excel or OpenOffice Calc, such a list is created by combining the previously created frequency table (with codes, not labels) with the following function (if the codes are in column A and the frequencies are in column B):+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):
  
 <code excel> <code excel>
-=CONCAT(A1; ": "; B1)+=CONCATENATE(A1; ": "; B1)
 </code> </code>
          
-In GNU R you can output the frequency table and the list as follows (if the variable of the random generator is e.g. RG01):+In GNU R you can output frequency table and list as follows (if the variable of the random generator is called e.g. RG01):
  
 <code r> <code r>
Line 411: Line 104:
 cat(paste(paste(names(tmp), tmp, sep=": "), collapse="\n")) cat(paste(paste(names(tmp), tmp, sep=": "), collapse="\n"))
 </code> </code>
 +
 +
 +
 +
en/create/questions/random.txt · Last modified: 07.12.2023 07:03 by admin
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki