Skip to contents

Make a plot comparing PofZs and Pi values for all collections (or repunits)

Usage

plot_PofZ_vs_pi(
  X,
  mix_coll,
  by_repunit = TRUE,
  burn_in = 100,
  plot_flavor = c("normal", "bars_fully_expanded", "bars_expanded_and_ticked")[1],
  arrange_scaled_likelihood_ascending = FALSE,
  dimens = list(b = 1, fbox = 0.9, fgap = 0.15, fnext = 2, ftick = 0.15),
  more_plot_pars = list(boxplot_linewidth = 0.1, boxplot_outlier.stroke = 0.25,
    boxplot_outlier.size = 0.1, bar_linewidth = 0.02, tick_linewidth = 0.02),
  left_edge_fract = 0.1,
  Npi_text_size = 2,
  Npi_left_nudge = 0.005
)

Arguments

X

The return object from infer_mixture()

mix_coll

character name of the mixture_collection within X you want to plot results for.

by_repunit

logical. If true, do by reporting units rather than collections.

burn_in

discards the first burn_in sweeps when handling the pi_traces (for the boxplots of the pi)

plot_flavor

a string giving the possibilities: "normal": the there is no scaling on the bar plots. "bars_fully_expanded": the horizontal barplots (and boxplots) are drawn on an expanded scale so that the larger of the sum of posteriors or the sum of scaled likelihoods is set to the value of N * pi_big, where pi_big is the largest mixing proportion and N is the sample size. This allows us to see things that are otherwise more squashed down for the rare stocks. "bars_expanded_and_ticked" bars are expanded, but any group with a sum over individuals of PofZ or scaled_likelihood which is less than 1 will not reach all the way to N * pi_big. Tick marks are drawn on the bars starting from the right end and proceeding at a constant distance that is equal to a single fish with PofZ (top bar) or Scaled Likelihood (bottom bar) of 1.0. This helps to gauge how far off from 1.0 the individual cells are. Note that if the sum of all the PofZ's (or of the scaled likelihoods) is less than 1.0, let's say it is f, then the first tick mark will go at the far right side still, but all the other values will be shrunk down so that the sum is f * the max right side value. This lets us see visually those groups with a cumulative posterior prob across individuals of less than 1.0.

arrange_scaled_likelihood_ascending

If this is TRUE, then the barplot for scaled likelihood has individuals sorted according to their scaled likelihoods. The default is FALSE, in which case the scaled likelihoods are sorted according to the PofZ. This is better as, I think, as it shows how the interaction of the scaled likelihood and the prior means PofZ is not simply an increasing function of scaled likelihood. If you want to use this, then expand_bars will be set to TRUE.

dimens

named list of relative heights of bars and boxplots. b is relative height of bar, fbox is factor by which the boxplot differs from b, fgap is the fraction of b that is the gap between boxplot and bar and fnext is the number of b's between the bottom of the bottom bar and the top of the next boxplot. ftick is the length of the ticks along the bars (when using "bars_expanded_and_ticked) as a fraction of the bar height, b.

more_plot_pars

a list of additional plot pars with self-explanatory names: boxplot_linewidth, boxplot_outlier.stroke, boxplot_outlier.size, bar_linewidth,

left_edge_fract

the fraction of the sample size to put the lower xlim. Make this larger to keep the N x pi number text from getting cut off.

Npi_text_size

size of text giving the N x pi number

Npi_left_nudge

how much to nudge the N x pi text to the left, away from the start of the bar. Given as a fraction of the sample size.