take_interaction_2ndderivative {lgspline} | R Documentation |
Calculate Second Derivatives of Interaction Terms
Description
Computes partial second derivatives for interaction terms including two-way linear, quadratic, and three-way interactions. Handles special cases for each type.
This function is necessary to compute total second derivatives as the sum of
second partial "pure" derivatives (d^2/dx^2
) plus second partial "mixed"
derivative (d^2/dxdz
), for a predictor x and all other predictors z.
Usage
take_interaction_2ndderivative(
dat,
var,
interaction_single_cols,
interaction_quad_cols,
triplet_cols,
colnm_expansions,
power1_cols,
power2_cols
)
Arguments
dat |
Numeric matrix; design matrix containing basis expansions |
var |
Character; variable name to differentiate with respect to |
interaction_single_cols |
Integer vector; column indices for linear-linear interactions |
interaction_quad_cols |
Integer vector; column indices for linear-quadratic interactions |
triplet_cols |
Integer vector; column indices for three-way interactions |
colnm_expansions |
Character vector; column names of expansions for each partition |
power1_cols |
Integer vector; column indices of linear terms |
power2_cols |
Integer vector; column indices of quadratic terms |
Value
Numeric matrix of second derivatives, same dimensions as input