pca_by_als {lazy.fa}R Documentation

PCA by ALS

Description

This program approximates the n x nvar input matrix Y
by the product of n x ndim F and nvar x ndim A matrices as
Y = F %*% t(A) + E
The optimal scaling of Y can also be estimated.

Usage

pca_by_als(Y, ndim = 2, mlevel = 4, maxiter = 1000, epsd = 1e-06,
  SQUAREM = 0, nSQUAREM = 1, maxalpha = -1, always = 1, reset1 = 1,
  reset2 = 2, print = 1)

Arguments

Y

Data matrix

ndim

# of dimensions

mlevel

A vector of measurement level for each variable:
mlevel for each variable = 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"

maxiter

Maximum # of iterations

epsd

The convergence criterion for the difference of param values.

SQUAREM

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

nSQUAREM

>= 1 # of iterations a which SQUAREM begins.

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

nknots

# of knots for monotone spline transformation

minalpha

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

Details

This function finds F and A matrices of rank ndim which minimize sum over j of( (Yhat[,j]-(F%*%t(A))[,j])^2 / var(Yhat[,j]) ) where Yhat is the column-wise optimally scaled data matrix Y. The actual minimization is done by normalizing var(Yhat[,j])=1 and minimizing sum( (Yhat-F%*%A)^2 ) by alternating least squares..

Examples

seed <- 1701+9
set.seed(seed)
n <- 100; nvar <- 25
Y <- matrix(rnorm(n*nvar),n)
# res <- pca_by_als( Y, 2, SQUAREM=0, print=2, mlevel=5 ) # slow!!
res <- pca_by_als( Y, 2, SQUAREM=3, always=1, print=2, mlevel=5 )


[Package lazy.fa version 0.1.3 Index]