Skip to content

Commit 7300ef3

Browse files
committed
change GLMM objective to use NLopt's tracking of function calls (like in LMM)
1 parent ebe7906 commit 7300ef3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/generalizedlinearmixedmodel.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,15 @@ function fit!(
244244
optsum.final = copy(optsum.initial)
245245
end
246246
setpar! = fast ? setθ! : setβθ!
247-
feval = 0
248247
function obj(x, g)
249-
isempty(g) || error("gradient not defined for this model")
250-
feval += 1
248+
isempty(g) || throw(ArgumentError("g should be empty for this objective"))
251249
val = deviance(pirls!(setpar!(m, x), fast, verbose), nAGQ)
252-
feval == 1 && (optsum.finitial = val)
253-
if verbose
254-
println("f_", feval, ": ", val, " ", x)
255-
end
250+
verbose && println(round(val, digits = 5), " ", x)
256251
val
257252
end
258253
opt = Opt(optsum)
259254
NLopt.min_objective!(opt, obj)
255+
optsum.finitial = obj(optsum.initial, T[])
260256
fmin, xmin, ret = NLopt.optimize(opt, copyto!(optsum.final, optsum.initial))
261257
## check if very small parameter values bounded below by zero can be set to zero
262258
xmin_ = copy(xmin)
@@ -274,7 +270,7 @@ function fit!(
274270
## ensure that the parameter values saved in m are xmin
275271
pirls!(setpar!(m, xmin), fast, verbose)
276272
optsum.nAGQ = nAGQ
277-
optsum.feval = feval
273+
optsum.feval = opt.numevals
278274
optsum.final = xmin
279275
optsum.fmin = fmin
280276
optsum.returnvalue = ret

0 commit comments

Comments
 (0)