infinitefactor-package {infinitefactor} | R Documentation |
Bayesian Infinite Factor Models
Description
Sampler and post-processing functions for semi-parametric Bayesian infinite factor models, motivated by the Multiplicative Gamma Shrinkage Prior of Bhattacharya and Dunson (2011) <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3419391/>. Contains component C++ functions for building samplers for linear and 2-way interaction factor models using the multiplicative gamma and Dirichlet-Laplace shrinkage priors. The package also contains post processing functions to return matrices that display rotational ambiguity to identifiability through successive application of orthogonalization procedures and resolution of column label and sign switching. This package was developed with the support of the National Institute of Environmental Health Sciences grant 1R01ES028804-01.
Details
The DESCRIPTION file:
Package: | infinitefactor |
Type: | Package |
Title: | Bayesian Infinite Factor Models |
Version: | 1.0 |
Date: | 2020-03-30 |
Author: | Evan Poworoznek |
Maintainer: | Evan Poworoznek <infinitefactorpackage@gmail.com> |
Description: | Sampler and post-processing functions for semi-parametric Bayesian infinite factor models, motivated by the Multiplicative Gamma Shrinkage Prior of Bhattacharya and Dunson (2011) <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3419391/>. Contains component C++ functions for building samplers for linear and 2-way interaction factor models using the multiplicative gamma and Dirichlet-Laplace shrinkage priors. The package also contains post processing functions to return matrices that display rotational ambiguity to identifiability through successive application of orthogonalization procedures and resolution of column label and sign switching. This package was developed with the support of the National Institute of Environmental Health Sciences grant 1R01ES028804-01. |
License: | GPL-2 |
Imports: | Rcpp (>= 1.0.2) |
Depends: | reshape2, ggplot2, stats, utils |
LinkingTo: | Rcpp, RcppArmadillo |
Index of help topics:
amean Average over the third index of an array del_mg Sampler Components infinitefactor-package Bayesian Infinite Factor Models interactionDL Factor regression model with interactions using the Dirichlet-Laplace shrinkage prior interactionMGSP Factor regression model with interactions using the Multiplicative Gamma Shrinkage Prior jointRot Resolve rotational ambiguity in samples of factor loadings and factors jointly linearDL Sample Bayesian linear infinite factor models with the Dirichlet-Laplace prior linearMGSP Sample Bayesian linear infinite factor models with the Multiplicative Gamma Shrinkage Prior lmean Average elements of a list msf Resolve label and sign switching in random matrix samples plotmat Plot a matrix summat Summarise a matrix from posterior samples
Perform sampling with the linearMGSP() and linearDL() functions for linear factor models, or interactionMGSP() and interactionDL() functions for factor regression models including 2-way interactions. See jointRot() or msf() for postprocessing.
Author(s)
Evan Poworoznek
Maintainer: Evan Poworoznek <infinitefactorpackage@gmail.com>
References
Bhattacharya, Anirban, and David B. Dunson. "Sparse Bayesian infinite factor models." Biometrika (2011): 291-306.
Bhattacharya, Anirban, et al. "Dirichlet-Laplace priors for optimal shrinkage." Journal of the American Statistical Association 110.512 (2015): 1479-1490.
Ferrari, Federico, and David B. Dunson. "Bayesian Factor Analysis for Inference on Interactions." arXiv preprint arXiv:1904.11603 (2019).
Examples
k0 = 5
p = 20
n = 100
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, adapt = FALSE)
aligned = jointRot(out$lambdaSamps, out$etaSamps)
plotmat(lmean(aligned$lambda))