Learn R Programming

FBMS (version 1.2)

glm.loglik.g: Log likelihood function for glm regression with Zellner's g-prior and BIC-like approximations

Description

This function estimates marginal likelihood for generalized linear models using a BIC-style penalty adjusted to approximate Zellner's g-prior effect.

Usage

glm.loglik.g(
  y,
  x,
  model,
  complex,
  mlpost_params = list(r = NULL, family = "binomial", g = NULL)
)

Value

A list with the approximate log marginal likelihood (crit) and the posterior mode of coefficients (coefs)

Arguments

y

A vector containing the dependent variable

x

The matrix containing the precalculated features

model

A logical vector indicating which features are included in the model

complex

A list of complexity measures for the features

mlpost_params

A list of parameters for the log likelihood, including:

  • r - scalar tuning parameter for the prior (default is 1 / number of rows of x)

  • family - GLM family as string ("binomial", "poisson", "Gamma"), default is "binomial"

  • g - scalar specifying the g prior hyperparameter (default max of model size squared and sample size)

Examples

Run this code
glm.loglik.g(as.integer(rnorm(100) > 0), 
cbind(1, matrix(rnorm(100))), c(TRUE, TRUE), list(oc = 1),
 list(r = 1/100, family = "binomial", g = 10))

Run the code above in your browser using DataLab