Add a statline to an scplot

add_statline(
  object,
  stat = c("mean", "median", "min", "max", "quantile", "sd", "mad", "trend", "trendA",
    "trendA theil-sen", "moving mean", "moving median", "loreg", "lowess", "loess"),
  phase = NULL,
  color = NULL,
  linewidth = NULL,
  linetype = NULL,
  variable = NULL,
  ...
)

Arguments

object

An scplot object (class scplot) returned from the scplot() function.

stat

A character string for defining a statistical line or curve to be plotted.

phase

Either a numeric or a character vector specifying the reference phase (see details)

color

A character string or a number defining the color of an element.

linewidth

A number with the width of the line.

linetype

A character string with the line type: "solid", "dashed", "dotted"

variable

Name of the dataline variable to apply the style.

...

additional parameters passed to the statistical function.

Value

An object of class scplot (seescplot()) with changed element statlines.

Details

The phase argument defines the reference phase for some statistical functions ("median", "mean", "min", "max", "quantile"). The default is NULL which calculates and plots statistics for each phase separately. The arguments takes a numeric vector (phase number(s)) or a character vector (phase name(s)). When more than one phase is defines, statistics are based on the combined values of these phases. Various methods for an extrapolated trendA line exist: "trendA" is based on an OLS regression, "trendA theil-sen" on a nonparametric regression, and "trendA bisplit" / "trendA trisplit" are two median based approaches. Some of the functions defined in stats have additional arguments. The mean() function has a trim argument (e.g. trim = 0.1). quantile() has a proportion argument (e.g. prob = 0.75 for calculating the 75% quantile). moving mean and moving median have a lag argument (e.g. lag = 2). The local-regression curve function "lowess" (or "loreg") has a proportion argument (e.g. f = 0.5; see lowess()) and the local-regression curve function "loess" has a span argument (e.g. span = 0.75; see loess()).