make_kernel: make_kernel

Description Usage Arguments Value Examples

View source: R/make_kernel.R

Description

constructs polynomial kernels

Usage

1

Arguments

order,

the degree of the 1st non-zero moment, an even number since all these kernels are orthogonal to odd polynomials. If NULL then a uniform kernel is constructed

R,

support is -R to R and kernel is smooth at the boundary

Value

a list containing coefficients of the even polynomial kernel, veck, Range, R, and functions for the kernel and its cdf, kern and kern_cdf.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# The order of the kernel is power of the first non-zero moment. Kernels will have support between
# -R and R.  Order must be an even number because all kernels are orthogonal to odd polynomials 
# since they are symmetric
order = 8
R = 5
k=blipCDF:::make_kernel(order,R)

# check it is a kernel
area = with(k, integrate(kern, lower = -R, upper = R, R = R, veck = veck, subdivisions = 10000)$value)
area

# plot
s = seq(-R,R,.001)
y = with(k, kern(s, R=R, veck=veck))
plot = plot(s,y)
plot

# check orthogonality to a polynomial less than the order 
test_fcn = as.data.frame(vapply(0:order, FUN = function(r) {
  test_fcn = function(x) (x^r)*with(k, kern(x, R=R, veck = veck))
  test_int = integrate(test_fcn, lower = -R, upper = R,subdivisions = 10000)
  return(c(test_int$abs.error, test_int$value))
}, FUN.VALUE = c(1,1)))
rownames(test_fcn) = c("abs_error", "integral")
colnames(test_fcn) = as.character(0:(order))
# We see the integral of the kernel times an 8th degree polynomial is non trivial
test_fcn

jlstiles/cateSurvival documentation built on May 24, 2019, 1:36 a.m.