Here are a couple of matlab scripts Iíve found useful for analyzing data from experiments where each observation in a data matrix is represented by a row of values. Observations can be from different experimental conditions and may recur many times, in no particular order.

(1) Meansemfun.m deals with a scalar dependent variable (which might for instance be a subjectís rating or a numerical setting). If no arguments are supplied, the user is prompted for the name of a text file that contains just the data matrix.There can be one or two independent variables, the values of which are defined by the experimental condition; values of the dependent and independent variables form two or three columns of the data matrix, that the caller of the script is asked to identify

For instance, this dialog runs meansemfun on the data matrix in the ascii text file tl2.dat :

>> meansemfun

ascii file to analyze, including any extension: tl2.dat

Column index (>=1) for x:†† 1

Column index for y:†† 2

Column index for z, to create multiple curves, one for each z value (hit 'enter' if none)?†† 3

 

Alternatively, the data matrix can be a variable in the workspace, specified by the first supplied argument. Thus if tl2 is an N x Mmatrix variable ( with M >=3) already present in the workspace, meansemfun(tl2,1,2,3)will produce the same results. Syntax here is:meansemfun(datamatrix, [xindex,yindex, zindex]).

Meansem.m begins by sorting the data by values of the independent variable. It plots mean and s.e.m for the dependent variable (y) as a function of the dependent variable (x), showing the results for different values of (z), if z is specified, as different graphs on a common plot. Relevant statistics are returned in output structures. Detailed comments are at the head of the script.

(2) Psyfit.m plots psychometric functions for data where each observation includes only a binary response (yes/no, or correct/incorrect in multiple-alternative forced-choice).It can deal with meager or messy data sets that may not be tractable using similar resources such as Wichmann and Hillís psignifit. Format for data: rows contain the independent variable value†† (e.g. log stimulus intensity), number of trials presented (can be 1 or zero if trials are listed individually, number correct (or yes), and optionally a condition index that allows results for different conditions to be analysed and plotted separately.Detailed comments on usage, etc., are at the head of the script. To try it on the 2AFC data in the file tmpdata.dat, usesomething like:[bestparams, statstruct ] = psyfit('tmpdata.dat', 2, 0, 1 ).

(3) The script threshdifflkhd.m proposes an elaborate and in some respects rigorous test for equality of thresholds as a null hypothesis, and derives a likelihood function for magnitude of threshold difference between two conditions that takes into account the uncertainty in all the threshold parameters involved. It is less useful than you might imagine, since it generally gives essentially the same result as the simpler procedure of straightforwardly computing the standard errors of the differences in threshold parameter. The involved subtleties of method are discussed in this MS Word document (click link to download).