Skip to content

Commit

Permalink
version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Keefe Murphy authored and cran-robot committed May 29, 2017
1 parent a225be7 commit 6c09a45
Show file tree
Hide file tree
Showing 39 changed files with 713 additions and 259 deletions.
15 changes: 7 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
Package: IMIFA
Type: Package
Date: 2017-05-09
Date: 2017-05-29
Title: Fitting, Diagnostics, and Plotting Functions for Infinite
Mixtures of Infinite Factor Analysers and Related Models
Version: 1.2.0
Version: 1.2.1
Authors@R: c(person("Keefe", "Murphy", email = "keefe.murphy@ucd.ie", role = c("aut", "cre")),
person("Isobel Claire", "Gormley", role = "ctb"),
person("Cinzia", "Viroli", role = "ctb"))
Description: Provides flexible Bayesian estimation of Infinite Mixtures of Infinite Factor Analysers and related models, for nonparametrically clustering high-dimensional data, introduced by Murphy et al. (2017) <https://arxiv.org/abs/1701.07010>. The IMIFA model conducts Bayesian nonparametric model-based clustering with factor analytic covariance structures without recourse to model selection criteria to choose the number of clusters or cluster-specific latent factors, mostly via efficient Gibbs updates. Model-specific diagnostic tools are also provided, as well as many options for plotting results and conducting posterior inference on parameters of interest.
Description: Provides flexible Bayesian estimation of Infinite Mixtures of Infinite Factor Analysers and related models, for nonparametrically clustering high-dimensional data, introduced by Murphy et al. (2017) <arXiv:1701.07010>. The IMIFA model conducts Bayesian nonparametric model-based clustering with factor analytic covariance structures without recourse to model selection criteria to choose the number of clusters or cluster-specific latent factors, mostly via efficient Gibbs updates. Model-specific diagnostic tools are also provided, as well as many options for plotting results and conducting posterior inference on parameters of interest.
Depends: R (>= 3.3.2)
License: GPL (>= 2)
Encoding: UTF-8
URL: https://cran.r-project.org/package=IMIFA
BugReports: https://github.com/Keefe-Murphy/IMIFA
Imports: abind, corpcor, e1071, gclus, graphics, grDevices, MASS,
matrixcalc, matrixStats, mclust, MCMCpack, mvnfast, plotrix,
Rfast, slam, stats, utils, viridis
Imports: abind, e1071, graphics, grDevices, matrixStats, mclust,
mvnfast, plotrix, Rfast, slam, stats, utils, viridis
Suggests: Rmpfr, gmp, knitr, methods, rmarkdown
RoxygenNote: 6.0.1
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2017-05-09 10:35:24 UTC; Keefe
Packaged: 2017-05-29 18:06:27 UTC; Keefe
Author: Keefe Murphy [aut, cre],
Isobel Claire Gormley [ctb],
Cinzia Viroli [ctb]
Maintainer: Keefe Murphy <keefe.murphy@ucd.ie>
Repository: CRAN
Date/Publication: 2017-05-09 21:22:18 UTC
Date/Publication: 2017-05-29 21:27:51 UTC
73 changes: 38 additions & 35 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
50e0cd13bc322106b9c3da93d80c469f *DESCRIPTION
624bbcf624e2049b9b204898dc518cc6 *NAMESPACE
7c19cfc89f02f0a80a3e2e031dfc0f8d *R/Diagnostics.R
b7b0c15edfd113aef0b0e642ccbc3670 *R/FullConditionals.R
8fbef014b257ab9a86b71d689c541ee1 *DESCRIPTION
95b024647b60e3f9c11b1f5cddb7bb17 *NAMESPACE
391f8dda881be954ca8da43ae7c7a5ea *NEWS.md
be0384a926c98b040e176084bb088478 *R/Diagnostics.R
3ea94817414d18c67901c9849ab91d62 *R/FullConditionals.R
655d03b12cbf713a2a097bb973de74ed *R/Gibbs_FA.R
38026b02c0bdb8a2c40f194d8f125734 *R/Gibbs_IFA.R
f219a3368bec7eed3e588c5e57d63f00 *R/Gibbs_IMFA.R
a6b7af21b4b94ad2857a662596051cfd *R/Gibbs_IMIFA.R
f38370352fa84b2ea88420c2e0edda87 *R/Gibbs_MFA.R
8df0c804f817f8e459df5bc5ef791e20 *R/Gibbs_MIFA.R
e5fcd052ef59e4bf692a7bc9decd8f25 *R/Gibbs_OMFA.R
3e2c197ea4bcd70d959bcb6566d7c359 *R/Gibbs_OMIFA.R
8ec5bd0be27809ed117678e021b6cadd *R/IMIFA.R
4d3dc1d09dae76e2003b726d75ace274 *R/MainFunction.R
29d54efb2d3eadb9783657e0915ba611 *R/PlottingFunctions.R
937984c71035f0b5b96c328f9b7489bb *R/SimulateData.R
c970958719b976dd9e6de080aec22c32 *R/Gibbs_IMFA.R
ec3f3d6624b65257a634a288b8eef0f2 *R/Gibbs_IMIFA.R
d5043fd053925e875f390f7aac7be5ae *R/Gibbs_MFA.R
ebb07e5e8eacdf4ad8a0759b33990073 *R/Gibbs_MIFA.R
117b7b6cca7149d6b75f22f6b0d9dc10 *R/Gibbs_OMFA.R
c85f11bca841e53a725cb0aaea6a226c *R/Gibbs_OMIFA.R
ebd02fe24220a83120fabdeafd357579 *R/IMIFA.R
f0eda2478bc4bfb52f7d7e66c133d02d *R/MainFunction.R
19a73413ced425c3685e7eb9a4958939 *R/PlottingFunctions.R
0cb8c8cd01e93c694eeede23e44434b7 *R/SimulateData.R
4e1464abd196123142e032a066f9628c *R/data.R
7f959bd5a95cfbabefe04b13ec8e7ee5 *README.md
67451aae22ea6399aa7705ac5d0432c1 *README.md
1888491b0f83f4166b5d387d781d75e0 *build/vignette.rds
6deddc586bb3532833f3ffa6652327c3 *data/coffee.rda
34fbecb96149bd96a12e9bdd0dc94f98 *data/olive.rda
35897767046da44f57a24f436cd46bc0 *inst/doc/IMIFA.R
d1c99f20a417cfadaea18c04cec5d640 *inst/doc/IMIFA.Rmd
117fecf1aae4db4ac8999e01cdd93ff4 *inst/doc/IMIFA.html
cef5bbba6facd8c2d2d44ff8a356c36f *man/G_expected.Rd
0991f0ceb1fce6bb14350122baf7a501 *man/G_priorDensity.Rd
21dd03479979b194d5bfe475817d9f60 *man/G_variance.Rd
20ab03b697321dea3dd959dfe4b1c9f3 *man/IMIFA.Rd
91aa33d6480ca8714d4a71a61989cd86 *man/MGP_check.Rd
693caeb81aed0ab500047b0ec42410a2 *man/PGMM_dfree.Rd
61ecb99a3850512df5b19344b288d41a *man/Zsimilarity.Rd
906fec5f08c1de15c0dca6ab045a32e1 *inst/doc/IMIFA.R
c1641bafdad997671ab7c2ddd4778804 *inst/doc/IMIFA.Rmd
29255a5d4d5142805aa2d4a2dc59ff9d *inst/doc/IMIFA.html
07473dd71acd068b7a5309b80e066974 *man/G_expected.Rd
cdc3492cb586de9e9289f0da6b13179d *man/G_priorDensity.Rd
e96e63e5bd631174a4f467eab91dadab *man/G_variance.Rd
c3c87f2bc1320d1d273a4c3dd26408e2 *man/IMIFA.Rd
ea98d66316220f2c2c956f9cd24fd632 *man/MGP_check.Rd
3cd8e8dd2131c30fc675a3dfff90c43b *man/PGMM_dfree.Rd
4ccccdc0421273d74d56e172ed301483 *man/Zsimilarity.Rd
0a414a386768243e488b2cc37644e4da *man/coffee.Rd
a5f9720031513230b7c96fa047b7376d *man/get_IMIFA_results.Rd
5c166d18bd247a603c2fd049827c0629 *man/gumbel_max.Rd
d564d483938b43d6a13da35d211f51c9 *man/heat_legend.Rd
70052bcf745bf1e74fce45bcdb944a0d *man/mat2cols.Rd
917b217b87c9681ad4ba5b07d64d648b *man/mcmc_IMIFA.Rd
aa4a739849ca14b52183ec7b5a823d2e *man/get_IMIFA_results.Rd
a54f5eec1b0d2cda89e4f834acda0c4e *man/gumbel_max.Rd
35010a68b88a53f50983dec770c30260 *man/heat_legend.Rd
274e09ab4f05e234c4afd8b29bc4b415 *man/is.posi_def.Rd
a5262c1f6f648adbd5f47c4e48abf26e *man/mat2cols.Rd
9090634ec37d5d035ffde49f221d060b *man/mcmc_IMIFA.Rd
66f2ceddb66664646e63803a468d74ca *man/olive.Rd
c1e54f448fba630998db0fd3621ce86f *man/plot.Results_IMIFA.Rd
ff36c8f5d60b6ba84bb66d8aead7a2de *man/psi_hyper.Rd
a6ef83c11ea344659931d42ac3d15c59 *man/plot.Results_IMIFA.Rd
983d339b088d04942786e831742d2b51 *man/plot_cols.Rd
bfe7d96a2294c66843ca30f9071b97e6 *man/psi_hyper.Rd
c8e01465312349f111bd7d490330b805 *man/rDirichlet.Rd
972db30dc47e58421caf8eea2c50027e *man/sim_IMIFA_data.Rd
d1c99f20a417cfadaea18c04cec5d640 *vignettes/IMIFA.Rmd
e76622458d25f6d5db8540d6b31160be *vignettes/res_olive_IMIFA__Edited-Vignette-only-Version.rda
470011ea7014881b12674be3889d3222 *man/sim_IMIFA_data.Rd
c1641bafdad997671ab7c2ddd4778804 *vignettes/IMIFA.Rmd
c52793291f0e0f057c961e4b45f446f2 *vignettes/res_olive_IMIFA__Edited-Vignette-only-Version.rda
8 changes: 2 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export(Zsimilarity)
export(get_IMIFA_results)
export(gumbel_max)
export(heat_legend)
export(is.posi_def)
export(mat2cols)
export(mcmc_IMIFA)
export(plot_cols)
export(psi_hyper)
export(rDirichlet)
export(sim_IMIFA_data)
import(graphics)
import(stats)
importFrom(MASS,"ginv")
importFrom(MCMCpack,"procrustes")
importFrom(Rfast,"Order")
importFrom(Rfast,"Var")
importFrom(Rfast,"colMaxs")
Expand All @@ -40,19 +40,15 @@ importFrom(Rfast,"rowsums")
importFrom(Rfast,"sort_unique")
importFrom(Rfast,"standardise")
importFrom(abind,"adrop")
importFrom(corpcor,"is.positive.definite")
importFrom(corpcor,"make.positive.definite")
importFrom(e1071,"classAgreement")
importFrom(e1071,"matchClasses")
importFrom(gclus,"plotcolors")
importFrom(grDevices,"adjustcolor")
importFrom(grDevices,"col2rgb")
importFrom(grDevices,"heat.colors")
importFrom(grDevices,"palette")
importFrom(matrixStats,"rowLogSumExps")
importFrom(matrixStats,"rowMedians")
importFrom(matrixStats,"rowQuantiles")
importFrom(matrixcalc,"is.positive.semi.definite")
importFrom(mclust,"Mclust")
importFrom(mclust,"classError")
importFrom(mclust,"mclustBIC")
Expand Down
68 changes: 68 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
__Infinite Mixtures of Infinite Factor Analysers__
==================================================

