---
title: "An Alternative Majorization for Multidimensional Scaling"
author: "Jan de Leeuw"
date: "Version April 09, 2018"
output:
html_document:
keep_md: yes
number_sections: yes
toc: yes
pdf_document:
keep_tex: yes
number_sections: yes
toc: yes
toc_depth: 3
fontsize: 12pt
graphics: yes
bibliography: cmds.bib
abstract: The Cauchy-Schwartz majorization of the distance function in SMACOF is replaced by a majorization of the squared distance function. This leads to an interesting SMACOF alternative, which we call SMOCAF.
---
```{r function_code, echo = FALSE}
source("smacof.R")
source("smocaf.R")
```
```{r packages, echo = FALSE}
options (digits = 10)
#suppressPackageStartupMessages (library (smacof, quietly = TRUE))
```
Note: This is a working paper which will be expanded/updated frequently. All suggestions for improvement are welcome. The directory [gifi.stat.ucla.edu/cmds](http://gifi.stat.ucla.edu/cmds) has a pdf version, the bib file, the complete Rmd file with the code chunks, and the R source code.
#Introduction
The (Euclidean, metric, least squares) multidimensional scaling or MDS problem is a special case of a nonconvex optimization problem in which we minimize a function of the form
$$
f(x)\mathop{=}\limits^{\Delta}1 + \frac12 x'x - \sum_{i=1}^n \sqrt{x'A_ix},
$$
where the $A_i$ are given positive semi-definite matrices. Because the third term on the right, the one with the square root, is convex, the problem is a DC-problem (@lethi_tao_18), i.e. the minimization of the difference of two convex functions, one of which is quadratic and one of which is not differentiable at some points. We do not really have to worry about non-differentiability, because of the result in @deleeuw_A_84f.
#SMACOF
The SMACOF algorithm (@deleeuw_C_77, @deleeuw_heiser_C_77, @deleeuw_mair_A_09c) to minimize the MDS objective function $f$ is a majorization algorithm (@deleeuw_C_94c), currently more commonly known as an MM algorithm (@lange_16). It is based on the Cauchy-Schwarz inequality
$$
\sqrt{x'A_ix\ y'A_iy}\geq x'A_iy.
$$
Define
$$
e_i(x)\mathop{=}\limits^{\Delta}\begin{cases}(x'A_ix)^{-\frac12}&\text{ if }x'A_ix\not= 0,\\
0&\text{ otherwise }.\end{cases}
$$
and
$$
g(x,y)\mathop{=}\limits^{\Delta}1+\frac12 x'x -\sum_{i=1}^ne_i(y)x'A_iy,
$$
then we have the basic majorization relations $f(x)\leq g(x,y)$ and $f(x)=g(x,x)$. Thus step $k$ in the iterative algorithm minimizes $g(x,x^{(k)})$ over $x$, which leads to the convergent algorithm
$$
x^{(k+1)}=\sum_{i=1}^ne_i(x^{(k)})A_ix^{(k)}.
$$
#SMOCAF
For our alternative majorization we use the inequality
$$
x'A_ix\geq 2x'A_iy-y'A_iy.
$$
Define the polyhedral convex set $\mathcal{C}(y)$ of all $x$ such that $2x'A_iy-y'A_iy\geq 0$
for all $i$. Clearly $y\in\mathcal{C}(y)$, and thus $\mathcal{C}(y)$ is non-empty. Also define
$$
h(x,y)\mathop{=}\limits^{\Delta}1+\frac12 x'x-\sum_{i=1}^n\sqrt{2x'A_iy-y'A_iy},
$$
for all $x\in\mathcal{C}(y)$. Because the square root of a non-negative linear form is concave, minimizing $h(x,x^{(k)})$ over $x\in\mathcal{C}(x^{(k)})$ is a convex problem with linear constraints and leads to a convergent MM algorithm, which we call SMOCAF.
Of course a SMOCAF step is inherently more complicated than a SMACOF step. The idea is interesting, at least to me, because the SMOCAF algorithm solves a sequence of convex programming problems in which the constraint set changes over iterations.
#Example
We try out both SMACOF and SMOCAF on a simple example, where there are 10 matrices $A_i$,
all covariance matrices of a 20 by 5 matrix filled with random standard normals. The SMOCAF iterations are implemented using `constrOptim()` from base R, which uses a logarithmic barrier
method for the convex programming step. Since we have very good initial estimates, and we do not really have to iterate until convergence within each step, I assume the SMOCAF implementation can be made much more efficient. In addition, acceleration techniques specific to DC programming, such as the one discussed in @artacho_fleming_vuong_17, could be applied. Or general acceleration techniques, discussed recently in great detail in @sidi_17. But optimal speed is not what interests us here.
```{r data, echo = FALSE}
set.seed(12345)
a <- array (0, c(5, 5, 10))
for (i in 1:10) a[, , i] <- crossprod (matrix(rnorm(100), 20, 5)) / 20
```
```{r smacof}
system.time(print(smacof(a, rep(1,5), verbose = FALSE)))
```
```{r smocaf}
system.time(print(smocaf(a, rep(1,5), verbose = FALSE)))
```
For both majorizations convergence is nice and smooth, and both converge to the same solution. The number of iterations is about the same, but since SMOCAF iterations are considerably more time-consuming the overall SMOCAF time is about 10 times the SMACOF time.
#Appendix: Code
##smacof.R
```{r file_auxilary, code = readLines("smacof.R"), size = 'footnotesize'}
```
##smocaf.R
```{r file_auxilary, code = readLines("smocaf.R"), size = 'footnotesize'}
```
#References