get_h_hp_adaptive {genscore}R Documentation

Generator of adaptive h and hp (derivative of h) functions.

Description

Generator of adaptive h and hp (derivative of h) functions.

Usage

get_h_hp_adaptive(mode, para, percentile)

Arguments

mode

A string, the corresponding mode (with the suffix "_ada" removed from the input to get_h_hp()). Must be one of the modes starting with "min_" supported by get_h_hp_vector().

para

Must be provided, but can be NULL. A number, the first parameter; see get_h_hp() or get_h_hp_vector().

percentile

A number, the percentile for column-wise truncation on hx and hpx.

Details

Helper function of get_h_hp(). Please refer to get_hs_hp().

Value

A function that returns a list containing hx=h(x) (element-wise) and hpx=hp(x) (element-wise derivative of h) when applied to a matrix x, with both of the results having the same shape as x.

Examples

get_h_hp_adaptive("min_log_pow", 1, 0.4)(matrix(0:49, nrow=10))
get_h_hp_adaptive("min_pow", 2, 0.3)(matrix(0:49, nrow=10))
get_h_hp_adaptive("min_softplus", 2, 0.6)(matrix(seq(0, 0.49, by=0.01), nrow=10))

hx_hpx <- get_h_hp_adaptive("min_log_pow", 1, 0.4)(matrix(0:49, nrow=10))
hx_hpx2 <- get_h_hp("min_log_pow_ada", 1, 0.4)(matrix(0:49, nrow=10))
c(max(abs(hx_hpx$hx - hx_hpx2$hx)), max(abs(hx_hpx$hpx - hx_hpx2$hpx)))

[Package genscore version 1.0.2.2 Index]