On this page

Draw the trajectories of each peel and of the full fit of a retrospective analysis, with Mohn's rho in each panel.

Usage

plot_retro(
  retro_result,
  rho_digits = 4,
  rho_position = "top_right",
  rho_size = 3.5,
  line_size = NULL,
  point_size = NULL,
  point_shape = 21,
  facet_scales = "free",
  facet_ncol = NULL,
  facet_nrow = NULL,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  font_family = NULL,
  title_size = NULL,
  axis_title_size = NULL,
  axis_text_size = NULL,
  strip_text_size = NULL,
  legend_text_size = NULL,
  x_breaks = NULL,
  base_theme = NULL,
  title_hjust = NULL,
  palette = NULL,
  colors = NULL,
  ...
)

Arguments

ArgumentDefaultDescription
retro_resultrequired

A list returned by retro_model(), retro_acl() or retro_alscl().

rho_digits4

Integer. Number of decimals of the Mohn's rho label. Default 4.

rho_position"top_right"

Character. Position of the Mohn's rho label, "top_right" (default), "top_left", "bottom_right" or "bottom_left". Letter case does not matter.

rho_size3.5

Numeric. Text size of the Mohn's rho label. Default 3.5.

line_sizeNULL

Numeric or NULL. Line width. NULL inherits the global line_size setting (1 under the default style, 1.5 under "classic"). While that setting keeps the value of the style, facets of more than four panels draw thinner lines.

point_sizeNULL

Numeric or NULL. Size of the points. NULL inherits the global point_size setting (default 2.5).

point_shape21

Numeric. Shape of the points that mark the last estimate of each peel. Default 21.

facet_scales"free"

Character. Axis scales of the panels, "fixed", "free", "free_x" or "free_y". Letter case does not matter.

facet_ncolNULL

Integer or NULL. Number of columns of panels. NULL chooses it from the number of panels, for example 5 × 3 for 15 panels and 6 × 4 for 23.

facet_nrowNULL

Integer or NULL. Number of rows of panels.

titleNULL

NULL (default) draws the default title, FALSE, NA or "" draws no title, and a character string draws that string; see acl_theme_set() for the default titles and the show_title setting.

xlabNULL

Character or NULL. Label of the x axis. NULL uses the global theme setting.

ylabNULL

Character or NULL. Label of the y axis. NULL uses the global theme setting.

font_familyNULL

Character or NULL. Font family of the text, which must be installed on the computer. NULL uses the global theme setting (default "sans").

title_sizeNULL

Numeric or NULL. Size of the plot title in pt. NULL uses the global theme setting (default 14).

axis_title_sizeNULL

Numeric or NULL. Size of the axis titles in pt. NULL uses the global theme setting (default 12).

axis_text_sizeNULL

Numeric or NULL. Size of the axis tick labels in pt. NULL uses the global theme setting (default 10).

strip_text_sizeNULL

Numeric or NULL. Size of the panel labels in pt. NULL uses the global theme setting (default 10).

legend_text_sizeNULL

Numeric or NULL. Size of the legend text in pt. NULL uses the global theme setting (default 10).

x_breaksNULL

Numeric vector or NULL. Positions of the x-axis breaks. NULL inherits the global x_breaks setting when at least one of its values lies on this axis; otherwise the breaks are chosen automatically.

base_themeNULL

Character or NULL. Name of the base ggplot2 theme, such as "bw", "minimal" or "theme_bw". NULL uses the global theme setting. Letter case does not matter.

title_hjustNULL

Numeric or NULL. Horizontal position of the title, 0 for left, 0.5 for centered and 1 for right. NULL uses the global theme setting.

paletteNULL

Character or NULL. Palette name ("default", "npg", "aaas", "nejm", "lancet", "jama"); NULL inherits acl_theme(). Native colors are interpolated when there are more peels than colors. With NULL under the default global palette, the full fit is orange and the earlier fits are greys, darkest for the first peel. Letter case does not matter.

colorsNULL

Character vector or NULL. Colors, one per fit, ordered by descending last time step of the data or named by it; every line needs a color. Given colors override palette.

...…

The former argument names facet_col and facet_row, accepted with a warning.

Value

A ggplot object, which can be styled further or saved with acl_save_plot().

Details

Compare the last estimate of each peel with the full fit at the same time step, and look at the whole trajectories as well as the mean rho. The Mohn's rho labels use font_family.

Each line is one fit and is identified by the last time step of its data. The legend is titled "Terminal year" for annual time steps and "Terminal period" for shorter ones, and quarterly time steps are labelled as in "2019 Q4", also when peel_step is above 1 (for example "2004 Q4" for annual peels of a quarterly model). Default colors follow the peel, so the fit with a given last time step has the same color whether or not another fit returned estimates. Under the default style the full fit is orange and drawn on top, and the peels are greys, darkest for the first peel; under another palette its colors are used in order. A fit that failed the numerical checks is drawn with a dashed line, and a "Numerical checks" legend is added. A requested fit without estimates, for example after a fit error, stays in the legend and is marked "(no estimates)". The subtitle names both kinds of fit, and each panel states how many requested peels are valid when Mohn's rho is withheld.

Additional details from R help

Each line is one fit and is identified by the last time step of its data. The legend is titled "Terminal year" for annual time steps and "Terminal period" for shorter steps, where quarters are labelled as in "2019 Q4". Default colors follow the retrospective peel, so the fit with a given terminal time step has the same color whether or not another fit returned estimates. A fit that failed the numerical checks is drawn with a dashed line, and a "Numerical checks" legend is added. A requested fit without estimates, for example after a fit error, stays in the legend and is marked "(no estimates)". The subtitle names both kinds of fit, and each panel states how many requested peels are valid when Mohn's rho is withheld.

Each panel leaves room for the rho text above the lines (below them for the bottom positions). With colors and palette NULL under the default global palette, the full fit is drawn again on top of the earlier fits.

Examples

Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.

Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
a <- run_acl(x, silent = TRUE)
b <- run_alscl(x, silent = TRUE)
ra <- retro_acl(x, nyear = 3, silent = TRUE)
rb <- retro_alscl(x, nyear = 3, silent = TRUE)
# Use objects defined above
plot_retro(rb, rho_digits = 3)
Example figure
Example figure: plot_retro(rb, rho_digits = 3)

See also

Search documentation