```{r ekman_plot_1, fig.align = "center", echo = FALSE} par(pty="s") hekman<-smacofEllipseRC(1,2,w,delta,2,.1) ```

If we change $\epsilon$ to .01 then the configuration stays the same, the shape of the ellipses stays the same, they just become uniformly smaller.

```{r ekman_plot_2, fig.align = "center", echo = FALSE} par(pty="s") hekman<-smacofEllipseRC(1,2,w,delta,2,.01) ```

##De Gruijter The second example are dissimilarity ratings between Dutch political parties in 1967, averaged over 50 students, and taken from @degruijter_67. ```{r poldist, echo = FALSE} par(pty="s") poldist <- structure( c( 5.63, 5.27, 4.6, 4.8, 7.54, 6.73, 7.18, 6.17, 6.72, 5.64, 6.22, 5.12, 4.59, 7.22, 5.47, 5.46, 4.97, 8.13, 7.55, 6.9, 4.67, 3.2, 7.84, 6.73, 7.28, 6.13, 7.8, 7.08, 6.96, 6.04, 4.08, 6.34, 7.42, 6.88, 6.36, 7.36 ), Labels = c("KVP", "PvdA", "VVD", "ARP", "CHU", "CPN", "PSP", "BP", "D66"), Size = 9L, call = quote(as.dist.default(m = polpar)), class = "dist", Diag = FALSE, Upper = FALSE ) print(poldist) delta <- as.vector(poldist) w <- rep (1, length(delta)) hsma <- smacofRCU (w, delta, 2, itmax = 10000) ``` A smacof analysis in two dimensions takes `r hsma$itel` iterations to come up with stress `r hsma$s`. We use an absolute region, with $\epsilon=1$, i.e. we show how points can be moved around while keeping stress less than `r hsma$s + 1`.

```{r poldist_plot, fig.align = "center", echo = FALSE} par(pty="s") hpoldist<-smacofEllipseRC(1, 2, w, delta, 2, 1) ```

#Code ```{r code} smacofEllipseRC <- function (s, t, w, delta, p, eps, relative = FALSE) { m <- length (w) n <- round ((1 + sqrt (1 + 8 * m)) / 2) r <- n * p hsma <- smacofRCU(w, delta, p) eps <- ifelse (relative, 2 * hsma$s * eps, 2 * eps) hvec <- smacofHessianRC(hsma$x, hsma$b, smacofVmatRC (w), hsma$d, w, delta) xmat <- matrix (hsma$x, n, p) plot ( xmat, col = "RED", pch = 21, bg = "RED", xlab = paste("dim ", formatC( s, digits = 1, format = "d" )), ylab = paste("dim ", formatC( t, digits = 1, format = "d" )) ) hmat <- matrix (trimatRC(hvec), r, r) z <- cbind (sin (seq(-pi, pi, length = 100)), cos (seq(-pi, pi, length = 100))) * sqrt(eps) for (i in 1:n) { ii <- c((s - 1) * n + i, (t - 1) * n + i) y <- xmat[i, c(s, t)] amat <- c(hmat[ii[1], ii[1]], hmat[ii[2], ii[1]], hmat[ii[2], ii[2]]) hjac <- jacobi (amat) zi <- z %*% diag (1 / sqrt (hjac$values)) zi <- tcrossprod(zi, hjac$vectors) zi <- zi + matrix (y, 100, 2, byrow = TRUE) lines (list(x = zi[, 1], y = zi[, 2])) } return ( list ( x = xmat, dist = hsma$d, bmat = hsma$b, hessian = hmat, stress = hsma$s, itel = hsma$itel ) ) } ``` #References