Dear Jack and Allin (and Sven... and all other contributors!),
I would like to try a modification of the source codes to make a reality of
some of my dreams. However, my noobish skills in C do not allow me to
obtain all the desired fruits. The original wish is to:
— Enhance the kdensity function via adding more kernels (biweight,
triweight, triangular, uniform, tricube, cosine, opt-cosine, logistic,
semicircle—the latter was found in Wolfram Mathematica (and nowhere else),
and made me laugh very hard);
— Add 4th and 6th-order kernels (enhanced convergence; however, negative
outcomes possible);
— Allow users to choose the number of points for interpolation.
The third goal seems the most feasible one. I examined the *dialogs.c* and
(most important) *kernel.c* and found the following lines:
static int kernel_kn (int nobs)
{
if (nobs >= 200) {
return 200;
} else if (nobs >= 100) {
return 100;
} else {
return 50;
}
}
It seems to be the land of promise for those who would like to advance. I
wonder whether it is possible to add an optional argument that would allow
to set the number of points manually. Like, say, --points=1000. That would
be quite useful when calculating the exact quantiles of the smoothed data
(for instance, when estimating the well-known distributions that depend on
nobs or X'X: Dickey—Fuller, Darbin—Watson etc.).
The second goal seems feasible at least for some functions, since Mr.
Hansen kindly provides the formulæ in his lecture notes (2009) and the
calculation method. Please see the following example and reply whether I
defined the extra kernels correctly (and if so, how can I expand the *int
type* for acceptance of multiple possible values):
/* Biweight = 15/16*(1-z^2)^2 if |x|<1 */
static double biw_pdf (double z)
{
if (fabs(z) >= 1) {
return 0.0;
} else {
return 0.9375 * (1.0 - z * z) * (1.0 - z * z);
}
}
/* Tricube = 70/81*(1-|z|^3)^3 if |x|<1 */
#define TCMULT 0.8641975308641975 /* 70 over 81 */
static double tcb_pdf (double z)
{
if (fabs(z) >= 1) {
return 0.0;
} else {
return TCMULT * (1.0 - abs(z) * z * z) * (1.0 - abs(z) * z * z) * (1.0
- abs(z) * z * z)
}
}
I will be very glad to hear from you whether this could be a nice
enhancement for the kdensity function or a complete waste of time. If I
create all the required prerequisited, will you include that functionality?
--
Yours sincerely, | С уважением,
Andreï V. Kostyrka. | Андрей Викторович Костырка.
http://kostyrka.ru,
http://kostyrka.ru/blog