Learn R Programming

relabeLoadings (version 1.0)

relabel: Relabel Factor Loadings from MCMC output

Description

Uses the relabeling method of Erosheva and Curtis to correct for sign invariance in MCMC draws from confirmatory factor analysis (CFA) models.

Usage

relabel(obj, ...)
"relabel"(obj, ...)
"relabel"(obj, random = FALSE, max.iter = 100, ...)

Arguments

obj

An object of the appropriate class. Currently, the method is implemented only for objects of S3 class matrix. The matrix should contain the MCMC draws from a Bayesian CFA model where no arbitrary restrictions are imposed on the loadings to enforce rotational invariance. For example, no loadings should have been arbitrarily constrained to be one. Columns of the matrix must have names of the form "Lam[1,1]", "Lam[1,2]", ..., where indices denote the structure of the loading matrix, i.e., missing idices indicate loadings that are constrained to be zero.

random
Logical value. If TRUE, random starting points will be used. If FALSE, starting values are chosen roughly to allow the largest loadings on each factor to have a positive sign or to allow the majority of loadings on a given factor to have a positive sign.
max.iter
Integer that specifies the maximum number of iterations of the algorithm before aborting procedure.
...
Not used.

Value

An S3 object of class relabel with the following components:

Details

See the references.

References

Erosheva, E. A. and Curtis, S. M. (2011) "A relabeling scheme for confirmatory factor analysis." Technical report #589. University of Washington, Dept. of Statistics.

Examples

Run this code

n <- 1000
p <- 8
set.seed(1)
mu <- as.numeric(t(cbind(
    matrix(rep(sample(c(-1, 1), size=n, replace=TRUE)*4, each=8), n, 8, byrow=TRUE),
    matrix(rep(sample(c(-1, 1), size=n, replace=TRUE)*4, each=8), n, 4, byrow=TRUE),
    matrix(rep(sample(c(-1, 1), size=n, replace=TRUE)*4, each=8), n, 4, byrow=TRUE))))
Lam <- matrix(rnorm(length(mu), mu, 1.0), n, 16, byrow=TRUE)
colnames(Lam) <- c(paste0("Lam[", 1:p, ",", 1, "]"),
                   paste0("Lam[", 1:4, ",", 2, "]"),
                   paste0("Lam[", 5:8, ",", 3, "]"))

par(mfrow=c(2, 8))
apply(Lam, 2, function(x) plot(density(x)))

## Relabeling removes the bimodality
out <- relabel(Lam)

par(mfrow=c(2, 8))
apply(out$nuLam, 2, function(x) plot(density(x)))


Run the code above in your browser using DataLab