take_derivative: Calculate Derivatives of Polynomial Terms

View source: R/HelperFunctions.R

take_derivativeR Documentation

Calculate Derivatives of Polynomial Terms

Description

Computes first or second derivatives of polynomial terms in a design matrix with respect to a specified variable. Handles polynomial terms up to fourth degree.

Usage

take_derivative(dat, var, second = FALSE, scale)

Arguments

dat

Numeric matrix; design matrix containing polynomial basis expansions

var

Character; column name of variable to differentiate with respect to

second

Logical; if TRUE compute second derivative, if FALSE compute first derivative (default FALSE)

scale

Numeric; scaling factor for normalization

Value

Numeric matrix containing derivatives of polynomial terms, with same dimensions as input matrix


lgspline documentation built on June 8, 2025, 10:45 a.m.