Description Usage Arguments Value Author(s) References Examples
Implement the Man and Culpepper (2020) mode-jumping algorithm to factor analyze continuous response data.
1 | EFA_Mode_Jumper(Y, M, gamma, burnin, chain_length = 10000L)
|
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). |
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.
Steven Andrew Culpepper, Albert Man
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.