Description Usage Arguments Value
View source: R/factor_analysis_with_regression.R
The model is as follows:
y_i = α + Λ η_i + ε_i,
η_i = Bx_i + δ_i
ε_i \sim N_p(0, τ^{-1})
δ_i \sim N_k(0, I)
where τ = diag(τ_1, ..., τ_p).
See Joyee Ghosh & David B. Dunson (2009) Default Prior Distributions and Efficient Posterior Computation in Bayesian Factor Analysis, Journal of Computational and Graphical Statistics, 18:2, 306-320, DOI: 10.1198/jcgs.2009.07145.
1 2 3 4 5 6 7 8 9 10 11 | factor_analysis_with_regression <- function(
Y,
X,
k,
niter = 1,
shape_psi = 1/2,
rate_psi = 1/2,
shape_tau = 1,
rate_tau = 0.2,
coef_multiplier = 10,
nonzero_structure = NULL)
|
Y |
n by p matrix |
X |
n by f matrix |
k |
number of factors |
niter |
number of iterations for the gibbs sampler to run. |
shape_psi |
shape parameter for psi. Can be a scalar or a k vector |
rate_psi |
rate parameter for psi. Can be a k vector |
shape_tau |
shape parameter for sigma2. Can be a p vector |
rate_tau |
rate parameter for sigma2. Can be a p vector |
nonzero_structure |
A boolean p x k matrix. If the i, jth spot is TRUE, then λ_{ij} is free. If the i, jth spot is FALSE, then λ_{ij} is zero. If not set, then a lower triangular matrix is used. |
alpha |
An niter x p matrix of posterior values |
lambda |
An niter x p x k array of posterior values |
tau |
An niter x p matrix of posterior values |
eta |
An niter x n x k array of posterior values |
B |
An niter x k x f array of posterior values |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.