Learn R Programming

ufs (version 0.5.12)

factorLoadingHeatmap: Two-dimensional visualisation of factor analyses

Description

This function uses the diamondPlot() to visualise the results of a factor analyses. Because the factor loadings computed in factor analysis are point estimates, they may vary from sample to sample. The factor loadings for any given sample are usually not relevant; samples are but means to study populations, and so, researchers are usually interested in population values for the factor loadings. However, tables with lots of loadings can quickly become confusing and intimidating. This function aims to facilitate working with and interpreting factor analysis based on confidence intervals by visualising the factor loadings and their confidence intervals.

Usage

factorLoadingHeatmap(
  fa,
  xlab = "Factor Loading",
  colors = viridisPalette(max(2, fa$factors)),
  labels = NULL,
  showLoadings = FALSE,
  heatmap = FALSE,
  theme = ggplot2::theme_minimal(),
  sortAlphabetically = FALSE,
  digits = 2,
  labs = list(title = NULL, x = NULL, y = NULL),
  themeArgs = list(panel.grid = ggplot2::element_blank(), legend.position = "none",
    axis.text.x = ggplot2::element_blank()),
  ...
)

Value

A ggplot2::ggplot() plot with several ggDiamondLayer()s is returned.

Arguments

fa

The object produced by the psych::fa() function from the psych::psych package. It is important that the n.iter argument of psych::fa() was set to a realistic number, because otherwise, no confidence intervals will be available.

xlab

The label for the x axis.

colors

The colors used for the factors. The default uses the discrete viridis palette, which is optimized for perceptual uniformity, maintaining its properties when printed in grayscale, and designed for colourblind readers.

labels

The labels to use for the items (on the Y axis).

showLoadings

Whether to show the factor loadings or not.

heatmap

Whether to produce a heatmap or use diamond plots.

theme

The ggplot2 theme to use.

sortAlphabetically

Whether to sort the items alphabetically.

digits

Number of digits to round to.

labs

The labels to pass to ggplot2.

themeArgs

Additional theme arguments to pass to ggplot2.

...

Additional arguments will be passed to ggDiamondLayer(). This can be used to set, for example, the transparency (alpha value) of the diamonds to a lower value using e.g. alpha=.5.

Author

Gjalt-Jorn Peters

Maintainer: Gjalt-Jorn Peters gjalt-jorn@userfriendlyscience.com

See Also

psych::fa()ss, meansDiamondPlot(), meanSDtoDiamondPlot(), diamondPlot(), ggDiamondLayer()

Examples

Run this code

if (FALSE) {
### (Not run during testing because it takes too long and
###  may generate warnings because of the bootstrapping of
###  the confidence intervals)

factorLoadingHeatmap(psych::fa(psych::Bechtoldt,
                               nfactors=2,
                               n.iter=50,
                               n.obs=200));

### And using a lower alpha value for the diamonds to
### make them more transparent

factorLoadingHeatmap(psych::fa(psych::Bechtoldt,
                               nfactors=2,
                               n.iter=50,
                               n.obs=200),
                     alpha=.5,
                     size=1);
}

Run the code above in your browser using DataLab