Today we are going to program a simple Implicit Association Task based on Experiments 1 and 2 of Greenwald & Farnham (2000). We will use the 5 me and 5 not-me items from Experiment 2, and 5 positive affect and 5 negative affect items from Experiment 1. The core of an IAT is quite similar to the tasks we have programmed previously, the basic procedure is that an item is presented on the screen (in this case a word), and the participant has to use the keyboard to indicate which category it belongs to (e.g. self vs. other; positive vs. negative). At some point in the Experiment this categorisation then switches for one of the grouping (i.e. for the me/not-me or affect categorisation). Some of the main differences this week compared to the previous Experiments we have programmed are:
If you have time you will also learn how to:
Like every week we are going to start a new Inquisit file for this weeks exercises. Call this file surname_wpa7.iqx. This is the file you will send me at the end of the class. I strongly recommend that you copy the defaults element from last weeks script into the top of this file, so that you have an easy way to terminate the Experiment.
The stimuli we will use are taken from the appendix of Greenwald & Farnham (2000), simply choose the 5 self and 5 other identifiers from Experiment 2, adn the top 5 positive and negative affect words from Experiment 1.
We want to define different correct and error responses for self and other words, and for positive and negative words. We also need to be able to create trials with only affect words or only me/not-me words. Usually to do this we would create 4 separate item sets; self, other, positive affect and negative affect. However this week we are going to learn a different way to specify correct responses. The advantage of this method is that it is much easier to then create the reversed association sections of the IAT.
For this method we will only need 2 item sets, one for the me/not-me items, and one for the affect items. first create these 2 lists.
<item me>
/1="I"
/2="me"
/3="my"
/4="mine"
/5="self"
/6="they"
/7="them"
/8="their"
/9="theirs"
/10="other"
</item>
<item affect>
/1="caress"
/2="cuddle"
/3="diamond"
/4="glory"
/5="gold"
/1="abuse"
/2="agony"
/3="assault"
/4="brutal"
/5="corpse"
</item>
Now create text elements to present these two types of items. Present them in the center of the screen. How does selection between self and other items occur in the Experiment? How should selection occur for the text element?
Within me/not-me trials self and other items are selected randomly without replacement, so you should use no replace for the select method. The same applies to the affect trials.
<text me>
/items=me
/position = (50%, 50%)
/hjustify = center
/fontstyle=("Arial", 5%)
/select=noreplace
</text>
<text affect>
/items=affect
/position = (50%, 50%)
/hjustify = center
/fontstyle=("Arial", 5%)
/select=noreplace
</text>
To start with we’ll define a trial for presenting the me/not-me stimuli.
First create a normal trial type where a random me/not-me stimuli is presented on the screen, and participants can respond either with the “A” key or with the “L” key. For now, set the “A” key as the correct response for every trial. Include a break of 200ms between trials.
<trial me>
/stimulustimes = [0=me]
/validresponse = ("a", "l")
/correctresponse = ("a")
/pretrialpause=200
</trial>
Also create a Block element so that this trial is run 10 times. This will be useful for testing our code.
<block me>
/trials=[1-10=me]
</block>
If you run this trial now, by default it will end when you press either the “A” or the “L” key (like every other time we have used this set up). However, in the IAT we wnat to allow participants to press the incorrect key (here “L”), but not end the trial until they press the correct key (“A”). To do this we need to look at the response attribute of the trial element. The response attribute specifies how a response is obtained for this trial. This isn’t referring to what responses are considered valid, but instead to what is considered a response that can end the trial.
There are several ways you can specify this response, we are going to specify a responsemode. There are 4 different responsemodes. Based on what we want to achieve (i.e. the trial continues if the incorrect key is pressed, but stops if the correct key is pressed) which response mode should we specify? Try it.
<trial me>
/stimulustimes = [0=me]
/validresponse = ("a", "l")
/correctresponse = ("a")
/response=correct
/pretrialpause=200
</trial>
By specifying response as correct, the trial will only end on a correct response. You might have also been tempted to just set "A" as the only validresponse to achieve this same outcome. While this would look similar when doing the task, the problem is that "L" responses would be completely ignored. We want these responses to be recorded as mistakes (which setting the validresponse attribute to both "A" and "L" allows), but for them to not end the trial.
Currently it doesn’t matter whether a self or other word is displayed, in both cases the correct response is to press “A”. What we can do however is instead set the correct response to be “A” if it is one of the first 5 items from our me/not-me set (i.e. Self items), and “L” if it is one of the last 5 items (i.e. Other items). IF you look at the trial helpfile again, you will see another means of specifying the correct response, called iscorrectresponse. This allows us to use a logical expression as correctresponse. If this expression is evaluated to be TRUE, then the response is cosidered correct. If it is FALSE, the response is incorrect.
So we need to come up with a logical Expression that is true if either; A is pressed and it is one of the first 5 items OR L is pressed and it is one of the second 5 items.
To do this we need to be able to retrieve the current response for the trial. Remember that reponse is a variable associated with the trial that records exactly this. Whas the code for accessing this for the trial “me”?
trial.me.response
Remember you need the element type, element name, and variable name.
Also remember that an "A" response is recorded as the number 30, and a "L" response as the number 38, because they are stored as keycodes.
We also need to know what item has been currently sampled by our call to text. We have accessed this information before when we were linking our stimulus pairs in the masked priming task. Check the code for that task if you can’t remember.
text.me.currentindex
Now create a logical expression that evaluates to true if A is pressed and the current stimuli is one of the first 5.
(trial.me.response==30&&text.me.currentindex<6)
Remember to use two "=" signs.
By linking our 2 expressions with && we insure it is only treated as true if both are true.
Now add the second part of the Expression for the other trials. They should be linked with an or statement.
(trial.me.response==30&&text.me.currentindex<6)||(trial.me.response==38&&text.me.currentindex>5)
Make sure you include the brackets so that it correctly interprets the and and or expressions.
Now replace the correctresponse attribute with the iscorrectresponse attribute (with the appropriate expression), in your trial element.
<trial me>
/stimulustimes = [0=me]
/validresponse = ("a", "l")
/iscorrectresponse = [(trial.me.response==30&&text.me.currentindex<6)||(trial.me.response==38&&text.me.currentindex>5)]
/response=correct
/pretrialpause=200
</trial>
Now at the end of this block we want to display to participants there accuracy for the trial, as a percentage, and the mean time it took them to respond. We are going to do this by creating custom variables (see week 5) called accuracy and rt to store these two values. These variables will be populated with the appropriate values at the end of the block, then displayed as a single trial in a new block.
First create these two variables in the values element. Set them both to 0 to begin with.
<values>
/accuracy=0
/rt=0
</values>
Now create a new trial, that will display these values as a text element in the middle of the screen. First create the text element, It should read **“You got X% of items correct and took on average Yms. Press spacebar to continue”. With X and Y replaced by Expressions for retriving the accuracy and the mean rt respectively. Remember that in text expressions need to be in encased in <% expression %>
<text acc>
/items=("You got <%values.accuracy%> % of items correct and took on average <%values.rt%> ms
Press spacebar to continue")
/position = (50%, 50%)
/hjustify = center
/fontstyle=("Arial", 5%)
/select=noreplace
</text>
Now create a trial to display this text. Have the trial end when the participant presses the spacebar.
<trial Report>
/ stimulustimes = [0=acc]
/correctresponse = (" ")
/validresponse = (" ")
</trial>
Finally create a block to display this trial, and create an expt to run both blocks.
<block Report>
/trials = [1=Report]
</block>
<expt>
/blocks=[1=me; 2=Report]
</expt>
Now use the onblockend attribute to update our placeholder accuracy and mean rt, with the actual accuracy and mean rt for that block. To do this we need to know how to retrieve the accuracy and mean rts from a block. Each block has a variable called percentcorrect which stores the running total of the percent of trials participants have answered correctly, and a variable called meanlatency which is the running mean rt for the block. What would be the full variable names for these variables in the me block?
block.me.percentcorrect and block.me.meanlatency
Now use these variables
<block me>
/trials=[1-10=me]
/onblockend = [values.accuracy = block.me.percentcorrect; values.rt = block.me.meanlatency]
</block>
if you want multiple actions to be performed in a single onblockend call, separate them with ;.
If you want to find other block level variables, have a look at the columns help file.
Now we need to create the same set-up for the affect items. If you look at figure 1 in the paper,you’ll see the basic set-up for an IAT. You can see that there is one section of the test (steps 1-3) where the positive words have a response that matches the self words (i.e. responding “A”), and a section (Steps 4-5) where this association is reversed, with instead negative words associated with self (by having the same response “A”).
We will implement all 5 steps. So far we have step 1.
First we will create steps 2 and 3.To do this you’ll need to setup new trial and block elements where a random affect stimuli is shown, and responding “A” for positive stimuli is correct and “L” for negative stimuli is correct. Create these now (you should know how for the section on m/not-me items).
<trial foraffect>
/stimulustimes = [0=affect]
/validresponse = ("a", "l")
/iscorrectresponse = [(trial.foraffect.response==30&&text.affect.currentindex<6)||(trial.foraffectaa.response==38&&text.affect.currentindex>5)]
/response=correct
/pretrialpause=200
</trial>
Because the direction of responding is the same, this is identical to the trial me element, except for stimulustimes , and the trial names in the iscorrectresponse expression.
<block foraffect>
/trials=[1-10=foraffect]
/onblockend = [values.accuracy = block.foraffect.percentcorrect; values.rt = block.foraffect.meanlatency]
</block>
Also very similar to the me block. Make sure you include the onblockend attribute so that our results page is updated correctly.
Now add this block to our expt element, so that Steps 1 and 2 are displayed.
<expt>
/blocks=[1=me; 2=Report; 3=foraffect; 4=Report]
</expt>
IMPORTANT: remember to include the Report block so that the accuracy for this new block is also shown.
Now we want to create a block where alternating affect and me trials are shown. We already have our me and affect trial elements created. So All we need to do is create a new block, which alternates the 2 trial types. How can we make them alternate?
Think of the different ways you can specify selection of trials/stimuli.
<block forall>
/trials=[1-20=sequence(me, foraffect)]
/onblockend = [values.accuracy = block.forall.percentcorrect; values.rt = block.forall.meanlatency]
</block>
Using sequence will make them alternate trials, with odd trials using me and even trials affect. Remember to update the accuracy adn rt values.
Does this work? What are we forgetting?
Remember these blocks need to be added to the Experiment as well.
<expt>
/blocks=[1=me; 2=Report; 3=foraffect; 4=Report; 5=forall; 6=Report]
</expt>
Now we want to create steps 4 and 5, where the responses are reversed for the affect trials. What do we need to do to achieve this?
You need to create a new trial element, where the iscorrectresponse expression has the opposite association between response value and item number.
<trial revaffect>
/stimulustimes = [0=affect]
/validresponse = ("a", "l")
/iscorrectresponse = [(trial.revaffect.response==38&&text.affect.currentindex<6)||(trial.revaffect.response==30&&text.affect.currentindex>5)]
/response=correct
/pretrialpause=200
</trial>
Now that you have the new trial type, it is easy to create the final working version of the Experiment. What do you need to do to achieve this? Try it.
Create a block element for the reversed affect trails to be displayed, and a block element for the reversed affect trils to be alternated with metrials
<block revaffect>
/trials=[1-10=revaffect]
/onblockend = [values.accuracy = block.revaffect.percentcorrect; values.rt = block.revaffect.meanlatency]
</block>
<block revall>
/trials=[1-20=sequence(me, revaffect)]
/onblockend = [values.accuracy = block.revall.percentcorrect; values.rt = block.revall.meanlatency]
</block>
Finally these need to be added to the Experiment (including the Report blocks)
<expt>
/blocks=[1=me; 2=Report; 3=foraffect; 4=Report; 5=forall; 6=Report; 7=revaffect; 8=Report; 9=revall; 10=Report]
</expt>
The Experimenters wanted to counterbalance the order of steps 2-3 and 4-5 (i.e. whether the positive self or negative self associations were shown first). Do this accross participants.
You need a second expt element, with the reversed order, and the subjects attribute for selecting which order to use based on the participants ID number.
<expt>
/blocks=[1=me; 2=Report; 3=foraffect; 4=Report; 5=forall; 6=Report; 7=revaffect; 8=Report; 9=revall; 10=Report]
/ subjects = (1 of 2)
</expt>
<expt>
/blocks=[1=me; 2=Report; 3=revaffect; 4=Report; 5=frevall; 6=Report; 7=foraffect; 8=Report; 9=rforall; 10=Report]
/ subjects = (2 of 2)
</expt>
One aspect of the task we haven’t implemented is the fact that each participant could indicate a subset of the affect list to be used. This was a means of insuring that the words were actually negative or positive for the participants. we can also implement this kind of selection in Inquisit. We are going to implement a procedure where the participnt has to pick 5 words for a list to create the positive affect items, and 5 words form another list to create the negative affect items.
To learn how to do this, Inquisit has a useful help page. As this is an advanced question, I’m not going to go into detail. I also strongly suggest you see if you can work it out yourself before reading the code. The basic procedure is to first create an empty item element, that we will populate during the Experiment with items.
<item ideoaffect>
</item>
Then to present the participant with a surveypage with two questions presented. The first will ask them to select 5 words form a provided list that have a positive associated. The second will ask them to select 5 words from different list that have a negative association. Remember we used the slider element last week, which was a type of questions element. To present lists where participants select one or more items, you instead use a checkbox element. Make sure that participants can indicate only 5 items for each checkbox.
<checkboxes positive>
/ caption = "Select five words that are positive"
/ options = ("caress", "cuddle", "diamond", "glory", "gold", "health")
/ range = (5, 5)
</checkboxes>
Range lets you set the minimum and maximum number of items participants can select. You could also have more than 6 items.
<checkboxes negative>
/ caption = "Select five words that are negative:"
/ options = ("abuse", "agony", "assault", "brutal", "corpse", "death")
/ range = (5, 5)
</checkboxes>
Now these questions need to be presented on a surveypage. Then the answers need to be converted into items in the list (Hint it uses ontrialend in a similar way to how we have assigned variables before)
<surveypage page1>
/ questions = [1=positive; 2=negative]
/ ontrialend = [ if (checkboxes.positive.checked.1 == true) item.ideoaffect.item = checkboxes.positive.option.1 ]
/ ontrialend = [ if (checkboxes.positive.checked.2 == true) item.ideoaffect.item = checkboxes.positive.option.2 ]
/ ontrialend = [ if (checkboxes.positive.checked.3 == true) item.ideoaffect.item = checkboxes.positive.option.3 ]
/ ontrialend = [ if (checkboxes.positive.checked.4 == true) item.ideoaffect.item = checkboxes.positive.option.4 ]
/ ontrialend = [ if (checkboxes.positive.checked.5 == true) item.ideoaffect.item = checkboxes.positive.option.5 ]
/ ontrialend = [ if (checkboxes.positive.checked.6 == true) item.ideoaffect.item = checkboxes.positive.option.6 ]
/ ontrialend = [ if (checkboxes.negative.checked.1 == true) item.ideoaffect.item = checkboxes.negative.option.1 ]
/ ontrialend = [ if (checkboxes.negative.checked.2 == true) item.ideoaffect.item = checkboxes.negative.option.2 ]
/ ontrialend = [ if (checkboxes.negative.checked.3 == true) item.ideoaffect.item = checkboxes.negative.option.3 ]
/ ontrialend = [ if (checkboxes.negative.checked.4 == true) item.ideoaffect.item = checkboxes.negative.option.4 ]
/ ontrialend = [ if (checkboxes.negative.checked.5 == true) item.ideoaffect.item = checkboxes.negative.option.5 ]
/ ontrialend = [ if (checkboxes.negative.checked.6 == true) item.ideoaffect.item = checkboxes.negative.option.6 ]
</surveypage>
Finally the item list can be used like any other item list in text, trial block etc. elements.
We created two trial types for the two directions of the Affect response. Do you think you could achieve this with a single trial type, by using custom values and the onblockbegin attribute? See if you can work out how.