wmdsGN {lazy.mds}R Documentation

Individual Differences Multidimensional Scaling by the Gauss-Newton Method

Description

Individual Differences Multidimensional Scaling by the Gauss-Newton Method

Usage

wmdsGN(O, ndim, init = 1, mlevel = 5, nknots = 5, estX = 1, estW = 1,
  X = NULL, W = NULL, SQUAREM = 3, nSQUAREM = 3, minalpha = -9999,
  maxalpha = -1, always = 1, reset1 = 0, reset2 = 1, maxiter = 100,
  eps = 1e-06, epsd = 1e-06, print = 2, debug = 0)

Arguments

O

n x n x nG array of observed dissimilarity matrices

ndim

# of dimensions

init

= 0 to use random initial for X matrix

mlevel

= 1|2|3|4|5|6|9
1="continuous nominal", 2="discrete nominal" , 3="continuous ordinal(primary)", 4="discrete ordinal(secondary)" , 5="interval", 6="monotone spline", 9="no transformation at all"

nknots

# of knots for monotone spline transformation

estX

= 0 to skip the estimation of X

estW

= 0 to skip the estimation of W

X

The initial value of X when estX=0

W

The initial value of W when estW=0

SQUAREM

= 3 : See the help of iSQUAREM in lazy.accel package.

nSQUAREM

>= 1 # of iterations a which SQUAREM begins.

minalpha

= -999 : See the help of iSQUAREM in lazy.accel package.

maxalpha

= -1 : See the help of iSQUAREM in lazy.accel package.

always

= 1 : See the help of iSQUAREM in lazy.accel package.

reset1

= 0 : See the help of iSQUAREM in lazy.accel package.

reset2

= 1 : See the help of iSQUAREM in lazy.accel package.

maxiter

The maximum # of iterations

eps

The convergence criterion for the relative improvement of rmse.

epsd

The convergence criterion for the difference of param values.

print

= 1 to print the result

debug

= 1 to print the intermediate results

Details

The puropose of this function is to demonstrate how the ALS (Alternating Least Squares), the Gauss-Newton method, and inline SQUAREM can be utilized in MDS context.
The program may not be very efficient but it reduces rmse (stress2) at each phase of iteration.

The basic algorithm is as follows:
0) find initial value of X and W.
1) minimize rmse w.r.t. X given W by the GN method.
2) minimize rmse w.r.t. W given X by the GN method.
3) for every three iterations, update X and W with inline SQUAREM if requested.
4) minimize rmse w.r.t. optimal transformation of O.
5) check convergence.
6) go back to step 1) if not converged.


This program minimizes the stress formula 2 in terms of the distance:

∑_k ∑_{i>j} ( dh_{ijk} - d_{ijk} )^2 / variance( dh_{,,k} )

with respect to X, W and dh.

Actual minimization is done by minimizing

∑_k ∑_{i>j} ( dh_{ijk} - d_{ijk} )^2

with respec to X, W and dh and normalizing each dh[,,k] so that its
mean is equal to the mean of d[,,k] and its varaiance is equal to unity.

Given X and W, the optimal dh[,,k] is found by regressing d[,,k] on o[,,k] under the suitable assumption specified by mlevel.

Given dh and W, X is updated using the Gauss-Newton method.
Given dh and X, W is updated using the Gauss-Newton method.


When nG >= 2,
X is normalized so that 1'X = 0' and diag(X'X) = n I.

When nG = 1, W is set equal to 1 and 1'X = 0' will be enforced.

When mlevel = 9, dh is set equal to o and will not be normalized.




For the monotone least squares transformation, see the description of lazy.stat::mlsreg.
For the monotone spline, see the description of lazy.stat::spreg with type="m" option.



Note on the iSQUAREM:
Try always=1 with maxalpha=-1 first.
If it seems not working, use always=0 with maxalpha=1.
Changing reset1=1 and reset2=2 may help.
If all of the above fail, be patient and use SQUAREM=0.

Value

A list of the following:
rmse The rmse minimized
stress1 stress1
stress2 stress2 minimized
stress1_s stress1 for each individual
stress2_s stress2 for each individual
X n x ndim group configuration matrix
W nG x ndim subject weight matrix
vO The roll-out of the observed dissimilarity matrices.
vDhat The roll-out of the optimal transformation matrices.
vD The roll-out of the distance matrices.
iter_hist The history of the iteration with the columns:
llll, rmse, maxadX, maxadW.
mlevel, nknots, ndim

Examples

# generate data
set.seed(1701)
n=10; nG=3; ndim=2
npair=n*(n-1)/2
X=matrix(rnorm(n*ndim), n, ndim)
W=matrix(runif(nG*ndim), nG, ndim)
W=W%*%Diag(1/sqrt(colSums(W^2)))

# weighted Euclidean distance
vD=vech(distancew( X, W ),nodiag=1)

# add scaled error
stdD=sqrt( diag(cov(vD)*(npair-1)/npair) )
stderr=.2
vO=vD + matrix(rnorm(npair*nG),npair,nG )%*%Diag(stderr*stdD)
vO[vO<0]=0

# nonlinear transformation for subj1 and 2
# obs1=d^(1/3)  and  obs2=d-3
vO[,1]=vO[,1]^(1/3)
vO[,2]=vO[,2]^3

# back to square array
O=vechinv(vO, nodiag=1, array=1) # this is n x n x nG

# Fit the Weighted Model with monotone spline transformations
res1=wmdsGN( O, ndim=2, mlevel=6, print=2 )

# dhat1=obs1^3,  dhat2=obs2^(1/3)
plot_wmds( res1 )
# res1=wmdsGN( O, ndim=2 , print=2, SQUAREM=0 )

[Package lazy.mds version 0.1.2 Index]