| Type: | Package |
| Title: | Bayesian Exploratory Factor Analysis |
| Version: | 0.0.0.6 |
| Date: | 2026-05-12 |
| Description: | Exploratory Bayesian factor analysis of continuous, mixed-type, and bounded continuous variables using the mode-jumping algorithm of Man and Culpepper (2020) <doi:10.1080/01621459.2020.1773833>. |
| License: | GPL-3 |
| SystemRequirements: | C++17 |
| Depends: | R (≥ 3.5.0) |
| Imports: | Rcpp (≥ 1.0.1) |
| LinkingTo: | Rcpp, RcppArmadillo |
| Encoding: | UTF-8 |
| LazyData: | true |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | yes |
| Packaged: | 2026-06-06 15:26:06 UTC; steve |
| Author: | Albert Man [aut],
Steven Andrew Culpepper
|
| Maintainer: | Steven Andrew Culpepper <sculpepp@illinois.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-06-12 11:20:14 UTC |
bayesefa: Bayesian Exploratory Factor
Description
Exploratory Bayesian factor analysis of continuous, mixed-type, and bounded continuous variables using the mode-jumping algorithm of Man and Culpepper (2020) doi:10.1080/01621459.2020.1773833.
Author(s)
Maintainer: Steven Andrew Culpepper sculpepp@illinois.edu (ORCID)
Authors:
Steven Andrew Culpepper sculpepp@illinois.edu (ORCID)
Albert Man aman3@illinois.edu
References
Man, A. & Culpepper, S. A. (2020). A mode-jumping algorithm for Bayesian factor analysis. Journal of the American Statistical Association, doi:10.1080/01621459.2020.1773833.
Exploratory Factor Analysis of Continuous Response Data
Description
Implement the Man and Culpepper (2020) mode-jumping algorithm to factor analyze continuous response data.
Usage
EFA_Mode_Jumper(Y, M, gamma, burnin, chain_length = 10000L)
Arguments
Y |
A N by J matrix of mean-centered, continuous variables. |
M |
An integer specifying the number of factors. |
gamma |
The value of the mode-jumping tuning parameter. Man and Culpepper (2020) used gamma = 0.5. |
burnin |
Number of burn-in iterations to discard. |
chain_length |
The total number of iterations (burn-in + post-burn-in). |
Value
A list that contains nsamples = chain_length - burnin array draws from the posterior distribution:
-
LAMBDA: A J by M by nsamples array of sampled loading matrices. -
PSIs: A J by nsamples matrix of vector of variable uniquenesses. -
ROW_OUT: A matrix of sampled row indices of founding variables for mode-jumping algorithm. -
F_OUT: An array of sampled factor scores. -
ACCEPTED: Acceptance rates for mode-jumping Metropolis-Hastings (MH) steps.
Author(s)
Steven Andrew Culpepper, Albert Man
References
Man, A. & Culpepper, S. A. (2020). A mode-jumping algorithm for Bayesian factor analysis. Journal of the American Statistical Association, doi:10.1080/01621459.2020.1773833.
Examples
data(exchangerate)
#Retain complete cases and drop Month_Year column
X<-exchangerate[complete.cases(exchangerate),-1]
X<-apply(X,2, diff)
X<-as.matrix(scale(X))
#Specify the number of factors
my_M<-2
#Run the mode-jumping EFA algorithm
burn_in<-150
chain_length<-300
out <- EFA_Mode_Jumper(X,my_M,gamma=0.5,burnin=burn_in,chain_length)
#Rotate all samples to permutation positive lower triangular (PPLT)
#structure with USD and FRF as factor founding variables
my_lambda_sample = out$LAMBDA
for (j in 1:dim(my_lambda_sample)[3]) {
my_rotate = proposal2(c(1,4),my_lambda_sample[,,j],out$F_OUT[,,j])
my_lambda_sample[,,j] = my_rotate$lambda
}
#compute posterior mean of PPLT loadings
mLambda<-apply(my_lambda_sample,c(1,2),mean)
Exploratory Item Factor Analysis for Ordinal Response Data
Description
Implement the Man and Culpepper (2020) mode-jumping algorithm to factor analyze ordinal response data. Missing values should be specified as a non-numeric value such as NA.
Usage
IFA_Mode_Jumper(Y, M, gamma, Ms, sdMH, burnin, chain_length = 10000L)
Arguments
Y |
A N by J matrix of item responses. |
M |
The number of factors. |
gamma |
Mode-jumping tuning parameter. Man & Culpepper used 0.5. |
Ms |
A vector of the number of score categories. Note 2 = two parameter normal ogive, >2 ordinal normal ogive. |
sdMH |
A vector of tuning parameters of length J for implementing the Cowles (1996) Metropolis-Hastings threshold sampler. |
burnin |
Number of burn-in iterations to discard. |
chain_length |
The total number of iterations (burn-in + post-burn-in). |
Value
A list that contains nsamples = chain_length - burnin array draws from the posterior distribution:
-
LAMBDA: A J by M by nsamples array of sampled loading matrices on the standardized metric. -
PSIs: A J by nsamples matrix of vector of variable uniquenesses on the standardized metric. -
ROW_OUT: A matrix of sampled row indices of founding variables for mode-jumping algorithm. -
THRESHOLDS: An array of sampled thresholds. -
INTERCEPTS: Sampled variable thresholds on the standardized metric. -
ACCEPTED: Acceptance rates for mode-jumping Metropolis-Hastings (MH) steps. -
MHACCEPT: A J vector of acceptance rates for item threshold parameters. Note that binary items have an acceptance rate of zero, because MH steps are never performed.
Author(s)
Albert X Man, Steven Andrew Culpepper
References
Cowles, M. K. (1996), Accelerating Monte Carlo Markov chain convergence for cumulative link generalized linear models," Statistics and Computing, 6, 101-111.
Man, A. & Culpepper, S. A. (2020). A mode-jumping algorithm for Bayesian factor analysis. Journal of the American Statistical Association, doi:10.1080/01621459.2020.1773833.
Exploratory Factor Analysis of Mixed-Type Responses
Description
Implement the Man and Culpepper (2020) mode-jumping algorithm to factor analyze mixed-type response data. Missing values should be specified as a non-numeric value such as NA.
Usage
IFA_Mode_Jumper_MixedResponses(
Y,
M,
gamma,
Ms,
sdMH,
bounds,
burnin,
chain_length = 10000L
)
Arguments
Y |
A N by J matrix of mixed-type item responses. |
M |
An interger specifying the number of factors. |
gamma |
The value of the mode-jumping tuning parameter. Man and Culpepper (2020) used gamma = 0.5. |
Ms |
model indicator where 0 = "bounded", 1 = "continuous", 2 = "binary", >2 = "ordinal". |
sdMH |
A J vector of tuning parameters for the Cowles (1996) Metropolis-Hastings sampler for ordinal data latent thresholds. |
bounds |
A J by 2 matrix denoting the min and max variable values. Note that bounds are only used for variable j if element j of Ms is zero. |
burnin |
Number of burn-in iterations to discard. |
chain_length |
The total number of iterations (burn-in + post-burn-in). |
Value
A list that contains nsamples = chain_length - burnin array draws from the posterior distribution:
-
LAMBDA: A J by M by nsamples array of sampled loading matrices on the standardized metric. -
PSIs: A J by nsamples matrix of vector of variable uniquenesses on the standardized metric. -
ROW_OUT: A matrix of sampled row indices of founding variables for mode-jumping algorithm. -
THRESHOLDS: An array of sampled thresholds. -
INTERCEPTS: Sampled variable thresholds on the standardized metric. -
ACCEPTED: Acceptance rates for mode-jumping Metropolis-Hastings (MH) steps. -
MHACCEPT: A J vector of acceptance rates for item threshold parameters. Note that binary items have an acceptance rate of zero, because MH steps are never performed. -
LAMBDA_unst: An array of unstandardized loadings. -
PSIs_inv_unst: A matrix of unstandardized uniquenesses. -
THRESHOLDS_unst: Unstandardized thresholds. -
INTERCEPTS_unst: Unstandardized intercepts.
Author(s)
Albert X Man, Steven Andrew Culpepper
References
Cowles, M. K. (1996), Accelerating Monte Carlo Markov chain convergence for cumulative link generalized linear models," Statistics and Computing, 6, 101-111.
Man, A. & Culpepper, S. A. (2020). A mode-jumping algorithm for Bayesian factor analysis. Journal of the American Statistical Association, doi:10.1080/01621459.2020.1773833.
International Exchange Rate Dataset
Description
This dataset was considered by West and Harrison (1997) and Lopes and West (2004). The dataset consists of n = 143 monthly first-differences of the exchange rates of 6 international currencies against the British pound, from Jan 1975 to Dec 1986, these currencies are: US dollar (USD), Canadian dollar (CAD), Japanese yen (JPY), French franc (FRF), German (deutsche) mark (DEM), and the Italian lira (ITL).
Usage
exchangerate
Format
A 143 by 7 matrix of exchange rate time-series. The variables include:
Month_YearMonth and year of exchange rate data.
USDUS dollar
CADCanadian dollar
JPYJapanese yen
FRFFrench franc
DEMGerman (deutsche) mark
ITLItalian lira
Author(s)
Steven Culpepper
Source
Lopes, H. F., and West, M. (2004). Bayesian model assessment in factor analysis, Statistica Sinica, 14, 41–67.
Man, A. & Culpepper, S. A. (2020). A mode-jumping algorithm for Bayesian factor analysis. Journal of the American Statistical Association, doi:10.1080/01621459.2020.1773833.
West, M., and Harrison, J. (1997), Bayesian forecasting and dynamic models (2nd ed.), Berlin, Heidelberg: Springer-Verlag.
Compute Deviance for Ordinal Probit Factor Model
Description
Internal function to compute -2LL using unstandardized parameters.
Usage
min2LL_ono(N, J, Y, MISS, as, bs, theta, Ms, Kaps)
Arguments
N |
The number of observations. (> 0) |
J |
The number of items. (> 0) |
Y |
A N by J matrix of item responses. |
MISS |
A N by J matrix of missing data indicators. |
as |
A matrix of item loadings. |
bs |
A vector of threshold parameters. |
theta |
A matrix of factor scores. |
Ms |
A vector of the number of score categories. Note 2 = two parameter normal ogive, >2 ordinal normal ogive. |
Kaps |
A matrix of category thresholds. |
Value
-2LL.
Author(s)
Steven Andrew Culpepper
Posterior Predictions of Item Factor Analysis with Mixed Response Types
Description
Generate posterior predictions for new variables using posterior samples.
Usage
mixedresponse_posterior_prediction(
OUTPUT,
Y,
Ms,
variable_predict_flag,
bounds,
n_mcmc_iterations = 10L
)
Arguments
OUTPUT |
A list of output from IFA_Mode_Jumper_MixedResponses. |
Y |
A N by J matrix of item responses for predictions. Variables to predict are indicated in Y by NAs. |
Ms |
model indicator where 0 = "bounded", 1 = "continuous", 2 = "binary", >2 = "ordinal". |
variable_predict_flag |
A J vector. 0 = do not predict the variable; 1 = predict the variable. |
bounds |
A J by 2 matrix denoting the min and max variable values. Note that bounds are only used for variable j if element j of Ms is zero. |
n_mcmc_iterations |
The number of Gibbs iterations for sampling posterior predictions for factor scores and missing data. The default is 10 iterations. |
Value
array of predictions for all posterior samples provided in OUTPUT.
Author(s)
Steven Andrew Culpepper
Rotate loadings and factor scores to a permuted positive lower triangle
Description
Rotates loading matrix according to specified founding variable row indices.
Usage
proposal2(new_r_idx, lambda, factors)
Arguments
new_r_idx |
vector of row indices of length equal to the number of factors. |
lambda |
Loading matrix. |
factors |
A n x m matrix of factor scores that is rotated. |
Value
A list of rotated loadings and factors.
Author(s)
Albert X Man