Skip to content

Commit a4f4ddc

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

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
@@ -260,19 +260,15 @@ function fit!(
260260
optsum.final = copy(optsum.initial)
261261
end
262262
setpar! = fast ? setθ! : setβθ!
263-
feval = 0
264263
function obj(x, g)
265-
isempty(g) || error("gradient not defined for this model")
266-
feval += 1
264+
isempty(g) || throw(ArgumentError("g should be empty for this objective"))
267265
val = deviance(pirls!(setpar!(m, x), fast, verbose), nAGQ)
268-
feval == 1 && (optsum.finitial = val)
269-
if verbose
270-
println("f_", feval, ": ", val, " ", x)
271-
end
266+
verbose && println(round(val, digits = 5), " ", x)
272267
val
273268
end
274269
opt = Opt(optsum)
275270
NLopt.min_objective!(opt, obj)
271+
optsum.finitial = obj(optsum.initial, T[])
276272
fmin, xmin, ret = NLopt.optimize(opt, copyto!(optsum.final, optsum.initial))
277273
## check if very small parameter values bounded below by zero can be set to zero
278274
xmin_ = copy(xmin)
@@ -290,7 +286,7 @@ function fit!(
290286
## ensure that the parameter values saved in m are xmin
291287
pirls!(setpar!(m, xmin), fast, verbose)
292288
optsum.nAGQ = nAGQ
293-
optsum.feval = feval
289+
optsum.feval = opt.numevals
294290
optsum.final = xmin
295291
optsum.fmin = fmin
296292
optsum.returnvalue = ret

0 commit comments

Comments
 (0)