procscal {lazy.procrustes}R Documentation

Procscal: Simultaneous Expanded Orthogonal Rotation of Many Matrices

Description

Procscal: Simultaneous Expanded Orthogonal Rotation of Many Matrices

Usage

procscal(X, mug = NULL, estm = 0, model = 2, minW = 0.001,
  maxiter = 200, eps = 1e-06, maxiter2 = 20, eps2 = 1e-05,
  epsd = 1e-06, Xonly = 1, SQUAREM = 3, nSQUAREM = 1, minalpha = -999,
  maxalpha = -1, always = 0, reset1 = 0, reset2 = 1, print = 2,
  init = 1, initpc = 2, Xinit = NULL, Tinit = NULL, Winit = NULL,
  minit = NULL)

Arguments

X

Input array

mug

Input variable mean matrix

estm

= 1 to estimate m

model

= 1 to set all W_k matrices proportional to identity matrix.

minW

minimum value of W

maxiter

max # of iterations

eps

convergence criterion for rmse

maxiter2

max # of inner iterations

eps2

convergence criterion for inner iterations

epsd

convergence criterion for the difference

Xonly

= 1 to use SQUAREM for X only.

SQUAREM

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

nSQUAREM

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

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.

print

= 1 to print the result

init

= 1 to use pc of super matrix as the initial

initpc

= 0 to use random initial of princ

Xinit

n x nr matrix consisting of the initial value of X matrix

Tinit

nr x nr x nG array consisting of the rotation matrix

Winit

nG x nr matrix consisting of the initial of the diag elem of W_k

minit

nG x nr matrix consisting of the initial value of m

Details

The program minimizes
RSS = sum_k ssq( ( X_k - (X W_k T_k + 1 m_k') ) )
w.r.t X, T_k, m_k and W_k subject to T_k'T_k = T_k T_k' = I and W=diag.

In addition, if mug is given, instead of estimating m_k, factor.mean will be calculated after conversion.

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

Value

When mu is present, a list of
X, W, T, m, q, u, mu, rmse
where X, W, m, mu, u, and q are group x dimension matrices , T is a array.
When mu is not present, u, q and mu are not included.

Examples

seed <- 1701
set.seed(seed)
nG <- 3; n <- 30; nr <- 2

# Simultaneous rotation of several matirces
# generate data
resg <- gendataWmm( nG,n,nr, genm=1, genW=2, errstd=.05, pcA=1, minWD=0.4 )
Xall <- l2a(resg$C); mall <- t(a2m(l2a(resg$m),method=1))
Xg <- resg$A; Tg <- l2a(resg$T); Wg <- l2a(resg$W);
Wg <- t(matrix(colSums(a2m(Wg)),nr))
od <- nr+1-order( colSums(Wg*Wg) )
Wg <- Wg[,od];  Xg <- Xg[,od];  mg <- mall[,od]
for( k in 1:nG ){
 Tg[,,k] <- Tg[od,od,k];  Xall[,,k] <- Xall[,od,k]
}

# Increase maxiter to obtain convergence!
res <- procscal( Xall, estm=1, model=2, minW=1e-4, init=1
              , always=1
              , maxiter=100, maxiter2=5, eps=1e-5, epsd=1e-4, print=2 )
X <- res$X; W <- res$W; T <- res$T; m <- res$m



# Estimation of factor score means
seed <- 1701
set.seed(seed)
ncommonitems <- 10

# generate data
resg <- gendataWmm( nG,n,nr, genmu=1,genW=2,errstd=0.05, pcA=1,minWD=0.4 )
Xall <- l2a(resg$C)
Xg <- resg$A; Tg <- l2a(resg$T); Wg <- l2a(resg$W);
mug <- a2m(l2a(resg$mu)); ug <- t( a2m(l2a(resg$u)) )
Wg <- t(matrix(colSums(a2m(Wg)),nr))
od <- nr+1-order( colSums(Wg*Wg) )
Wg <- Wg[,od]; Xg <- Xg[,od]; ug <- ug[,od]
for( k in 1:nG ){
 Tg[,,k] <- Tg[od,,k]; Xall[,,k] <- Xall[,od,k]
}


# Distribute items to nG forms:  systematic missing pattern
locmiss=gensysmiss( n, nG, ncommonitems, print=0, sort=0 )
for( k in 1:nG ){
 lmk <- locmiss[[k]]
 Xall[lmk,,k] <- NA; mug[lmk,k] <- NA
}
Print("Data to be analyzed:", Xall, mug, fmt="6.3")#'

# Increase maxiter and lower eps values to obtain true convergence!
res=procscal( Xall, mug=mug, estm=0, model=2, minW=1e-4, init=1, always=1
            , maxiter=100, maxiter2=5, eps=1e-5, epsd=1e-4, print=1 )
X <- res$X; W <- res$W; T <- res$T; mu <- res$mu; u <- res$u; q <- res$q



[Package lazy.procrustes version 0.1.3 Index]