get_densfun: Generate a function that looks up a density in accordance...

View source: R/sim_tools.R

get_densfunR Documentation

Generate a function that looks up a density in accordance with the specification in a stats::family object

Description

This function is useful for evaluating data against the implied density of a fitted glm object

Usage

get_densfun(family)

Arguments

family

an object of type stats::family

Value

A function with arguments x (data), eta, (linear predictor from glm object), dispersion (summary(m)$dispersion where m is a fitted glm), and n, vector of group sizes (optional unless family=binomial)

Examples


fam = Gamma('log')
densfun = get_densfun(fam)
densfun(0.2, eta = 2, dispersion=0.5)

# the above is equivalent to:
dgamma(0.2, scale = exp(2), shape = 1/0.5)

audreyrenson/didgformula documentation built on Oct. 9, 2022, 11:45 a.m.