Skip to content

use ADTypes for StatsBase.informationmatrix #2732

@penelopeysm

Description

@penelopeysm

function StatsBase.informationmatrix(
m::ModeResult; hessian_function=ForwardDiff.hessian, kwargs...
)
# This needs to be calculated in unlinked space
model = m.f.ldf.model
vi = DynamicPPL.VarInfo(model)
getlogdensity = _choose_getlogdensity(m.estimator)
new_optimld = OptimLogDensity(DynamicPPL.LogDensityFunction(model, getlogdensity, vi))
# Calculate the Hessian, which is the information matrix because the negative of the log
# likelihood was optimized
varnames = StatsBase.coefnames(m)
info = hessian_function(new_optimld, m.values.array[:, 1])
return NamedArrays.NamedArray(info, (varnames, varnames))
end

this should take an adtype rather than a hessian function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions