kernelXD: Construct an 'xDensity' representation of a kernel smoothing...

Description Usage Arguments Value Examples

View source: R/kernelXD.R

Description

Construct an xDensity representation of a kernel smoothing estimator.

Usage

1
kernelXD(x, n = 512, from, to, mean, sd, any0 = FALSE, ...)

Arguments

x

Vector of samples from the underlying distribution.

n, from, to

Optional arguments to density which are used to set the grid on which to evaluate the kernel estimator.

mean, sd

Optional mean and standard deviation arguments for the extended density. Default to the mean and standard deviation of x.

any0

Logical; if FALSE forces the support of the density to be the real line.

...

Additional arguments to density.

Value

An xDensity object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# xDensity approximation to a noncentral-t distribution

# true parameters
lambda <- rnorm(1) # noncentrality parameter
nu <- runif(1, 4, 6) # degrees of freedom

# simulate data
x <- rt(1e4, df = nu, ncp = lambda)

# xDensity approximation
xDens <- kernelXD(x)

# true vs approximate PDF
curve(dt(x, df = nu, ncp = lambda),
      from = min(x), to = max(x), ylab = "Density")
curve(dXD(x, xDens = xDens), add = TRUE, col = "red")
legend("topleft", legend = c("True PDF", "xDensity Approx."),
       fill = c("black", "red"))

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