# IMIFA v1.2.1 - (_3rd release [patch update]: 2017-05-29_)
## Improvements
* Posterior mean scores can now also be plotted in the form of a heat map (previously loadings only).
`load.meth` argument replaced by logical `heat.map` in `plot.Results_IMIFA`.
* `mat2cols` gains `compare` argument to yield common palettes/breaks for heat maps of multiple matrices:
Associated `plot_cols` function also fixed, and now unhidden.
* Removed certain dependencies with faster personal code: e.g. Procrustes rotation now quicker:
`IMIFA` no longer depends on the `corpcor`, `gclus`, `MASS`, `matrixcalc`, or `MCMCpack` libraries.

## Bug Fixes
* Used `par()$bg` (i.e. default `"white"`) for plotting zero-valued entries of similarity matrix.
* Range of data for labelling in `heat_legend` calculated correctly.
* `mcmc_IMIFA`'s `verbose` argument now governs printing of `message` & `cat` calls, but not `stop` or `warning`.
* Fixed storage and plotting of loadings, particularly when some but not all clusters have zero factors.
* Added `NEWS.md` to build.

# IMIFA v1.2.0 - (_2nd release [minor update]: 2017-05-09_)

## New Features
* Learning the Pitman-Yor `discount` & `alpha` parameters via Metropolis-Hastings now implemented.
Plotting function's `param` argument gains the option `discount` for posterior inference.
* Sped up simulating cluster labels from unnormalised log probabilities using the Gumbel-Max trick (Yellott, 1977):
`gumbel_max` replaces earlier function to sample cluster labels & is now unhidden/exported/documented.
* Added new plot when `plot.meth=GQ` for OM(I)FA/IM(I)FA methods depicting trace(s) of #s of active/non-empty groups.
* Added function `Zsimilarity` to summarise posterior clustering by the sampled labels with minimum
squared distance to a sparse similarity matrix constructed by averaging the adjacency matrices.
When optionally called inside `get_IMIFA_results`, the similarity matrix can be plotted via `plot.meth="zlabels"`.

