@@ -69,7 +69,7 @@ is the squared length of the conditional modes, `u`, plus the determinant
69
69
of `Λ'Z'WZΛ + I`, plus the sum of the squared deviance residuals.
70
70
"""
71
71
function StatsBase. deviance (m:: GeneralizedLinearMixedModel{T} , nAGQ = 1 ) where {T}
72
- # TODO : fix dispersion's contribution for non Gaussians
72
+ # TODO : fix dispersion's contribution for non Gaussians
73
73
disp = dispersion_parameter (m) ? nobs (m) * (1 + log2π + log (varest (m))) : zero (T)
74
74
nAGQ == 1 && return T (sum (m. resp. devresid) + logdet (m) +
75
75
sum (u -> sum (abs2, u), m. u) + disp)
@@ -415,7 +415,6 @@ function StatsBase.loglikelihood(m::GeneralizedLinearMixedModel{T}) where {T}
415
415
mu = r. mu
416
416
d = r. d
417
417
if length (wts) == length (y)
418
- # in GLM.jl, they use the deviance of the
419
418
ϕ = deviance (r)/ sum (wts)
420
419
@inbounds for i in eachindex (y, mu, wts)
421
420
accum += GLM. loglik_obs (d, y[i], mu[i], wts[i], ϕ)
@@ -426,7 +425,7 @@ function StatsBase.loglikelihood(m::GeneralizedLinearMixedModel{T}) where {T}
426
425
accum += GLM. loglik_obs (d, y[i], mu[i], 1 , ϕ)
427
426
end
428
427
end
429
- accum
428
+ accum - ( mapreduce (u -> sum (abs2, u), + , m . u) + logdet (m)) / 2
430
429
end
431
430
432
431
StatsBase. nobs (m:: GeneralizedLinearMixedModel ) = length (m. η)
@@ -556,7 +555,7 @@ function Base.setproperty!(m::GeneralizedLinearMixedModel, s::Symbol, y)
556
555
end
557
556
end
558
557
559
- sdest (m:: GeneralizedLinearMixedModel{T} ) where {T} = dispersion_parameter (m) ? √ varest (m) : convert (T, NaN )
558
+ sdest (m:: GeneralizedLinearMixedModel{T} ) where {T} = dispersion_parameter (m) ? √ varest (m) : convert (T, NaN )
560
559
561
560
function Base. show (io:: IO , m:: GeneralizedLinearMixedModel )
562
561
if m. optsum. feval < 0
0 commit comments