Learn R Programming

PPMiss (version 0.1.1)

kdens: Kernel density estimator

Description

The probability density function \(F'\) is estimated using a kernel density approach. More specifically, first \(y_i = \hat{f}(x_i^\ast)\) is estimated using \(T = 512\) (default for the function density) equally spaced points \(x_i^\ast\), \(1 \leq i \leq T\), in the interval \([x_{(1)} - 3b, x_{(n)} + 3b]\), where \(b\) is the bandwidth for the Gaussian kernel density estimator, chosen by applying the Silverman's rule of thumb (the default procedure in density). A cubic spline interpolation (the default method for spline) is then applied to the pairs \(\{(x_i^\ast, y_i)\}_{i=1}^T\) to obtain \(\hat F_n'(x)\) for all \(x \in [x_{(1)} - 3b, x_{(n)} + 3b]\).

Usage

kdens(x)

Value

a function that approximates the probability density function.

Arguments

x

the data from which the estimate is to be computed.

Examples

Run this code
# creating a time series
trunc = 50000
cks <- arfima.coefs(d = 0.25, trunc = trunc)
eps <- rnorm(trunc+1000)
x <- sapply(1:1000, function(t) sum(cks*rev(eps[t:(t+trunc)])))

# kernel density function
dfun <- kdens(x)

# plot
curve(dfun, from = min(x), to = max(x))

Run the code above in your browser using DataLab