gc4XD: Construct an 'xDensity' representation of a combined...

Description Usage Arguments Details Value See Also Examples

View source: R/gc4XD.R

Description

Construct an xDensity representation of a combined Box-Cox/Gram-Charlier density approximation.

Usage

1
2
gc4XD(x, lambda = NULL, alpha = 0, cmom = NULL, trim = 0.01,
  n = 512, from, to, mean, sd, ...)

Arguments

x

Vector of random samples from density to approximate.

lambda

Exponent of Box-Cox transform. If NULL it is estimated from x. See Details.

alpha

Offset of the Box-Cox transform. Default is no offset. See Details.

cmom

Optional vector of first 4 central moments of x. If NULL these are estimated from x.

trim

Scalar between 0 and 1; removes the trim fraction of extreme values from x for estimation of lambda and cmom, which are very sensitive to outliers. trim = FALSE does not trim any values.

n, from, to

Specifies a grid of values on which to evaluate the density (see density).

mean, sd

Optional mean and standard deviation for xDensity representation.

...

Additional parameters to Box-Cox fitting function powFit.

Details

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.

Value

An xDensity object.

See Also

powFit, dgc4, xDensity.

Examples

 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"))

mlysy/GaussCop documentation built on Nov. 6, 2019, 6:19 p.m.