# NOT RUN {
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)
# }
Run the code above in your browser using DataLab