plot_pdf_ext {SimMultiCorrData} | R Documentation |
Plot Theoretical Power Method Probability Density Function and Target PDF of External Data for Continuous Variables
Description
This plots the theoretical power method probability density function:
as given in
Headrick & Kowalchuk (2007, doi: 10.1080/10629360600605065), and target
pdf. It is a parametric plot with , where
, on the x-axis and
on the y-axis, where
is vector of
random standard normal numbers (generated with a seed set
by user; length equal to length of external data vector).
sigma
is the standard deviation and mu
is the mean of the external data set.
Given a vector of polynomial transformation constants, the function generates and calculates the theoretical
probabilities using
. The target distribution is also plotted given a vector
of external data. This external data is required. The
values are centered and scaled to have the same mean and standard
deviation as the external data. If the user wants to only plot the power method pdf,
plot_pdf_theory
should be used instead with overlay = FALSE
. It returns a ggplot2-package
object so the user can modify as necessary. The graph parameters (i.e. title
,
power_color
, target_color
, nbins
) are ggplot2-package
parameters. It works for valid or invalid power method pdfs.
Usage
plot_pdf_ext(c = NULL, method = c("Fleishman", "Polynomial"),
title = "Probability Density Function", ylower = NULL, yupper = NULL,
power_color = "dark blue", ext_y = NULL, target_color = "dark green",
target_lty = 2, 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 |
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. |
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") |
ext_y |
a vector of external data (required) |
target_color |
the histogram color for the target pdf (default = "dark green") |
target_lty |
the line type for the target pdf (default = 2, dashed line) |
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
, geom_density
Examples
## Not run:
# Logistic Distribution
seed = 1234
# Simulate "external" data set
set.seed(seed)
ext_y <- rlogis(10000)
# 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 external data
plot_pdf_ext(c = con1$constants, method = "Polynomial",
title = "Invalid Logistic PDF", ext_y = ext_y,
seed = seed)
# 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 invalid power method pdf with external data
plot_pdf_ext(c = con2$constants, method = "Polynomial",
title = "Valid Logistic PDF", ext_y = ext_y,
seed = seed)
## End(Not run)