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.
take_derivative(dat, var, second = FALSE, scale)
Numeric matrix containing derivatives of polynomial terms, with same dimensions as input matrix
Numeric matrix; design matrix containing polynomial basis expansions
Character; column name of variable to differentiate with respect to
Logical; if TRUE compute second derivative, if FALSE compute first derivative (default FALSE)
Numeric; scaling factor for normalization