## Improvements
* Metropolis-Hastings updates implemented for `alpha` when `discount` is non-zero, rather than usual Gibbs.
Mutation rate monitored rather than acceptance rate for Metropolis-Hastings updates of `discount` parameter.
* Fixed calculation of # 'free' parameters for `aic.mcmc` & `bic.mcmc` criteria when uniquenesses are isotropic:
`PGMM_dfree`, which calculates # 'free' parameters for _finite_ factor analytic mixture models is exported/documented.
This function is also used to add checks on the Dirichlet hyperparameter for OM(I)FA methods.
* DIC model selection criterion now also available for infinite factor models (previously finite only).
* `G_priorDensity` now better reflects discrete nature of the density, and plots for non-zero PY discount values.
* Posterior mean loadings heatmaps now also display a colour key legend via new function `heat_legend`.
* Avoided redundant simulation of stick-breaking/mixing proportions under both types of IM(I)FA slice sampler.
* Simulated (finite) mixing proportions w/ _Gamma(alpha, 1)_ trick (Devroye 1986, p.594) instead of `MCMCpack:rdirichlet`:
`rDirichlet` replaces earlier function to sample mixing proportions & is now unhidden/exported/documented.
* Deferred setting `dimnames` attributes in `mcmc_IMIFA` to `get_IMIFA_results`: lower memory burden/faster simulations.
* Jettisoned superfluous duplicate material in object outputted from `get_IMIFA_results` to reduce size/simplify access.
* IMFA/IMIFA `trunc.G` arg, the max allowable # active groups, defaults to `range.G` & # active groups now stored.
* Code sped up when G=1 by not simulating labels for OM(I)FA/IM(I)FA & not simulating mixing proportions for OM(I)FA.
* Reduced chance of crash by exceeding memory capacity; `score.switch` defaults to `FALSE` if # models ran is large.

