plot.multi: Plot Model Fits for a 'multi' Object

View source: R/class_plot.R

plot.multiR Documentation

Plot Model Fits for a 'multi' Object

Description

S3 method for class 'multi'. plot.multi creates plots for objects of class multi, using the R base plotting framework. Plots of all model fits, the multimodel SAR curve (with confidence intervals) and a barplot of the information criterion weights of the different models can be constructed.

Usage

## S3 method for class 'multi'
plot(
  x,
  type = "multi",
  allCurves = TRUE,
  xlab = NULL,
  ylab = NULL,
  pch = 16,
  cex = 1.2,
  pcol = "dodgerblue2",
  ModTitle = NULL,
  TiAdj = 0,
  TiLine = 0.5,
  cex.main = 1.5,
  cex.lab = 1.3,
  cex.axis = 1,
  yRange = NULL,
  lwd = 2,
  lcol = "dodgerblue2",
  mmSep = FALSE,
  lwd.Sep = 6,
  col.Sep = "black",
  pLeg = TRUE,
  modNames = NULL,
  cex.names = 0.88,
  subset_weights = NULL,
  confInt = FALSE,
  ...
)

Arguments

x

An object of class 'multi'.

type

The type of plot to be constructed: either type = multi for a plot of the multimodel SAR curve, or type = bar for a barplot of the information criterion weights of each model.

allCurves

A logical argument for use with type = multi that specifies whether all the model fits should be plotted with the multimodel SAR curve (allCurves = TRUE; the default) or that only the multimodel SAR curve should be plotted (allCurves = FALSE).

xlab

Title for the x-axis. Only for use with type = multi.

ylab

Title for the y-axis.

pch

Plotting character (for points). Only for use with type = multi.

cex

A numerical vector giving the amount by which plotting symbols (points) should be scaled relative to the default.

pcol

Colour of the points. Only for use with type = multi.

ModTitle

Plot title (default is ModTitle = NULL, which reverts to "Multimodel SAR" for type = multi and to "Model weights" for type = bar). For no title, use ModTitle = "".

TiAdj

Which way the plot title is justified.

TiLine

Places the plot title this many lines outwards from the plot edge.

cex.main

The amount by which the plot title should be scaled relative to the default.

cex.lab

The amount by which the axis titles should be scaled relative to the default.

cex.axis

The amount by which the axis labels should be scaled relative to the default.

yRange

The range of the y-axis. Only for use with type = multi.

lwd

Line width. Only for use with type = multi.

lcol

Line colour. Only for use with type = multi.

mmSep

Logical argument of whether the multimodel curve should be plotted as a separate line (default = FALSE) on top of the others, giving the user more control over line width and colour. Only for use with type = multi and allCurves = TRUE.

lwd.Sep

If mmSep = TRUE, the line width of the multimodel curve.

col.Sep

If mmSep = TRUE, the colour of the multimodel curve.

pLeg

Logical argument specifying whether or not the legend should be plotted (when type = multi and allCurves = TRUE).

modNames

A vector of model names for the barplot of weights (when type = bar). The default (modNames = NULL) uses abbreviated versions (see below) of the names from the sar_average function.

cex.names

The amount by which the axis labels (model names) should be scaled relative to the default. Only for use with type = bar.

subset_weights

Only create a barplot of the model weights for models with a weight value above a given threshold (subset_weights). Only for use with type = bar.

confInt

A logical argument specifying whether confidence intervals should be plotted around the multimodel curve. Can only be used if confidence intervals have been generated in the sar_average function.

...

Further graphical parameters (see par, plot.default,title, lines) may be supplied as arguments.

Note

In some versions of R and R studio, when plotting all model fits on the same plot with a legend it is necessary to manually extend your plotting window (height and width; e.g. the 'Plots' window of R studio) before plotting to ensure the legend fits in the plot. Extending the plotting window after plotting sometimes just stretches the legend.

Occasionally a model fit will converge and pass the model fitting checks (e.g. residual normality) but the resulting fit is nonsensical (e.g. a horizontal line with intercept at zero). Thus, it can be useful to plot the resultant 'multi' object to check the individual model fits. To re-run the sar_average function without a particular model, simply remove it from the obj argument.

For visual interpretation of the model weights barplot it is necessary to abbreviate the model names when plotting the weights of several models. To plot fewer bars, use the subset_weights argument to filter out models with lower weights than a threshold value. To provide a different set of names use the modNames argument. The model abbreviations used as the default are:

  • Pow = Power

  • PowR = PowerR

  • E1 = Extended_Power_model_1

  • E2 = Extended_Power_model_2

  • P1 = Persistence_function_1

  • P2 = Persistence_function_2

  • Loga = Logarithmic

  • Kob = Kobayashi

  • MMF = MMF

  • Mon = Monod

  • NegE = Negative_exponential

  • CR = Chapman_Richards

  • CW3 = Cumulative_Weibull_3_par.

  • AR = Asymptotic_regression

  • RF = Rational_function

  • Gom = Gompertz

  • CW4 = Cumulative_Weibull_4_par.

  • BP = Beta-P_cumulative

  • Logi = Logistic(Standard)

  • Hel = Heleg(Logistic)

  • Lin = Linear_model

Examples

data(galap)
#plot a multimodel SAR curve with all model fits included
fit <- sar_average(data = galap, grid_start = "none")
plot(fit)

#remove the legend
plot(fit, pLeg = FALSE)

#plot just the multimodel curve
plot(fit, allCurves = FALSE, ModTitle = "", lcol = "black")

#plot all model fits and the multimodel curve on top as a thicker line
plot(fit, allCurves = TRUE, mmSep = TRUE, lwd.Sep = 6, col.Sep = "orange")

#Plot a barplot of the model weights
plot(fit, type = "bar")
#subset to plot only models with weight > 0.05
plot(fit, type = "bar", subset_weights = 0.05)

txm676/sars documentation built on Nov. 20, 2023, 7:29 p.m.