Quick start: QUB Online Fitness X-Means Movie Maker

# Maximum Subinterval Likelihood

The maximum likelihood estimator MIL (Qin et al 1996) is extended to handle data recorded with a varying stimulus. We consider the stimulus as piece-wise constant, and adjust the transition matrices each time it changes. This may split some events, so we derive a transition probability matrix that allows subsequent events in the same class. Thus the new name, maximum subinterval likelihood.

See the source code: browse

## MIL Background

In MIL, the conditional likelihood of a dwell in class a and the following transition to class b is given as

$$$${}_e\!G_{ab}(t) = e^{{}_e\!Q_{aa}t'}{}_e\!Q_{ab} \label{eq:eGab}$$$$

where

$$$$t' = t - t_d \label{eq:tp}$$$$ $$$${}_e\!Q_{aa} = Q_{aa} - Q_{a\bar{a}}(I - e^{Q_{\bar{a}\bar{a}}t_d})Q_{\bar{a}\bar{a}}^{-1}Q_{\bar{a}a} \label{eq:eQaa}$$$$ $$$${}_e\!Q_{ab} = e^{t_dQ_{a\bar{a}}(I - e^{Q_{\bar{a}\bar{a}}t_d})Q_{\bar{a}\bar{a}}^{-1}Q_{\bar{a}a}} \times [Q_{ab} - Q_{ac}(I - e^{Q_{cc}t_d})Q_{cc}^{-1}Q_{cb}] \label{eq:eQab}$$$$

$${}_e\!Q_{ab}$$ is calculated differently in modern QUB:

$$$${}_e\!Q_{ab} = [Q_{ab} - Q_{ac}(I - e^{Q_{cc}t_d})Q_{cc}^{-1}Q_{cb}]e^{Q_{bb}t_d} \label{eq:eQab2}$$$$

The forward function is

$$$$\alpha^{\tau}_k = \alpha^{\tau}_{k-1}{}_e\!G_{a_ka_{k+1}}(t_k) \label{eq:alpha}$$$$

and

$$$$LL = log(\alpha^{\tau}_L 1) \label{eq:ll}$$$$

## Subinterval Likelihood

Following the lead of Colquhoun and Hawkes (1982), eq \eqref{eq:eGab} combines the conditional probability of staying in class a (at least apparently) with the probability per second of going to class b. The resulting probabilities per second are often greater than 1, so their use as likelihoods in MIL leads to surreal "LL". This is mainly just an annoyance, but it does prevent use of Aikaike and Bayes information criteria.

A more serious difficulty for MSL is that the stimulus may change mid-dwell, and with it the Q matrix. We need a formula that allows for subsequent dwells of the same class. In equation \eqref{eq:eGab}, $$e^{{}_e\!Q_{aa}t'}$$ does not depend on the event ending after time t. So the likelihood of a partial dwell is

$$$$L_a(t) = e^{{}_e\!Q_{aa}(t - t_d)} \label{eq:La}$$$$

The final $$t_d$$ of each event is spent mysteriously in transition, whether back to the same class or into a new one. This is the conditional likelihood of being in class b after exactly $$t_d$$:

$$$$Adead = e^{Q t_d} \label{eq:Adead}$$$$ $$$$L_{ab} = Adead_{ab} = Adead_{i \in a,j \in b} \label{eq:Lab}$$$$

Put them together in a new forward function and get LL from \eqref{eq:alpha}:

$$$$\alpha^{\tau}_k = \alpha^{\tau}_{k-1} L_a(t_k) L_{a_ka_{k+1}} \label{eq:alphatau}$$$$

## Constrained Parameters

This is the algorithm used by MIL, Mac etc to transform between k, a column vector of $$N_k$$ rate constants, constrained by

$$$$A_{in} \cdot k = B_{in} \label{eq:Ain}$$$$

and the free parameters $$p \in \Re^{N_p}$$ used by the optimizer. A and B are derived so that

$$$$k = A \cdot p + B, and \label{eq:k}$$$$ $$$$p = A^T \cdot k \label{eq:p}$$$$

In the final section I extend the method to scale all free parameters to start at 1.

### Clean up Constraints

#### Remove linearly dependent constraints

The Singular Value Decomposition (SVD) technique below doesn't work well when constraints duplicate each other; that is, none of the augmented vectors $$c_i^T = \left [ A_{ij} \vdots B_i \right ]$$ may be a linear combination of the others. To find and eliminate these constraints, build C out of rows $$c_i$$: $$$$C = \left [ A \vdots B \right ]^T \label{eq:c}$$$$

define the partitions:

$$$$C_{i..j} = \left [ {}^{c_{1i}}\ddots_{c_{N_k+1 j}} \right ]; C_{i..i} = c_i \label{eq:Cij}$$$$

and with i from 2 increasing, remove any column $$c_j$$, where $$i \lt j$$, if

$$$$C_{1..i} \cdot c'_j = c_j \label{eq:C1i}$$$$

can be solved for $$c'_j$$. This can be tested with SVD:

$$$$U \cdot W \cdot V^T = SVD(C_{1..i}) \label{eq:svd}$$$$ $$$$C^-1 \approx V \cdot W^{-1} \cdot U^T \label{eq:Cinv}$$$$

* all infinitesimals in U, W, V sent to 0
* if $$W_{ii} = 0$$, define $$W_{ii}^{-1} = 0$$

$$$$c'_j = C^{-1} c_j \approx V W^{-1} U^T c_j \label{eq:cpj}$$$$ $$$$c''_j = C_{1..i} \cdot c'_j \label{eq:cppj}$$$$

If $$c_j = c''_j$$, then $$c_j$$ is the linear combination $$c'_j$$ of the previous constraints, so remove it.

Alternately, or as a double-check, the $$c_i$$ are linearly independent if $$C_{1..N_c}$$ has rank $$N_c$$. A constraint $$c_j$$, where $$j = i + 1$$ can be removed if $$rank(C_{1..i}) = rank(C_{1..j})$$.

Again with SVD: the singular values of $$C_{1..i}$$ are the nonzero diagonal entries of W in \eqref{eq:svd}. $$rank(C_{1..i})$$ is the number of singular values.

#### Look for Inconsistent Constraints

Consider $$rank(A_{in}^T) = rank(A_{in})$$. If $$rank(A_{in}) \lt rank(C)$$, there is a constraint that can be expressed as a linear combination of others, except with a different right-hand-side ($$B_{in}$$) component, a contradiction. The user must resolve this. We could identify which constraints conflict with each other using a procedure similar to the last section.

### Solve the Linear System

Now we have $$A_{in}$$, $$B_{in}$$ with $$N_c$$ independent and compatible constraints. To solve the system \eqref{eq:Ain} for the subspace of constrained k, observe that any such k can be written

$$$$k = k_h + k_p \label{eq:khp}$$$$

where $$k_h$$ is in the null space of $$A_{in}$$; i.e. $$A_{in} \cdot k_h = 0$$, and $$k_p$$ is a particular vector satisfying \eqref{eq:Ain}.

#### The null space

Using SVD,

$$$$U \cdot W \cdot V^T = A_{in} \label{eq:svdnull}$$$$

Now, assuming SVD sorts the singular values non-increasing, the columns of

$$$$A = \left [ V_{R+1 \cdots N_k} \right ] \label{eq:Avr}$$$$

form a basis for the null space of $$A_{in}$$, so

$$$$k_h = A \cdot p = 0 \text{ for all } p \in \Re^{N_k-R} \label{eq:kh}$$$$

#### The Pseudo-Inverse

Find the particular nonhomogeneous solution $$k_p$$ by inverting \eqref{eq:Ain} using SVD pseudo-inversion:

$$$$A_{in} \cdot k_p = B_{in} \label{eq:Ainkp}$$$$ $$$$A_{in}^{-1} \approx V W^{-1} U^T \label{eq:Aininv}$$$$ $$$$A_{in}^{-1} A_{in} k_p \approx V W^{-1} U^T B_{in} \label{eq:Aininvkp}$$$$ $$$$B = k_p \approx V W^{-1} U^T B_{in} \label{eq:B}$$$$

Putting it together,

$$$$k = A \cdot p + B \label{eq:kdup}$$$$ $$$$\frac{\partial k}{\partial p} = A \label{eq:dkdp}$$$$

### Scale All Parameters to 1

The DFP optimizer works poorly when components of p have different magnitude. To scale them so they're all ones at the starting rate constants $$k0$$, define the vector $$s$$ of scaled parameters

$$$$p = A_s \cdot s + B_s \label{eq:pAs}$$$$ $$$$s = A^{-1}_s (p - B_s) \label{eq:sAinv}$$$$ $$$$\frac{\partial p}{\partial s} = S \label{eq:dpds}$$$$

where $$A_s$$ is the $$N_p x N_p$$ diagonal matrix with entries

$$$$p0 = A^T \cdot k0 \label{eq:p0At}$$$$ $$$$A_{s,ii} = \begin{cases} 1.0, & \mbox{if }p0_i\mbox{ is 0} \\ p0_i, & \mbox{otherwise} \end{cases} \label{eq:Asii}$$$$

and $$B_s$$ is the column vector with entries

$$$$B_{s,i} = \begin{cases} -1.0, & \mbox{if }p0_i\mbox{ is 0} \\ 0.0, & \mbox{otherwise} \end{cases} \label{eq:Bsi}$$$$