Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Randomly select some trials from two distinct groups

Hi there,

I am trying to set up a very simple experiment but I stuck in a practical issue. I am supposed to ask my participants to indicate whether a pair of words are opposites or not. I am planning to present two sets of pairs. The first set will refer to certain adjectives (e.g., competent - incompetent) and the other set will refer to emotions (e.g., happy - sad) and colors (e.g., black - white). There are a lot of pairs and I want to randomly show my participants, some but not all the pairs. Say, that I want to show them 10 pairs. But, I want seven out of these 10 pairs (i.e., 70%) to come from the first set and the remaining three (i.e., 30%) of the pairs to come from the second set. Although I tried to find a solution from the discussion forum or from the instructions in opensesame page (for example by using the command "slice" or through "weighing") I could not find a way how to address this issue. I would appreciate any assistance.

Best regards

PS. this is an exploratory study so there is not necessarily a "correct answer". I only want to see how people construe specific pairs of adjectives and I want to include pairs of emotions or colors as "manipulation checks". As can be seen below the example of my block loop is quite simple:


Comments

  • Hi @thanmour ,


    Is it possible to upload your experiment here? And will you be running your study online or locally?


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Dear Lotje,

    First, I am sorry for my delayed reaction. And second, I thank you a lot for your consideration. I have just prepared the experiment, which includes 212 pairs of adjectives or phrases. I am planning to ask from participants to randomly rate 10% of them (about 20 pairs) whether they are opposites or not (there is no right or wrong answer for that - I only want to assess how they construe meanings that they might be (or might not be) opposites. Among those 20 pairs, however, I want 10 (i.e., 50%) of them to be randomly chosen from a certain block of the list, 5 (i.e., 25%) of them to be randomly chosen from another block from the list, and the remaining ones (i.e., 25%) from a third block. To ease the "blocking", I added a column called "my_class". There, the first 150 entries (rows) are classified as "a", the next 35 entries as "b" and the remaining ones as "c". So, my question is how I can make the experiment proportionally select (randomly) 10 entries from "a", 5 from "b", and "5" from c.

    About how to run the study, I am planning to run it online. (But still have a

    problem setting up a follow-up survey)

  • Hi @thanmour ,


    And I guess you want the pairs from the different classes to be mixed, right? Or can you first show 10 items from class "a", then 5 from class "b" and 5 from class "c"?


    Regarding the survey, these links might be useful:



    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi Lotje,

    Indeed, I want them to be randomly presented in a mixed fashion (say, a, a, a, b, b, c, a, b, c, c, a, a, a, b, etc.)

    About the links, thanks a lot. I was aware of the first two, but I think the one which makes a great difference and was really missing was the youtube video. It is amazingly clear !!! Thanks a lot for that and congrats on whoever has prepared it!

  • Hi @thanmour ,


    I'll get back to you shortly.


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • edited March 2021

    Hi @thanmour ,


    It took me a while to figure this one out, but I think the following solution will work. It might not be the most elegant way, and requires some JavaScript, but I think otherwise your implementation is not possible with OSWeb.


    • First, define the lists of words in the Prepare tab of an inline_javascript item (instead of in the block_loop) at the beginning of your experiment (see comments for some explanation):
    // Define trial information as arrays:
    // I used the following order: correct_response, word1, word2, class
    
    var array_A = [["correct_response1", "A1_word1", "A1_word2", "A"], 
                    ["correct_response1", "A2_word1", "A2_word2", "A"],
                    ["correct_response2", "A3_word1", "A3_word2", "A"],
                    ["correct_response2", "A4_word1", "A4_word2", "A"]]
                    
                    
    var array_B = [["correct_response1", "B1_word1", "B1_word2", "B"], 
                    ["correct_response1", "B2_word1", "B2_word2", "B"],
                    ["correct_response2", "B3_word1", "B3_word2", "B"],
                    ["correct_response2", "B4_word1", "B4_word2", "B"]]
    
    
    var array_C = [["correct_response1", "C1_word1", "C1_word2", "C"], 
                    ["correct_response1", "C2_word1", "C2_word2", "C"],
                    ["correct_response2", "C3_word1", "C3_word2", "C"],
                    ["correct_response2", "C4_word1", "C4_word2", "C"]]
    
    // A function for selecting without replacement from a given list:
    function getRandomItem(my_array) {
        var randomIndex = Math.floor(Math.random()*my_array.length);
        return my_array.splice(randomIndex, 1)[0];
    }
    
    
    
    // Define the number of instances of A, B and C:
    var n_A = 3
    var n_B = 2
    var n_C = 1
    
    var array_final = []
    
    // Fill the final array with a selection of A-items:
    for (let i = 0; i < n_A; i++) {
        // Get a random item from the A list:
        var a = getRandomItem(array_A)
        // And append it to the array
        array_final.push(a)
    }
    
    
    // Fill the final array with a selection of B-items:
    for (let i = 0; i < n_B; i++) {
        // Get a random item from the B list:
        var b = getRandomItem(array_B)
        // And append it to the array
        array_final.push(b)
    }
    
    // Fill the final array with a selection of B-items:
    for (let i = 0; i < n_C; i++) {
        // Get a random item from the C list:
        var c = getRandomItem(array_C)
        // And append it to the array
        array_final.push(c)
    }
    
    
    // Store the final array in the vars object so that we can use it in
    // subsequent inline_javascript items:
    vars.array_final = array_final
    
    • Note that you have to change the content of the arrays (obviously), but also the number of A's, B's and C's that the experiment should contain (as defined by the variables n_A, n_B, and n_C).
    • Append another inline_script item, this time to the beginning of the trial_sequence, and place something like the following in the Prepare tab:
    // Again, define the function for random selection without replacement:
    
    function getRandomItem(my_array) {
        var randomIndex = Math.floor(Math.random()*my_array.length);
        return my_array.splice(randomIndex, 1)[0];
    }
    
    // Randomly choose the item for the current trial:
    vars.current_trial = getRandomItem(vars.array_final)
    
    
    // Unpack the trial information:
    vars.correct_response = vars.current_trial[0]
    vars.word1 = vars.current_trial[1]
    vars.word2 = vars.current_trial[2]
    vars.class_of_item = vars.current_trial[3]
    
    console.log(vars.class_of_item)
    
    • Make sure to set the Repeat value in the block_loop to the correct number of trials. (The number of trials should be the sum of the number of instances of A, B and C, as you defined in the inline_javascript item called "define_lists".

    The overview of your experiment should now look like this:

    I uploaded an example script.

    I hope this helps!


    Cheers,


    Lotje


    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Thanks a lot, Lotje!

    I am almost there. But still, after the "practice loop", I get an error message. Is there something that I can do about it?

    Also, should the var array_A include "correct_response1" or "correct_response2"? Is there any particular reason for including these two options (and not just keeping it as "correct_response")?

  • HI @thanmour ,


    Sorry for the late reply! I didn't know which response ("p" or "q" belonged to which trial, which is why I used dummy names ("correct_response1" and "correct_response2"). But they indeed should be changed.


    Could you upload the current version of your experiment that gives the above error message?


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hi Lotje,

    I am attaching the experiment as you prepared it. Everything goes perfectly in the first block but it stucks in the second block. I tried dozens of different solutions but at no avail.

    Kind regards


  • Hi @thanmour ,


    Oops, sorry about that. The lists had to be redefined at the beginning of the experimental phase (this time in the Run tab of an inline_javascript item. I attached the new version.


    Could you check whether it works as desired now?


    Cheers,


    Lotje


    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Yes! Now it works perfectly! So, it needed a new inline_script in the end of Block A to redefine it. Now I've got it. Thanks, Lotje!!!

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games