jsPsych / Behavioral experimentsRead · predict · build · inspect

Meeting 2: predict, run, explain

These short activities connect the slides to the full workshop. They are ungraded. Use one as a five-minute class demonstration; use the other for a warm-up or independent practice. They replace part of the existing demonstration time.

Before every run, write one prediction. Afterward, record one row or screen that supports or contradicts it. Then make one change and explain the result without reading the code aloud.

1. One procedure, different items.

Open the editable example. The editor supplies startup and output code so you can focus on the experiment. Expand Supplied setup and run lines to see those lines; downloaded JS includes them.

Predict: Will randomizing the order change the number of items?

Change and test: Switch randomize_order to false. Then add a third item with its own item_id and expected key.

Inspect: The displayed target, saved item ID, expected key, and observed response should agree.

Write three short notes:

2. Which rows belong in the mean?

Open the editable example. The editor supplies startup and output code so you can focus on the experiment. Expand Supplied setup and run lines to see those lines; downloaded JS includes them.

Predict: Calculate accuracy and mean correct RT before running this code.

Change and test: Change every correct value to false. What should the mean become? Restore the example, then compute separate condition means.

Inspect: Incorrect responses and omissions stay in the accuracy denominator. Neither enters the correct-response RT mean.

Write three short notes:

Transfer to the workshop

In the Stroop starter, explain how to add two balanced items without copying the response trial. Choose one row and reconstruct its expected response from its word, ink, and mapping. State both summary denominators.

Diagnose one fault

A summary averages rt over every row in the export.

Explain the cause and the smallest useful test. Do this before reading the check below.

Check your reasoning after an attempt

Example 1: Randomization changes order, not the supplied item counts. Each item supplies values to one pass of the procedure. Scoring runs after the response exists.

Example 2: Accuracy is 4/8 = 50%. Mean correct RT is (500 + 700 + 900 + 1100)/4 = 800 ms. Condition means are 600 and 1000 ms. With no correct rows, meanRT is null, not zero.

Fault: Instruction, fixation, wrong-response, and omission rows do not belong in the mean correct-response RT. Filter task/block, then correct finite RTs; report N/A for an empty eligible subset.

Keep a useful record

Download edited JS if you want to keep your change; a reset or refresh replaces it. For experiment examples, download JSON after the run. Source packs include HTML, the initializer, libraries, and assets: small-example source pack. These files are for learning; the workshop remains the core task.