...
</item>
There are also corresponding items for "losses" and "certains".
Then I use the "text" command to present these items values on screen and I link the loss values with the win values (and also the certain values with the win values so they come as a trio):
<text gambles_win>
/items = gambles_win
/position = (20, 20)
/txcolor = (0,255,0)
/select = noreplace
/ fontstyle = ("Arial", 10%)
</text>
<text gambles_certain>
/items = gambles_certain
/select = text.gambles_win.currentindex
/position = (70, 45)
/txcolor = (0,0, 255)
/ fontstyle = ("Arial", 10%)
</text>
<text gambles_loss>
/items = gambles_loss
/select = text.gambles_win.currentindex
/position = (20, 65)
/txcolor = (255,0,0)
/ fontstyle = ("Arial", 10%)
</text>
So far, I think everything is fine. Maybe it is the trial specification that is the problem. At the beginning of each trial, I set the values for win, loss, and certain to match whatever I'm presenting on screen. The "values.outcome" determines whether the participant will win or lose the bet if they choose to take it. At the end of each trial, I update the "balance" by adding the appropriate value.
<trial gambles>
/stimulusframes = [1 = running_total; 10 = gambles_win, gambles_loss, gambles_certain]
/ontrialbegin = [values.outcome = counter.flip_coin.selectedvalue]
/ontrialbegin = [values.win = text.gambles_win.currentitem]
/ontrialbegin = [values.loss = text.gambles_loss.currentitem]
/ontrialbegin = [values.certain = text.gambles_certain.currentitem]
... (bunch of other trial specifications)
/ ontrialend = [if(trial.gambles.response == 30 && values.outcome == 1)
{values.balance = values.balance + values.win}]
/ ontrialend = [if(trial.gambles.response == 30 && values.outcome == 0)
{values.balance = values.balance + values.loss}]
/ ontrialend = [if(trial.gambles.response == 38)
{values.balance = values.balance + 0}]
</trial>
Lastly, I create a data output file:
<data loss_aversion_data>
/ file = "LA_data.iqdat"
/ columns = [date, time, subject, values.outcome, values.balance, values.win, values.loss, values.certain, response]
/ separatefiles = true
</data>
The values.balance column (as far as I can tell) reflects what the balance is at the *end* of the trial. This looks straightforward to me so I don't think it's the source of the problem but I welcome your input.