Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CCN Assignment 2

Computational modelling of behavioural data

Spring 2022

Practicalities

Deadline is Monday, March 28 2022 at 4 pm (standard late policies apply). Please submit your report as

single PDF on Learn.

●  Please keep your submission anonymous.  The submission should be no longer than 6 pages.  Refer- ences, appendices and code do not count toward this limit.

● You do have to include code in your report.  Please attach it to your PDF as an appendix in the same way you did for Assignment 1.

●  Plots should always include axes labels and units.   Figures should always have a caption and be referenced in the text. The presentation and format will count 10% of the final mark. Note that using default settings for plots is probably not the best idea (e.g. the line-widths are often too thin).

●  Show your work. If there are more than one (sensible) ways to calculate something be sure to describe how you did it.  Be concise and precise in how you report your results.  Don’t include lots and lots of separate graphs: you can superimpose different graphs in the same plot.

●  Copying results is not allowed.  It is okay to ask for help from your friends.  However, this help must not extend to copying code or written text that your friend has written, or that you and your friend have written together. You are assessed you on the basis of what you are able to do by yourself. If you are found to have done so, a penalty will be assessed against you as well.

● Your programming style will not be assessed but your code should be readable/decipherable in a reasonable amount of time.  If your code is incorrect, you may still be able to get points by realising that the results are not correct and describing how you think they should look like.

● It is recommended that you try to complete the tasks in the order they are given.   Please clearly indicate which question you are answering in your report.

● If something is not clear please create a new post on Piazza so that the answer can be shared with all the other students. If you are unsure whether your question can be shared with all the students, you can create a private Piazza question which, in case, can be made public by the course staff.

Marks for Style of Presentation (10 marks)

You should present your findings in the style of a scientific report. By this we mean that the document should include text broken into appropriate sections (e.g., by question number and/or topic), equations (if relevant), figures (with axes clearly labeled, font size similar to the font in the main text, with figure captions to explain their content, and with numbering/lettering of figures and subpanels in order to refer to them from the main text), and references (if relevant).  You should consider how to best communicate your findings in a clear and concise way to the reader. This includes designing figures appropriately, for example by making use of subplots and plotting multiple things on the same graph to save space or for aid of visual comparison, setting the axis limits appropriately, using figure legends and colour schemes to delineate different things plotted on the same graph, etc.  There is no need to aim for a 6 page report if you can convey your findings more succinctly, and marks may be deducted if you provide excessively long-winded, incoherent, or unstructured answers.  To take these factors into account, 10 marks have been allocated for the quality of presentation with regards to the overall layout and style, the quality of figures, and the scientific clarity and precision of written answers.

Assignment (90 points)

