Creates a histogram or sequence of histograms of posterior means for factors \(f_{jk}\) or loadings \(\ell_{ik}\). One plot is created for each value of \(k\) in kset. Values are normalized so that the maximum absolute value for each factor \(f_{\cdot k}\) or set of loadings \(\ell_{\cdot k}\) is equal to 1 (see ldf.flash). If pm_groups is specified, then overlapping semi-transparent histograms are created, with one histogram per group specified by pm_groups. This option works best when the number of groups is small or when groups are well separated across components.

flash_plot_histogram(
  fl,
  order_by_pve = FALSE,
  kset = NULL,
  pm_which = c("factors", "loadings"),
  pm_subset = NULL,
  pm_groups = NULL,
  pm_colors = NULL,
  binwidth = NULL,
  bins = NULL,
  alpha = 0.5,
  ...
)

Arguments

fl

An object inheriting from class flash.

order_by_pve

If order_by_pve = TRUE, then factor/loadings pairs will be ordered according to proportion of variance explained, from highest to lowest. (By default, they are plotted in the same order as kset; or, if kset is NULL, then they are plotted in the same order as they are found in fl.)

kset

A vector of integers specifying the factor/loadings pairs to be plotted. If order_by_pve = FALSE, then kset also specifies the order in which they are to be plotted.

pm_which

Whether to plot loadings \(L\) or factors \(F\).

pm_subset

A vector of row indices \(i\) or column indices \(j\) (depending on the argument to pm_which) specifying which values \(\ell_{i \cdot}\) or \(f_{j \cdot}\) are to be shown. If the dataset has row or column names, then names rather than indices may be specified. If pm_subset = NULL, then all values will be plotted.

pm_groups

A vector specifying the group to which each row of the data \(y_{i \cdot}\) or column \(y_{\cdot j}\) belongs (groups may be numeric indices or strings). A group must be provided for each plotted row \(i\) or column \(j\), so that the length of pm_groups is exactly equal to the number of rows or columns in the full dataset or, if pm_subset is specified, in the subsetted dataset.

pm_colors

A character vector specifying a color for each unique group specified by pm_groups. Defines the color and fill of the histograms.

binwidth

The width of the bins (a numeric value). The default is to use the number of bins in bins, covering the range of the data.

bins

Number of bins. Overriden by binwidth. Defaults to 30.

alpha

A transparency value between 0 (transparent) and 1 (opaque).

...

Additional arguments to be passed to facet_wrap (e.g., nrow or ncol).

Value

A ggplot object.