## Bug Fixes
* 2<sup>nd</sup> IM(I)FA label switching move sped up/properly weighted to ensure uniform sampling of neighbouring cluster pairs.
* Offline label switching square assignment correction now permutes properly.
* Fixed factor score trace plots by extracting indices of stored samples using `Rfast::sort_unique` & rotating properly.
* Fixed adding of `rnorm` columns to scores matrix during adaptation, esp. when widest loadings matrix grows/shrinks.
* Fixed initialisation (& upper limit) of number of clusters for OM(I)FA/IM(I)FA, esp. when `N < P`.
* Updates of DP/PY `alpha` parameter now correctly depend on current # non-empty rather than active groups.
* Fixed density plots for parameters with bounded support, accounting for spike at zero for `discount`.
* Slightly rearranged order Gibbs updates take place, esp. to ensure means enter simulation of uniquenesses properly.
* Edited/robustified subsetting of large objects when storing `mcmc_IMIFA` output.
* Tightened controls for when certain parameters are not stored for posterior inference.
* Edited Ledermann upper bound `stop(...)` for finite factor models to `warning(...)`.
* Geometric rather than arithmetic mean used in derivation of single rate hyperparameter for PPCA's isotropic uniquenesses.
* Uniquenesses now stored correctly for all clustering methods.
* Indices of uncertain obs. returned (`get_IMIFA_results`)/printed (`plot.Results_IMIFA`) even when `zlabels` not supplied.
* Fixed behaviour of progress bar when `verbose=FALSE`.
* Fixed typos & expanded/clarified help documentation/vignette.

