Skip to content

Commit 43d09ca

Browse files
committed
initial work on including dispersion in GLMM deviance
1 parent cb90435 commit 43d09ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/generalizedlinearmixedmodel.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ is the squared length of the conditional modes, `u`, plus the determinant
6969
of `Λ'Z'WZΛ + I`, plus the sum of the squared deviance residuals.
7070
"""
7171
function StatsBase.deviance(m::GeneralizedLinearMixedModel{T}, nAGQ = 1) where {T}
72-
nAGQ == 1 && return T(sum(m.resp.devresid) + logdet(m) + sum(u -> sum(abs2, u), m.u))
72+
# TODO: fix dispersion's contribution for non Gaussians
73+
disp = dispersion_parameter(m) ? nobs(m) * (1 + log2π + log(varest(m))) : zero(T)
74+
nAGQ == 1 && return T(sum(m.resp.devresid) + logdet(m) +
75+
sum(u -> sum(abs2, u), m.u) + disp)
76+
# TODO: incorporate disp into nAGQ > 1
7377
u = vec(first(m.u))
7478
u₀ = vec(first(m.u₀))
7579
copyto!(u₀, u)

0 commit comments

Comments
 (0)