ggladder: Ladder-of-powers histograms

View source: R/ggladder.R

ggladderR Documentation

Ladder-of-powers histograms

Description

Explore Tukey's ladder of powers graphically using histograms to identify a transform that converts varinto a normally distributed variable.

Density is shown on the y-axis. The heights of the bars of the histogram are scaled so that the sum of their areas is equal to 1.0. Normal curves are plotted using the mean and standard deviation of the transformations, not the kernel density of the histograms.

This is intended to replicate the gladder command in Stata. As per Stata's approach, the number of bins is set to the min(sqrt(n), 10 * log10(n)), rounded to the closest integer, where n is number of observations. NAs are omitted by default.

Usage

ggladder(data, var, fill = "cyan4", line_color = "black", line_type = "solid")

Arguments

data

A tibble or data frame.

var

A numeric vector of data values.

fill

Fill color for the histograms (default = "cyan4").

line_color

Color for the normal curves (default = "black").

line_type

Line type for the normal curves (default = "solid").

Value

A tibble.

References

https://www.stata.com/manuals/rladder.pdf

Examples


ggladder(data = auto,
         var = mpg)

ggladder(data = auto,
         var = mpg,
         fill = "pink")

# To adjust the theme of all of the patches using patchwork package and an &
# instead of +
ggladder(data = auto,
         var = mpg) &
  ggplot2::theme_classic()


emilelatour/lamisc documentation built on April 9, 2024, 10:33 a.m.