# IMIFA v1.1.0 - (_1st release: 2017-02-02_)
12 changes: 7 additions & 5 deletions R/Diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
#' @export
#' @importFrom Rfast "med" "rowMaxs" "standardise" "colMaxs" "rowVars" "rowmeans" "Order" "cova" "Var"
#' @importFrom abind "adrop"
#' @importFrom MCMCpack "procrustes"
#' @importFrom e1071 "matchClasses" "classAgreement"
#' @importFrom mclust "classError"
#' @importFrom matrixStats "rowMedians" "rowQuantiles"
#'
#' @seealso \code{\link{mcmc_IMIFA}}, \code{\link{plot.Results_IMIFA}}, \code{\link{Zsimilarity}}
#' @references Murphy, K., Gormley, I. C. and Viroli, C. (2017) Infinite Mixtures of Infinite Factor Analysers: Nonparametric Model-Based Clustering via Latent Gaussian Models, \code{https://arxiv.org/abs/1701.07010}
#' @references Murphy, K., Gormley, I. C. and Viroli, C. (2017) Infinite Mixtures of Infinite Factor Analysers: Nonparametric Model-Based Clustering via Latent Gaussian Models, \href{https://arxiv.org/abs/1701.07010}{arXiv:1701.07010}.
#'
#' @author Keefe Murphy
#'
#' @examples
#' # data(coffee)
Expand Down Expand Up @@ -262,9 +263,9 @@ get_IMIFA_results.IMIFA <- function(sims = NULL, burnin = 0L, thinning =
tmp.store <- tmp.store[[Q.ind]]
}
if(!inf.Q) {
Q <- if(length(n.fac) > 1) Q else n.fac
Q <- if(length(n.fac) > 1) Q else n.fac
Q.ind <- if(all(!Q.T, length(n.fac) > 1)) Q.ind else which(n.fac == Q)
Q <- setNames(if(length(Q) != G) rep(Q, G) else Q, gnames)
Q <- setNames(if(length(Q) != G) rep(Q, G) else Q, gnames)
if(all(inf.G, Q.T)) GQ.temp1$G <- rep(G, GQs)
if(is.element(method, c("OMFA", "IMFA")) && GQ1) {
GQ.temp1$G.CI <- lapply(seq_len(GQs), function(gq) GQ.temp1$G.CI[gq,])
Expand Down Expand Up @@ -621,7 +622,7 @@ get_IMIFA_results.IMIFA <- function(sims = NULL, burnin = 0L, thinning =
if(sw["l.sw"]) {
for(p in store) {
if(p %in% eta.store) {
proc <- MCMCpack::procrustes(X=as.matrix(lmat[,,p]), Xstar=l.temp)
proc <- .Procrustes(X=as.matrix(lmat[,,p]), Xstar=l.temp)
lmat[,,p] <- proc$X.new
if(sw["s.sw"]) {
rot <- proc$R
Expand Down Expand Up @@ -805,6 +806,7 @@ get_IMIFA_results.IMIFA <- function(sims = NULL, burnin = 0L, thinning =
ci.mu <- Filter(Negate(is.null), lapply(result, "[[", "ci.mu"))
means <- list(mus = mus, post.mu = post.mu, var.mu = var.mu, ci.mu = ci.mu)
}
sw["l.sw"] <- attr(sims, "Switch")["l.sw"] && !all(Q == 0)
if(sw["l.sw"]) {
lmats <- Filter(Negate(is.null), lapply(result, "[[", "loadings"))
post.load <- Filter(Negate(is.null), lapply(result, "[[", "post.load"))
Expand Down

0 comments on commit 6c09a45

Please sign in to comment.