This package is no longer maintained. I moved most of the useful functionality from this into my package DependentBootstrap.
This module allows Julia users to specify and evaluate a range of different kernel functions. It also includes functionality for estimating bandwidths for use with various staistical procedures, including, but not limited to, estimation of optimal block lengths for dependent bootstraps.
The module is implemented entirely in Julia and draws some inspiration from the Distance package. Specifically, each kernel function or bandwidth estimation method is its own type and are evaluated via the functions
bandwidth respectively, exploiting multiple dispatch. This is in contrast to the other kernel statistics packages for Julia, which typically do not employ this model for structuring modules.
It is worthing noting that kernel-function based statistics is a big topic, and this module is currently quite small. In fact, I only wrote this module to support a more comprehensive module for dependent bootstrapping, and so the functionality implemented thus far is all that was needed to support the package DependentBootstrap.
This package is not yet registered, so you will not be able to get it using
Pkg.add("KernelStat"). If you want to try it out use
Pkg.clone("https://github.com/colintbowers/KernelStat.jl") from the Julia REPL. This should download it and install it in your
.julia folder. Then you can load the package into the current julia session with
As in the Julia Distance package, each kernel function is its own type, and all kernel function types are a subset of the abstract type
KernelFunction. A list of kernel function types and their fields follows. Kernel functions defined on the interval [-1, 1] include:
Kernel functions defined on the interval [-Inf, Inf] include:
KernelGaussian. Fields include:
Specific kernel functions from academic papers include:
KernelPR1993FlatTop, from Politis, Romano (1993) "On a family of smoothing kernels of infinite order". Fields (defined in that paper) include:
KernelP2003FlatTop, from Politis (2003) "Adaptive bandwidth choice". Note, this kernel function is equivalent to
KernelPP2002Trap, from Paparoditis, Politis (2002) "The tapered block bootstrap for general statistics from stationary sequences". Fields (defined in that paper) include:
KernelPP2002Smooth, from Paparoditis, Politis (2002) "The tapered block bootstrap for general statistics from stationary sequences". Fields (defined in that paper) include:
Every kernel function exhibits a constructor that requires no inputs. These constructors use sensible default values for the kernel parmeters, e.g.
KernelPR1993FlatTop() = KernelPR1993FlatTop(0.5, 1).
KernelFunction exhibits the following very important function:
For example, if a user wishes to evaluate the uniform kernel at the number 0.3, they would use:
If a user wishes to evaluate the flat top kernel of Politis and Romano (1993) with parameters 1.5 and 2.5, over the integers 1, 2, 3, and 4, they would use:
evaluate([1:4], KernelPR1993FlatTop(1.5, 2.5))
In addition to
KernelFunction exhibits the following core methods:
ASCIIStringrepresentation of the kernel function, e.g.
ASCIIStringto a subtype of
KernelUniform(). Note, this function is essentially the inverse of
string. By construction it is not type stable.
UnitRangethat indicates the domain over which the input kernel function evaluates to a non-zero number.
UnitRangeindicating the valid domain of the parameter number indicated in
pNum. Parameter numbers correspond to the order in which fields are defined for the
KernelFunction. If a
KernelFunctiondoes not have any fields/parameters or if
pNumdoes not correspond to a field number, then this function throws an error.
Each method of bandwidth estimation is its own type, and they are all subtypes of the abstract type
BandwidthMethod. Common to every bandwidth estimation type is a field called
adjustmentTerm, which simply scales the output of bandwidth estimation by multiplication. Thus the default value to this field is
1.0 and most users will not want to alter this. Some bandwidth estimation types contain additional fields. A complete list follows
BandwidthWhiteNoise. Estimate bandwidth using a white noise assumption to determine confidence bounds for autocorrelation. Bandwidth is two times the lag number of the first insignificant autocorrelation. Fields include:
BandwidthBartlett. Estimate bandwidth using Bartlett assumptions (ie underlying model is Moving Average (MA)) to determine confidence bounds at each step. Bandwidth is two times the lag number of the first insignificant autocorrelation. Fields include:
BandwidthP2003. Estimate bandwidth using the empirical rule of picking M defined in section 2.1 of Politis (2003) "Adaptive Bandwidth Choice". Fields include:
numObsinto a better estimate for
Kthan the default rule - see Politis (2003) for more detail)
Given a vector of observable data
T<:Number, an appropriate bandwidth for
x can be estimated using the
bandwidth function. This function exhibits methods of the type:
For example, to estimate the bandwidth of
x using the Bartlett method, one would use:
M = bandwidth(x, BandwidthBartlett())
A second example. To estimate the bandwidth of
x using the adaptive method of Politis (2003) with default parameter value for
K determined optimally from the number of observations in
x, one would use:
M = bandwidth(x, BandwidthP2003(length(x)))
The subtypes of
BandwidthMethod also exhibit the following core functions:
ASCIIStringrepresentation of the bandwidth method, e.g.
ASCIIStringto a subtype of
This concludes the description of the KernelStat module.
almost 4 years ago