Description Usage Arguments Value Author(s) References See Also Examples
Perform Bayesian factor analysis by sampling the posterior distribution of parameters in a factor model with the Multiplicative Gamma Shrinkage Prior of Bhattacharya and Dunson
1 2 3 4 5 6 |
X |
Data matrix (n x p) |
nrun |
number of iterations |
burn |
burn-in period |
thin |
thinning interval |
prop |
proportion of elements in each column less than epsilon in magnitude cutoff |
epsilon |
tolerance |
kinit |
initial value for the number of factors |
adapt |
logical. Whether or not to adapt number of factors across sampling |
output |
output type, a vector including some of: c("covMean", "covSamples", "factSamples", "sigSamples", "numFactors") |
verbose |
logical. Show progress bar? |
dump |
logical. Save output object during sampling? |
filename |
if dump, filename for output |
buffer |
if dump, frequency of saving |
augment |
additional sampling steps as an expression |
some of:
covMean |
X covariance posterior mean |
omegaSamps |
X covariance posterior samples |
lambdaSamps |
Posterior factor loadings samples (rotationally ambiguous) |
etaSamps |
Posterior factor samples (rotationally ambiguous) |
sigmaSamps |
Posterior marginal variance samples (see notation in Bhattacharya and Dunson (2011)) |
numFacts |
Number of factors for each iteration |
Evan Poworoznek
Bhattacharya, Anirban, and David B. Dunson. "Sparse Bayesian infinite factor models." Biometrika (2011): 291-306.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | k0 = 5
p = 20
n = 50
lambda = matrix(rnorm(p*k0, 0, 0.01), ncol = k0)
lambda[sample.int(p, 40, replace = TRUE) +
p*(sample.int(k0, 40, replace = TRUE)-1)] = rnorm(40, 0, 1)
lambda[1:7, 1] = rnorm(7, 2, 0.5)
lambda[8:14, 2] = rnorm(7, -2, 0.5)
lambda[15:20, 3] = rnorm(6, 2, 0.5)
lambda[,4] = rnorm(p, 0, 0.5)
lambda[,5] = rnorm(p, 0, 0.5)
plotmat(varimax(lambda)[[1]])
X = matrix(rnorm(n*k0),n,k0)%*%t(lambda) + matrix(rnorm(n*p), n, p)
out = linearMGSP(X = X, nrun = 1000, burn = 500)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.