EFA_Mode_Jumper: Exploratory Factor Analysis of Continuous Response Data

Description Usage Arguments Value Author(s) References Examples

View source: R/RcppExports.R

Description

Implement the Man and Culpepper (2020) mode-jumping algorithm to factor analyze continuous response data.

Usage

1
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:

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)
      

bayesefa documentation built on Feb. 10, 2021, 5:10 p.m.