View source: R/qreml_functions.R
| penalty_uni | R Documentation |
Penalty approximation of unimodality constraints for univariates smooths
penalty_uni(coef, m, kappa = 1000, concave = TRUE, rho = 20)
coef |
coefficient vector of matrix on which to apply the unimodality penalty |
m |
vector of indices for the position of the coefficient mode.
If |
kappa |
global scaling factor for the penalty |
concave |
logical; if |
rho |
control parameter for smooth approximation to |
a numeric value of the penalty for the given coefficients
## coefficient vector
coef <- c(1, 2, 3, 2, 1)
# mode at position 3
penalty_uni(coef, m = 3) # basically zero
#' # mode at position 2
penalty_uni(coef, m = 2) # large positive penalty
## coefficient matrix
coef <- rbind(coef, coef)
m <- c(1, 4)
penalty_uni(coef, m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.