Description Usage Arguments Details Value See Also Examples
Construct an xDensity
representation of a combined Box-Cox/Gram-Charlier density approximation.
1 2 |
x |
Vector of random samples from density to approximate. |
lambda |
Exponent of Box-Cox transform. If |
alpha |
Offset of the Box-Cox transform. Default is no offset. See Details. |
cmom |
Optional vector of first 4 central moments of |
trim |
Scalar between 0 and 1; removes the |
n, from, to |
Specifies a grid of values on which to evaluate the density (see |
mean, sd |
Optional mean and standard deviation for |
... |
Additional parameters to Box-Cox fitting function |
x
is first standardized to z = x/sd(x) - min(x/sd(x), from) + 1
, before the Box-Cox transform is applied.
For details on the Box-Cox transformation and Gram-Charlier approximation, see powFit
and dgc4
respectively.
An xDensity
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # xDensity approximation to a noncentral-t distribution
# true parameters
lambda <- rnorm(1) # noncentrality parameter
nu <- runif(1, 4, 6) # degrees of freedom
# simulate data (note the small sample size)
x <- rt(500, df = nu, ncp = lambda)
# xDensity approximation
xDensK <- kernelXD(x) # kernel smoothing
xDensG <- gc4XD(x) # gc4 approximation
# true vs approximate PDFs
xlim <- qt(c(.005, .995), df = nu, ncp = lambda) # range for plot
curve(dt(x, df = nu, ncp = lambda),
from = xlim[1], to = xlim[2], ylab = "Density")
curve(dXD(x, xDens = xDensK), add = TRUE, col = "red")
curve(dXD(x, xDens = xDensG), add = TRUE, col = "blue")
legend("topleft", legend = c("True PDF", "xDensity: kernel", "xDensity: gc4"),
fill = c("black", "red", "blue"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.