Intuitively, anxiety is related to worry and being pessimistic about negative events occurring in the future. In this assignment we are interested in understanding whether participants with anxiety differ in how they learn to predict negative events, in the context of a reinforcement learning task. We will focus on modelling behavioural impairments during a probabilistic reversal learning task inspired by an experiment conducted by Andrea D’Olimpio as part of his Masters by Research in the Seri`es’ Lab. In this experiment, participants had to perform an avoidance learning task composed by two parts: a Pavlovian phase and an instrumental phase.  The participants were recruited from the general population as those who self-identified as either anxious or calm. All participants were asked, prior to the beginning of the task, to complete the State-Trait Anxiety Inventory (Spielberger et al.1999), form Y, a commonly used questionnaire to assess anxiety levels. This questionnaire1  consists of two different forms, form Y1 and Y2 which measure, respectively, state and trait anxiety. The values of each form range from 20 (not anxious) to 80 (very anxious).

During the task, participants were asked to choose between two stimuli so that, at each trial, one stimulus

would lead to a loud unpleasant noise (i.e., an aversive outcome) whereas the other would lead to a neutral outcome (i.e., no sound). During the Pavlovian phase, the computer would choose the stimulus at each trial

and  subjects  would  only  observe.   In  the  instrumental  phase,  participants  were  asked  to  make  their  own

choices to maximise their changes of avoiding the aversive outcome.

Introduction

You are given, on the course Learn page, three csv files containing simulated data for 50 participants.  In this coursework you will focus only on the instrumental phase of the task. This phase consists of 160 trials, during which the probability of each stimulus to lead to the aversive noise were changed every 40 trials according to the following values:  60/40, 80/20, 60/40, 65/35 (i.e.  stimulus A leads to the aversive sound 60% of the first 40 trials, in the following 40 trials 80% of the times, etc).  Participants were not aware of both the probabilities and their changes - i.e., they had to infer them from the observed outcomes (loud sound/no sound) with the aim of avoiding the aversive outcome as much as possible.

D’Olimpio modelled the participants’ behaviour using 9 different reinforcement learning model similar to the

ones you have seen in the CCN lectures.  In this coursework, you will implement 3 of these, starting from

a simple model in which the value of the chosen stimulus i is updated on trial t after observing outcome o (which will be 0 for no sound and 1 for sound) as follows:

l You  can   have  a   look  at  the  questionnaire  at  this   link  https://oml.eular.org/sysModules/obxOML/docs/id_150/ State-Trait-Anxiety-Inventory.pdf

Vi(t+1)  = Vi(t) + α x (o(t) - Vi(t))

(1)

Initial values of V (0)  are set to 0.5. When the outcome of one stimulus choice is observed, the value of the alternative option is not updated.

The probability of choosing stimulus A as opposed to stimulus B on trial t is modelled using a softmax function (written slightly differently than in the lectures):

p(action A I V(t), β) =  .                                    (2)

Careful: we use a negative β parameter. This is an avoidance task, as such, we want to choose the option less likely to lead to the aversive sound.

Therefore, in this first model, we have two parameters: the learning rate α in our observation model and the inverse temperature β in our decision model. We hypothesise that trait anxiety could be related to changes in avoidance learning (i.e. an altered learning rate) or some change in decision making (inverse temperature).

Task (a):  Exploring the data (6)

Load and explore the provided data.  Compute the mean, standard deviation and median of the STAI-Y2 scores (trait anxiety).

Given a cutoff score of 43 (i.e.  STAI S 43 is healthy), how many participants would be considered healthy controls?  Report the indices of the control subjects. We know that the first 25 participants were recruited from the anxious population, and the last 25 from the calm population.  Based on the above cutoff, do the participants fit in the correct group?

Note: for the rest of the assignment we will consider the first 25 participants as the high anxious ones, and the last 25 as the low anxious ones.

Compute the number of times each participant choose option A. Report the average of this number  (or percentage) across all subjects. What is the expected number of aversive sounds experienced by participants

who respond randomly throughout the experiment? Did our participants perform the task well? Hint: the proportion of times subject 1 chose option A is about 18%.

Task (b):  Simulations (7)

Since we are working with a generative model, we are able to simulate data, which can be extremely useful. Use equations 2 and 3 to write a function that lets you generate data from known parameters (the parameter values should be an input to the function).  Generate the outcomes with probabilities which are changing every 40 trials as described in the introduction.

Hint: You can take inspiration from the code from the lectures to help you get started.

Simulate 160 choices with parameter settings α = 0.3,  β = -8 and V0  = 0.5 for both options a number of times.  (Choose a reasonable number so you can average the simulations).  Illustrate the average evolution of values V (A) and V (B).  Illustrate the average evolution of the difference in V values of the two stimuli (i.e. show how V (A) - V (B) changes, on average, over the course of the simulated experiments). Very briefly explain what is observed and why the shape of this evolution makes sense.

Hint: The average number of aversive sounds from a large number of simulations using the parameter values stated above should be around 60.

Task (c):  Exploring parameter settings (7)

Simulate 160 choices several times for a number of different parameter settings. Systematically vary settings of α and β to explore how different values affect the average number of aversive stimuli received.  Plot the average number of aversive stimuli received as a function of the parameter settings, which means there will be three dimensions. Choose sensible ranges for the parameters (e.g. 0 < α < 1 and -10 < β < 0).

Briefly describe your precise approach and comment on how the expected performance during the experiment is related to different settings of the parameters.

Task (d):  Likelihood function (6)

To find the parameter values that best capture each participant’s behaviour, we need to define the likelihood

of the parameters.  Write a function that takes as input the data (choices and outcomes) for an individual and a vector of parameters (learning rate and inverse temperature) and returns the negative log likelihood (NLL) of these parameters (note that θ is the parameter vector containing both α and β):

NLL = -               log p(c I V, θ).                                                         (3)

c∈Choices

Hint: You can take inspiration use the code from the lectures to help you get started.

Report the NLL for the first and the 10th participant using parameter settings α = 0.3, β = 8, V0  = 0.5.

Hint: If you compute the NLL for the second participant using the above parameters it should be around 64.

Task (e):  Model tting (9)

Find the parameters that minimize the NLL for each individual: Pass your NLL function and a set of starting parameters (use α = 0.3 and β = -8) to a optimization function performing unconstrained minimization.

Hint: For Python, you could have a look at scipy.optimize and particularly the Nelder-Mead algorithm. Calculate and report mean and variance of the fitted parameter values for learning rate and inverse temper- ature.  Illustrate the results: Plot the participant index on the x-axis, parameter values on the y-axis.  Can any difference between the low and high anxious groups be seen from the plot? Comment briefly on what you observe. Do all the values make sense? If not, what can you do about it? Calculate and report the Pearson’s correlation coefficient between estimated parameters (i.e. between α and β across all participants. Consider the first 25 participants as your high anxious group.  Also, calculate and report the Pearson’s correlation coefficient between estimated parameters separately for participants within each group.

Task (f):  Group comparison (4)

Use a two sample t-test (describe which exact test you are using) to test whether the estimated parameter values (Task (e)) are significantly different across groups (again, consider the first 25 participants as your high anxious group).  Report the t statistic, degrees of freedom and p value if applicable.  Make sure the estimated parameter values you use for this test make sense. Explain briefly how we can interpret the results and how this relates to our hypotheses. What might we conclude if the data was real?

Task (g):  Parameter recovery (9)

We now want to check the reliability and identifiability of our parameter estimates.   Sample 50 sets of parameter values of learning rate and inverse temperature from a multivariate normal distributions. Choose

sensible numbers for the mean of this distribution and describe how you chose them; choose small numbers for the variance (e.g. 0.01 and 0.5 for α and β respectively); set the covariance to zero. Illustrate the sampled values and highlight and exclude (resample) nonsensical values.

Use the sampled parameter values to simulate 50 sets of data (as in Task (b)). Fit new parameter values to these simulated data sets (as in Task (e)). Calculate, report and illustrate the Pearson’s correlation between the parameter values you used to simulate the data and the parameter values that you obtained from fitting the model to the simulated data.

Repeat this process 5 times and report the Pearson’s correlation each time (there is no need for you to plot the sampled values all 5 times, the correlation coefficients are enough).

Comment briefly.  Does this parameter recovery simulation meet your expectations?  Explore and describe how the number of trials and the number of simulated data sets affects the performance of the parameter

recovery.

Task (h):  Alternative model (9)

In addition to model 1, which you already implemented, we will now be considering an additional model. Model 2 introduces a parameter A. What is the effect of A in this model? How it can be interpreted?

Vi(t+1)  = A x Vi(t) + α x (o(t) - Vi(t))

(4)

Action selection for this model is again performed by the same softmax equation described in eq. (2)

p(action A I V(t), β) =                exp(-β x Vt))              

1. Implement simulation and (negative) log likelihood functions for this new model.

2.  Fit the new model (use α = 0.4,  β = 5,  A = 0.5 as initial values).  Illustrate the fitted parameter values.  Are the results surprising or as expected?  Can you explain them?  What can be done if the results are not as expected?

Task (i):  Model comparison (8)

For each participant you should now have two negative log likelihood values:  One for each model (using the estimated optimal parameters). Compare these negative log likelihood values between models. Explain what you observe. Does it make sense?

For each participant, compute AIC and BIC scores for each model.  Sum up the participant scores for each model (i.e. for each model you will have a single AIC score and a single BIC score).  Report the results. Comment briefly. Which model would you choose as the “best” model?

For your reference, use the following equations for the calculations of AIC and BIC, where NLL is the negative log likelihood, p is the number of parameters, and n is the number of observations  (160 in our experiment):

AIC = 2 x NLL + 2 x p

(6)

BIC = 2 x NLL + p x log(n)

(7)

Task (j):  Model recovery and confusion matrix (10)

We now want to check the reliability of our model comparison procedure using model recovery simulations. This will give us some indication about how much we can trust our results from Task (h). For each model, simulate data (using the functions you already implemented) multiple times.  For each of these simulated data set, fit each model and use model comparison (i.e., the AIC and BIC scores) to choose the best model. Display your results in a confusion matrix.  Comment briefly.   (Make sure to explain your approach and results in appropriate detail.)

Task (k):  Discussion and extra model (15)

Now, we include a last model, Model 3, which introduces two learning rates, one for neutral outcomes (ot  = 0) α+ , and one for punishments α _ :

Vi(t+1)  = Vi(t) + ((1 - ot )α+ + ot α _ ))(o(t) - Vi(t))

(8)

Action selection for this model is again performed by the same softmax equation described in eq. (2).          Repeat task h, i and j with this new model.  Use α+  = 0.25,  α _  = 0.35,  β = 6 as initial values for model fitting.

Note: in your report you can “merge” the results from this task to the previous three to save up space (i.e., you can report the AICs and BICs score for all three models in the same section, produce a single confusion matrix including all 3 models, etc).

Based on the model recovery, which model do you think generated the data used in this assignment?

Compute group comparisons  (again,  treat the first 25 participants as your high anxious group) for the parameters of model 3. Report t statistic, degrees of freedom and p value if applicable. If you find statistically significant differences for a parameter between the low and high anxious groups, what implications could this difference have on anxiety treatments (i.e., therapy)?