efa {lazy.fa}R Documentation

Simple Iterative Solution of Exploratory Factor Analysis
Sigma = Lambda %*% t(Lambda) + Psi

Description

Simple Iterative Solution of Exploratory Factor Analysis
Sigma = Lambda %*% t(Lambda) + Psi

Usage

efa(S, ndim = 3, n = 1, method = "ML", Lambda = NULL, psi = NULL,
  estLambda = 1, estpsi = 1, Phi = diag(ndim), maxiter = 500,
  epsd = 1e-07, minpsi = 0.01, derivN = 0, SQUAREM = 3, nSQUAREM = 1,
  minalpha = -99, maxalpha = 1, always = 1, reset1 = 1, reset2 = 2,
  print = 1)

Arguments

S

Input dispersion matrix

ndim

# of dimensions

n

# of observations

method

= "ls" or "lm" or "em"

Lambda

Fixed value of Lambda when estLambda=0.

psi

Fixed value of c(Psi) when estpsi=0.

estLambda

= 0 to skip the estimation of Lambda.

estpsi

= 0 to skip the estimatio of Psi.

Phi

Factor Correlation matrix to be used.

maxiter

Maximum # of iterations

epsd

The convergence criterion for the difference of param values.

minpsi

The minimum value of psi

derivN

= 1 to calculate the final derivative numerically by lazy.mat::JacobianMat.

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.

print

= 1 to print the result.

Details

This function minimizes -2/n times the log likelihood ratio criterion:
crit = tr(S%*%invSigma)+log(det(Sigma)) - log(det(S)) - nvar
where S is the observed dispersion matrix, Sigma is the model dispersion matrix, invSigma is the inverse of Sigma, nvar is the # of variables, and n is the # of observations.
Note that n is not used during the course of estimation.

method="ML" uses Layley (1949)”s method.
method="EM" uses Rubin and Thayer (1982)”s method.
method="LS uses Harman and Jones (1966)”s method.

Given any Lambda matrix, estLambda=0 and method="EM" will give you the MLE of Psi given Lambda.

Value

A list of
Lambda Factor Loadings
Psi Scalar error variance
crit The value of criterion function.
nparam, aic # of parameters and aic
dcritN and dcritA The derivatives of the criterion.
method
dcritA and dcritN analutic and numeric derivative of the criterion function.

References

Harman, Harry and Jones, Wayne (1966) Factor analysis by minimizing residuals (minres), Psychometrika, 31, 3, 351-368.

Lawley, D.N. (1940) The estimation of factor loadings by the method of maximum likelihood. Proc. R. Soc. Edinb. A 60, 64-82.

Rubin, D.B., Thayer, T.T.(1982) EM algorithms for ML factor analysis. Psychometrika 47, 69-76.

Examples


# generate data as an Wishart RV
seed <- 1701
set.seed(seed)

nvar <- 20
ndim0 <- 5
ps <- 0.2
df <- 500

A <- matrix(runif(nvar*ndim0),nvar)
Sigma <- A%*%t(A)
Sigma <- Sigma+ps*diag(nvar)
dS <- sqrt(diag(Sigma))
Sigma <- diag(1/dS)%*%Sigma%*%diag(1/dS)

S <- rWishart( 1, df, Sigma )
S <- S[,,1]/df
dS <- sqrt(diag(S))
S <- diag(1/dS)%*%S%*%diag(1/dS)


# # of factors to be used in the following estimation
ndim <- 3

# Facrot correation matrix
phi <- 0.3
Phi1 <- (1-phi)*diag(ndim)+phi*matrix(1,ndim,ndim)

# Orthogonal LSE
resLS <- efa( S, ndim=ndim, method="LS", derivN=1, print=3 )
# Oblique LS (no change in crit)
resLS <- efa( S, ndim=ndim, method="LS", derivN=1, print=3, Phi=Phi1 )

# Orthogonal MLE by Lawley''s method
res <- efa( S, ndim=ndim, derivN=1, print=3 )
# Orthogonal MLE by EM algorithm
res2 <- efa( S, ndim=ndim, derivN=1, print=3, method="EM" )

# Specification of Phi: No improvement of the likelihood.
# Oblique MLE by Lawley''s method
res3 <- efa( S, ndim=ndim, derivN=1, print=3, Phi=Phi1 )
# Oblique MLE by EM
res4 <- efa( S, ndim=ndim, derivN=1, print=3, Phi=Phi1, method="EM" )


# get MLE of Lambda given psi=0.1: No change in crit.
# Orthogonal MLE by Lawley''s method
res5 <- efa( S, ndim=ndim, estpsi=0, psi=rep(0.1,nvar), method="ML"
            , derivN=1, print=3 )
res6 <- efa( S, ndim=ndim, estpsi=0, psi=rep(0.1,nvar), method="EM"
            , derivN=1, print=3 )
# Oblique MLE by EM
res7 <- efa( S, ndim=ndim, estpsi=0, psi=rep(0.1,nvar), method="ML"
            , derivN=1, print=3, Phi=Phi1 )
res8 <- efa( S, ndim=ndim, estpsi=0, psi=rep(0.1,nvar), method="EM"
            , derivN=1, print=3, Phi=Phi1 )


# get MLE of psi given Lambda0: Cannot use Layley's method here.
Lambda0 <- A[,1:ndim]
Lambda0[abs(Lambda0)<0.1] <- 0
# Orthogonal MLE by EM
res9 <- efa( S, ndim=ndim, estLambda=0, Lambda=Lambda0, method="EM"
          , derivN=1, print=3 )
# Oblique MLE by EM: slightly better fit.
res10 <- efa( S, ndim=ndim, estLambda=0, Lambda=Lambda0, method="EM"
            , derivN=1, print=3, Phi=Phi1 )


[Package lazy.fa version 0.1.3 Index]