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.
take_interaction_2ndderivative(
dat,
var,
interaction_single_cols,
interaction_quad_cols,
triplet_cols,
colnm_expansions,
power1_cols,
power2_cols
)
Numeric matrix of second derivatives, same dimensions as input
Numeric matrix; design matrix containing basis expansions
Character; variable name to differentiate with respect to
Integer vector; column indices for linear-linear interactions
Integer vector; column indices for linear-quadratic interactions
Integer vector; column indices for three-way interactions
Character vector; column names of expansions for each partition
Integer vector; column indices of linear terms
Integer vector; column indices of quadratic terms