MegaLMM parameters are all matrices. Parameters related to the factor loadings matrix Lambda all have K rows. Factors related to the factor scores all have K columns. Some parameters only have 1 row or column, but are still stored as matrices. Posterior samples of these parameters are arrays with dimensions: Ixnxm for I samples of a parameter with dimensions nxm.

traceplot_array(
  sample_array,
  facet_dim = 2,
  name = "param",
  n_per_facet = 5,
  mask = NULL,
  include_zero = TRUE
)

Arguments

sample_array

Ixnxm array of posterior samples for a matrix of dimension nxm

facet_dim

either 2 or 3, giving the dimension of sample_array that should be used as the facets

name

string giving a name to assign to the plot. The file will be a pdf booklet stored in the `run_ID` folder with this name.

n_per_facet

maximum number of values to make traces per facet

mask

optional nxm logical matrix giving values of the parameter matrix that should NOT be plotted

include_zero

should each facet include the value zero?

Value

None

Details

This function makes trace plots of parameters using a faceting scheme to try to display as many parameter traces as possible in an organized way. In all plots, the sample number will be the x-axis. The plot(s) will be divided into facets by either the second (default) or 3rd dimension of the sample_array. Within a facet there will be lines showing the traces of individual values within that dimension of the matrix. In cases where the matrix is large in that dimension, only the n_per_facet traces with the largest (absolute) posterior mean will be shown, as these are probably the most important.

Sometimes (particularly in a cross-validation framework) we may have a matrix with many parameters, but only some of them are interesting to inspect traces. You can supply an nxm logical matrix mask where TRUE means the value will be masked from the plot, and FALSE means the value will be plotted.

Examples

traceplot_array(load_posterior_param(MegaLMM_state,'Lambda'),2,'Lambda')
#> Error: object 'MegaLMM_state' not found