mk_qqplot: Create a function for making publishable ggplot2 Q-Q plots.

View source: R/mk_qqplot.R

mk_qqplotR Documentation

Create a function for making publishable ggplot2 Q-Q plots.

Description

mk_qqplot takes a data frame as input and returns a function for making Q-Q plot of any continuous variable from the data frame.

Usage

mk_qqplot(df)

Arguments

df

A data frame.

Value

function(varname, dist = "norm", dparams = list(), ci_band_type = "pointwise", font_size = 14)

  • varname. String, name of a continuous variable. We're interested in comparing its empirical distribution with a theoretical distribution, for example, the standard normal distribution.

  • dist. String, theoretical probability distribution function to compare against. These values are supported: "beta", "cauchy", "chisq", "exp", "f", "gamma", "geom", "lnorm", "logis", "norm" (default), "nbinom", "pois", "t", "weibull".

  • dparams. List of parameters to the chosen theoretical distribution function. If an empty list is provided (default), the distributional parameters are estimated via MLE. Default = list().

  • ci_band_type. String, type of the confidence bands to be drawn: "pointwise" (default), "boot", "ks", and "ts", where * "pointwise" - simultaneous confidence bands based on the normal distribution; * "boot" - pointwise confidence bands based on a parametric boostrap; * "ks" - simultaneous confidence bands based on an inversion of the Kolmogorov-Smirnov test; It's not tail sensitive so the bands at the tails are really wide. Not good to test if the tails of the empirical distribution follows the given theoretical distribution. * "ts" - tail-sensitive confidence bands, as proposed by Aldor-Noiman et al. (2013). It only works when dist = "norm", and it takes too long to compute for large samples.

  • font_size. Overall font size. Default = 14. The font size of the axes and legend text is a fraction of this value.

Examples

inst/examples/ex-mk_qqplot.R

gmlang/ezplot documentation built on Sept. 18, 2022, 6:33 a.m.