plot_pdf_theory {SimMultiCorrData}R Documentation

Plot Theoretical Power Method Probability Density Function and Target PDF by Distribution Name or Function for Continuous Variables

Description

This plots the theoretical power method probability density function:

f_p(Z)(p(z)) = f_p(Z)(p(z), f_Z(z)/p'(z)),

as given in Headrick & Kowalchuk (2007, doi: 10.1080/10629360600605065), and target pdf (if overlay = TRUE). It is a parametric plot with sigma * y + mu, where y = p(z), on the x-axis and f_Z(z)/p'(z) on the y-axis, where z is vector of n random standard normal numbers (generated with a seed set by user). Given a vector of polynomial transformation constants, the function generates sigma * y + mu and calculates the theoretical probabilities using f_p(Z)(p(z), f_Z(z)/p'(z)). If overlay = TRUE, the target distribution is also plotted given either a distribution name (plus up to 4 parameters) or a pdf function fx. If a target distribution is specified, y is scaled and then transformed so that it has the same mean and variance as the target distribution. It returns a ggplot2-package object so the user can modify as necessary. The graph parameters (i.e. title, power_color, target_color, target_lty) are ggplot2-package parameters. It works for valid or invalid power method pdfs.

Usage

plot_pdf_theory(c = NULL, method = c("Fleishman", "Polynomial"), mu = 0,
  sigma = 1, title = "Probability Density Function", ylower = NULL,
  yupper = NULL, power_color = "dark blue", overlay = TRUE,
  target_color = "dark green", target_lty = 2, Dist = c("Benini", "Beta",
  "Beta-Normal", "Birnbaum-Saunders", "Chisq", "Dagum", "Exponential",
  "Exp-Geometric", "Exp-Logarithmic", "Exp-Poisson", "F", "Fisk", "Frechet",
  "Gamma", "Gaussian", "Gompertz", "Gumbel", "Kumaraswamy", "Laplace",
  "Lindley", "Logistic", "Loggamma", "Lognormal", "Lomax", "Makeham", "Maxwell",
  "Nakagami", "Paralogistic", "Pareto", "Perks", "Rayleigh", "Rice",
  "Singh-Maddala", "Skewnormal", "t", "Topp-Leone", "Triangular", "Uniform",
  "Weibull"), params = NULL, fx = NULL, lower = NULL, upper = NULL,
  n = 100, seed = 1234, legend.position = c(0.975, 0.9),
  legend.justification = c(1, 1), legend.text.size = 10,
  title.text.size = 15, axis.text.size = 10, axis.title.size = 13)

Arguments

c

a vector of constants c0, c1, c2, c3 (if method = "Fleishman") or c0, c1, c2, c3, c4, c5 (if method = "Polynomial"), like that returned by find_constants

method

the method used to generate the continuous variable y = p(z). "Fleishman" uses Fleishman's third-order polynomial transformation and "Polynomial" uses Headrick's fifth-order transformation.

mu

the desired mean for the continuous variable (used if overlay = FALSE, otherwise variable centered to have the same mean as the target distribution)

sigma

the desired standard deviation for the continuous variable (used if overlay = FALSE, otherwise variable scaled to have the same standard deviation as the target distribution)

title

the title for the graph (default = "Probability Density Function")

ylower

the lower y value to use in the plot (default = NULL, uses minimum simulated y value)

yupper

the upper y value (default = NULL, uses maximum simulated y value)

power_color

the line color for the power method pdf (default = "dark blue)

overlay

if TRUE (default), the target distribution is also plotted given either a distribution name (and parameters) or pdf function fx (with bounds = ylower, yupper)

target_color

the line color for the target pdf (default = "dark green")

target_lty

the line type for the target pdf (default = 2, dashed line)

Dist

name of the distribution. The possible values are: "Benini", "Beta", "Beta-Normal", "Birnbaum-Saunders", "Chisq", "Exponential", "Exp-Geometric", "Exp-Logarithmic", "Exp-Poisson", "F", "Fisk", "Frechet", "Gamma", "Gaussian", "Gompertz", "Gumbel", "Kumaraswamy", "Laplace", "Lindley", "Logistic", "Loggamma", "Lognormal", "Lomax", "Makeham", "Maxwell", "Nakagami", "Paralogistic", "Pareto", "Perks", "Rayleigh", "Rice", "Singh-Maddala", "Skewnormal", "t", "Topp-Leone", "Triangular", "Uniform", "Weibull". Please refer to the documentation for each package (either stats-package, VGAM-package, or triangle) for information on appropriate parameter inputs.

params

a vector of parameters (up to 4) for the desired distribution (keep NULL if fx supplied instead)

fx

a pdf input as a function of x only, i.e. fx <- function(x) 0.5*(x-1)^2; must return a scalar (keep NULL if Dist supplied instead)

lower

the lower support bound for fx

upper

the upper support bound for fx

n

the number of random standard normal numbers to use in generating y = p(z) (default = 100)

seed

the seed value for random number generation (default = 1234)

legend.position

the position of the legend

legend.justification

the justification of the legend

legend.text.size

the size of the legend labels

title.text.size

the size of the plot title

axis.text.size

the size of the axes text (tick labels)

axis.title.size

the size of the axes titles

Value

A ggplot2-package object.

References

Please see the references for plot_cdf.

Wickham H. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York, 2009.

See Also

find_constants, calc_theory, ggplot2-package, geom_path

Examples

## Not run: 
# Logistic Distribution

# Find standardized cumulants
stcum <- calc_theory(Dist = "Logistic", params = c(0, 1))

# Find constants without the sixth cumulant correction
# (invalid power method pdf)
con1 <- find_constants(method = "Polynomial", skews = stcum[3],
                      skurts = stcum[4], fifths = stcum[5],
                      sixths = stcum[6])

# Plot invalid power method pdf with theoretical pdf overlayed
plot_pdf_theory(c = con1$constants, method = "Polynomial",
         title = "Invalid Logistic PDF", overlay = TRUE,
         Dist = "Logistic", params = c(0, 1))

# Find constants with the sixth cumulant correction
# (valid power method pdf)
con2 <- find_constants(method = "Polynomial", skews = stcum[3],
                      skurts = stcum[4], fifths = stcum[5],
                      sixths = stcum[6], Six = seq(1.5, 2, 0.05))

# Plot valid power method pdf with theoretical pdf overlayed
plot_pdf_theory(c = con2$constants, method = "Polynomial",
         title = "Valid Logistic PDF", overlay = TRUE,
         Dist = "Logistic", params = c(0, 1))

## End(Not run)


[Package SimMultiCorrData version 0.2.2 Index]