get_glm_log_density: Compute Log Density Based on GLM Family

get_glm_log_densityR Documentation

Compute Log Density Based on GLM Family

Description

This function calculates the log density of the response variable given a generalized linear model (GLM) based on the specified family. The log density is computed differently for binomial and gaussian families.

Usage

get_glm_log_density(family_string, X, Y, coefs, weights = 1)

Arguments

family_string

Character. The GLM family to use. Options are "binomial" or "gaussian".

X

Matrix. The design matrix (predictors) for the GLM.

Y

Vector or data frame. The response variable for the GLM. If a data frame, it is converted to a numeric vector.

coefs

Numeric vector. The coefficients for the GLM.

weights

Numeric vector. Weights for the observations. Default is 1 (no weighting).

Value

Numeric. The computed log density of the response variable based on the specified family.


catalytic documentation built on April 4, 2025, 5:51 a.m.