**Overview**
These are scripts from the paper "Using a Generative Model to Characterise and Target Affective Instability in Patients with Bipolar and Borderline Personality Disorders".
The scripts generate synthetic data and then run the Bayesian filter on the data (and plot the results).
**Data**
Unfortunately the data from the reported studies were not collected with the required ethical approval to allow deposit on an open access server. Annonymised data may be shared with research groups who have appropriate ethical approval in place by contacting: kate.saunders@psych.ox.ac.uk
**Code**
Three matlab scripts are provided. Details of these are below (basically run "run_example" to see an example of the model on synthetic data).
*maglearn_func_vardiff_flat_miss.m* is the code for the filter itself.
*inv_logit.m* is a required function (performs either a logit or inverse logit transform)
*run_example* is a wrapper script that generates synthetic data, runs it through the model and then plots the results. Use this to see how to call the model. The synthetic data has periods of high and low volatility and noise which the model attempts to recover.