This function calculates the gradient of the log density with respect to the coefficients for a given GLM family based on the provided predictors, response variable, and weights.
get_glm_log_density_grad(family_string, X, Y, coefs, weights = 1)
Numeric vector. The gradient of the log density with respect to the coefficients
Character. The GLM family to use. Options are "binomial"
or "gaussian"
.
Matrix. The design matrix (predictors) for the GLM.
Vector. The response variable.
Numeric vector. The coefficients for the GLM.
Numeric vector. The weights for the GLM. Default is 1.