Skip to content

Commit d40ac21

Browse files
committed
fix loglik calc
1 parent 989526b commit d40ac21

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/generalizedlinearmixedmodel.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ function StatsBase.loglikelihood(m::GeneralizedLinearMixedModel{T}) where {T}
434434
mu = r.mu
435435
d = r.d
436436
if length(wts) == length(y)
437-
# in GLM.jl, they use the deviance of the
438437
ϕ = deviance(r)/sum(wts)
439438
@inbounds for i in eachindex(y, mu, wts)
440439
accum += GLM.loglik_obs(d, y[i], mu[i], wts[i], ϕ)
@@ -445,7 +444,7 @@ function StatsBase.loglikelihood(m::GeneralizedLinearMixedModel{T}) where {T}
445444
accum += GLM.loglik_obs(d, y[i], mu[i], 1, ϕ)
446445
end
447446
end
448-
accum
447+
accum - (mapreduce(u -> sum(abs2, u), +, m.u) + logdet(m)) / 2
449448
end
450449

451450
StatsBase.nobs(m::GeneralizedLinearMixedModel) = length(m.η)
@@ -623,7 +622,7 @@ function Base.setproperty!(m::GeneralizedLinearMixedModel, s::Symbol, y)
623622
end
624623
end
625624

626-
sdest(m::GeneralizedLinearMixedModel{T}) where {T} = dispersion_parameter(m) ? varest(m) : convert(T, NaN)
625+
sdest(m::GeneralizedLinearMixedModel{T}) where {T} = dispersion_parameter(m) ? varest(m) : convert(T, NaN)
627626

628627
function Base.show(io::IO, m::GeneralizedLinearMixedModel)
629628
if m.optsum.feval < 0

0 commit comments

Comments
 (0)