plot_residual_plot: Create residual plot

View source: R/PlotResidualPlot.R

plot_residual_plotR Documentation

Create residual plot

Description

Create a figure that plots the residuals of the data. These residuals are the difference between expected normal quantiles and observed quantiles.

Usage

plot_residual_plot(
  x,
  transformer,
  centre_width = NULL,
  show_original = TRUE,
  use_alpha = TRUE,
  use_absolute_deviation = TRUE,
  ggtheme = NULL
)

Arguments

x

A vector with numeric values that should be transformed to normality.

transformer

A transformer object created using find_transformation_parameters.

centre_width

A numeric value between 0.0 and 1.0 that describes the width of the centre of the data. Can be NULL.

show_original

Show residuals for original, untransformed, data in addition to transformed data.

use_alpha

Use transparency for points in case the data contains many instances.

use_absolute_deviation

Plot absolute deviation instead of residuals.

ggtheme

ggplot2 theme to use for the plot. If not provided, ggplot2::theme_light is used.

Value

A ggplot2 plot object for a Q-Q plot.

Examples

x <- exp(stats::rnorm(1000))
transformer <- find_transformation_parameters(
  x = x,
  method = "box_cox"
)

if (rlang::is_installed("ggplot2")) {
  plot_residual_plot(
    x = x,
    transformer = transformer
  )

  # Plot only central 80% of the data.
  plot_residual_plot(
    x = x,
    transformer = transformer,
    centre_width = 0.80,
    show_original = FALSE
  )
}

power.transform documentation built on April 12, 2025, 5:08 p.m.