Manual

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 29

Scroll down to view the document on your mobile browser.
cbm manualPayam PirayJune 18, 2019This document serves as the manual of cbm (computational and behavioral modeling) toolbox.cbm provides tools for hierarchical Bayesian inference (HBI). See the corresponding manuscript(here) for more information about the HBI and its comparison with other methods. You can down-load cbm here. In this manual, I present two well-known examples and explain how cbm toolsshould be used to perform Bayesian model comparison, parameter estimation and inference at thegroup level. To be able to follow this manual, you need to be familiar with matlab syntax (cbmwill be published soon in other languages, particularly python).1 Example 1: bandit taskI assume that the current directory contains this manual and “codes” directory, as well as “exam-ple_RL_task” and “example_2step_task” directories. The codes directory contains all cbm matlabfunctions.For using cbm tools, you need to know what is your model-space and code your own models.You can then use cbm to make inference. For this example, models code and data have been storedin the example_RL_task directory.Suppose you have 40 subjects’ choice data in a 2-armed bandit task, in which subjects chosebetween two actions and received binary outcomes.All data have been stored in a mat-file called all_data.mat in a cell format, in which each cellcontains choice data and outcomes for one subject. First, enter the example_RL_task directory andthen load those data:In [1]: % enter the example_RL_task folder,% which contains data and models for this example% (assuming that you are in the directory of the manual)cd(fullfile('example_RL_task'));In [2]: % load datafdata = load('all_data.mat');data = fdata.data;% data for each subjectsubj1 = data{1}; % subject 1subj2 = data{2}; % subject 2% and so onFor example, subj1 contains information of subject 1: subj1.actions are all actions andsubj1.outcome are the corresponding outcomes.1
Also suppose you have 2 candidate models. An RL model, which has a learning rate (alpha)and a decision noise (beta) parameter. The other model is a dual-alpha RL model with two sep-arate learning rates for positive and negative prediction errors (alpha1 and alpha2, respectively)and a decision noise (beta) parameter. See matlab functions model_RL and model_dualRL as ex-amples.It is important to remember that cbm does not care how your model works! It assumes thatyour models take parameters and data (of one subject) as input and produce a log-probability ofdata given the parameters (i.e. log-likelihood function). Tools in cbm only require that the inputand output of models follow a specific format:loglik = model(parameters,subj)For example, for the model_RL, we have:loglik = model_RL(parameters,subj1)here parameters is a vector, which its size depends on the number of parameters of themodel_RL (for model_RL, its size is 2). subj1 is the structure containing data of subject 1 asindicated above. loglik is the log-likelihood of subj1 data given parameters, as computed bymodel_RL.We now use cbm tools to fit models to data. For this example, we use the two models im-plemented in model_RL and model_dualRL together with the data stored in all_data.mat. Datastored in all_data is a synthetic dataset of 40 subjects. The data of the first 10 subjects are generatedby model_RL and the data of the next 30 subjects are generated by model_dualRL. Note, however,that cbm is not meant to provide a collection of different computational models. You should codeyour models for questions of your interest yourself. The tools in cbm fit your models to your dataand compare the models given the data.First, make sure that cbm is added to your matlab path and then load the data:In [3]: addpath(fullfile('..','codes'));% load data from all_data.mat filefdata = load('all_data.mat');data = fdata.data;Before using cbm tools, it is always good to check whether the format of the models is com-patible with the cbm. To do that, create a random vector parameters and call the models:In [4]: % data of subject 1subj1 = data{1};parameters = randn(1,2);F1 = model_RL(parameters,subj1)parameters = randn(1,3);F2 = model_dualRL(parameters,subj1)F1 =-200.95992

Navigation menu