In the following, T: the number of time bins, S: the number of odors, N: the number of cells, K: the number of clusters.

ClusterLhnData(Data, numClusters = 3, kalpha = 10, thalpha = 3/20,
  sdv0 = 0.1, taua = 1, taul0 = 0.5, minIters = 0,
  numIters = 10000, dt = 1e-05, seed = 0, initMode = "random",
  iclust = NULL, verbose = TRUE, timer = "OFF",
  slopeRatioToStop = 100, numSlopePoints = 20,
  checkToStopEvery = 100, keepHistory = NULL, keepHistoryAt = NULL,
  maxPreFitIters = 1)

Arguments

Data

FIXME - what should the input data look like?!

numClusters

The number of clusters to use.

kalpha

The shape parameter for the gamma prior on alpha.

thalpha

The scale parameter for the gamma prior on alpha

sdv0

The standard deviation of the gaussian prior on membrane potential offset.

taua

The rate constant for the exponential prior on the drive parameters

taul0

The rate constant for the exponential prior on l0.

minIters

The minumum number of iterations.

numIters

The maximum number of iterations.

dt

The time constant of the updates.

seed

The random seed to use.

initMode

The initialization mode for the clustering. Can be "random", "kmeans", or "kmeans++".

iclust

An initial clustering assignment, if any.

verbose

If TRUE will print out the progress of the algorithm and other diagonstic information.

timer

If "ON" will time different blocks of the code.

slopeRatioToStop

The ratio of the rate of change of the objective at the end to the start above which to terminate.

numSlopePoints

How many points to take to compute the slope of the objective

checkToStopEvery

How often to compute the stopping ratio.

keepHistory

A least of strings containing the variables to track.

keepHistoryAt

A list of iterations at which to record history. If NULL defaults to all.

maxPreFitIters

The maximum number of iterations to pre fit the cell-specific parameters to the clusters. If set to 0 will not prefit the parameters.

Value

A list consisting of

seed

The random seed used.

a

A 2 x S x K array containing the learned drive parameters

al

A N x 1 vector containing the learned alpha values

v0

A N x 1 vector containing the learned v0 parameters

l0

A N x 1 vector containing the learned l0 parameters

qnk

A N x K matrix of the cluster responsibilities for each data point.

L

A T x S x N x K array containing the final lambda values

Lclust

A T x S x N array containing the final lambda value for the most likely cluster for each fit.

numIters

The actual number of iterations that ran.

F

A numIters x 1 array containing the objective function as function of the number of iterations.

clust

A N x 1 vector of cluster assignments.

pclust

A N x 1 vector of the probabilities of the cluster chosen.

dclust

A N x 1 vector of distances to its cluster center.

exitMode

A string with the exit mode of the algorithm: "ITERS" if it hit the maximum number of iterations, "SLOPE_RATIO" if it exited early due to the slope ratio.

history

A list containing the values of the tracked variables for the specified iterations.

misc

A miscellaneous list to hold other variables, used mainly for debugging.