Skip to contents

Plots the histogram of the residuals of a VAR model, or of the variables in a dataset, possibly overlapped with a normal curve.

Usage

ggvar_distribution(
  x,
  series = NULL,
  plot_normal = TRUE,
  args_histogram = list(bins = 30),
  args_line = list(),
  args_labs = list(),
  args_facet = list(),
  ...
)

Arguments

x

Either a "varest" object for plotting the residuals, or an dataset (object coercible to data.frame) with numeric variables.

series

A character vector with series (variables) to consider. Defaults to all (NULL).

plot_normal

Logical, whether or not a normal curve should be plotted.

args_histogram, args_line

Additional arguments passed to geom_histogram and geom_line (respectively). See more in the 'Customization' section.

args_labs

Additional arguments passed to labs. If an empty list, will be changed to default values.

args_facet

Additional arguments passed to the faceting engine used.

...

Arguments passed to methods, see the 'Methods' section.

Value

A ggplot.

Details

Customization

The graph can be customized both with the 'static' arguments passed to each layer – using the args_* arguments –, and, if applicable, the 'dynamic' aesthetics – using the args_aes argument.

After built, the result can be further customized as any ggplot, adding or overwriting layers with the ggplot's +. It is useful to understand the data and the mappings coded by the package, using the function get_gg_info.

See vignette('customizing-graphs') for more details.

Methods

The data from x is extracted with the generic function texts_vec. Each class conditions an external function to pass the ... arguments to. Below there is a list with all the currently implemented classes:

  • Class 'varest': passed to nothing.

  • Class 'default': passed to nothing.

See also

Other model diagnostics plots: ggvar_acf(), ggvar_dispersion(), ggvar_history(), ggvar_select(), ggvar_stability()

Other general time series plots: ggvar_acf(), ggvar_history()

Examples

ggvar_distribution(vars::VAR(freeny[-2]))