log_basis: Logarithmic Basis Function

View source: R/log.R

log_basisR Documentation

Logarithmic Basis Function

Description

The logarithmic basis function

Usage

log_basis(var, ui = c("none", "increasing", "decreasing"),
          remove_intercept = FALSE)

Arguments

var

a numeric_var object

ui

a character describing possible constraints

remove_intercept

a logical indicating if the intercept term shall be removed

Details

log_basis returns a function for the evaluation of the basis functions with corresponding model.matrix and predict methods.

Examples


  ### set-up basis
  lb <- log_basis(numeric_var("x", support = c(0.1, pi)))

  ### generate data + coefficients
  x <- as.data.frame(mkgrid(lb, n = 100))

  ### 1 + 2 * log(x) 
  max(abs(predict(lb, newdata = x, coef = c(1, 2)) - (1 + 2 * log(x$x))))


basefun documentation built on May 31, 2022, 3 a.m.