Good day,
I am running an experiment online on Pavlovia and I experience the following error quite often but not always:
I have two experimental groups who should entail max. 10 persons per group, thus 20 people in total. For about 2-4 participants in a row, counterbalancing works fine without any error code. After that, I receive the error code which is displayed in the screenshot. I do receive the error code before the limit of participants in the groups is reached and also, when only one person tries to run the experiment at a time.
Currently, my workaround is to set the shelf back to 0 on a daily basis. Thus, that at about 2 participants can complete the study until the next day. However, this does not work for larger studies for me, so I am trying to figure out a solution.
Thanks a lot in advance!
Best,
Jule
Hi,
I’ve just written an alternative method for counterbalancing online. It still uses the Pavlovia Shelf but uses code instead of the counterbalance routine. The shelf entry is a single list which should be created as a list of one more zeros than the number of groups.
The code is in two parts. Firstly in Begin Routine of the first routine after consent (if you have a consent question or embedded survey).
groupAllocations = await psychoJS.shelf.getListValue({key: ["group_allocations"]}); // Get values
groupAllocations[0] += 1; // Add 1 for current session number
expInfo["session"] = groupAllocations[0];
psychoJS.shelf.setListValue({key: ["group_allocations"], value: groupAllocations}) // Await not needed when storing
minAllocation = Math.min(...groupAllocations); // ... needed to indicate groupAllocations is a list
availableGroups = []; // Define list
for (var Idx, _pj_c = 0, _pj_a = util.range(1, groupAllocations.length), _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
Idx = _pj_a[_pj_c];
if ((groupAllocations[Idx] < (minAllocation + 3))) { // + 3 means groups can become 3 apart after allocation
availableGroups.push(Idx);
}
}
util.shuffle(availableGroups);
group = availableGroups[0]; // group takes positive integer values
Note that the value of group is not available in Begin Experiment code if the allocation is in Begin Routine.
The second code snippet goes either in End Routine of the final routine or in End Experiment (if you are including incomplete data saved by pressing the escape key twice).
// If this code is in End Experiment, aborted sessions will count if escape is pressed twice.
// To avoid counting any aborted sessions, this code should be in End Routine of the final routine.
groupAllocations = await psychoJS.shelf.getListValue({key: ["group_allocations"]}); // Update list from shelf
groupAllocations[group] += 1;
await psychoJS.shelf.setListValue({key: ["group_allocations"], value: groupAllocations}) // Await needed here
An alternative to the counterbalance routine which stores a list on the shelf (with one more entry than the number of groups). The first entry is used to count the number of sessions started. Each participant is allocated randomly to a group with no more than 2 more than the current stored minimum number of allocations. Allocations are stored either in End Experiment or End Routine of the final routine, depending on whether you want to include participants with incomplete results. This method is not suitable if a significant proportion of the participants are likely to start the study at the same time.
2 Likes