-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I've been monkeying with random effects this week, and started using this debugging helper with my old friend curve():
obj_fn_plot <- function (model_code, params, par_name, from = params[par_name[[1]], "lower"], to = params[par_name[[1]], "upper"], ...) {
stopifnot(par_name %in% rownames(params))
params$optimise <- FALSE
params$random <- FALSE
params[par_name, "optimise"] <- TRUE
obj.fn <- g3_tmb_adfun(model_code, params, type = c("ADFun", "Fun")) # TODO: Just "Fun" is failing, maybe because there's only one param?
fn <- Vectorize(function (x) { params[par_name, "value"] <- list(x) ; obj.fn$fn(g3_tmb_par(params)) })
curve(fn(x), from = from, to = to, ...)
}So I can do things like: obj_fn_plot(model_cpp, params.in, "fish_imm.rec.2010").
I'd been suggesting @vbartolino try something similar at one point, but didn't have any code to hand. Do we think something along these lines is worth adding into gadget3? Or at least parked in the debugging vignette?
- I can't help feel that as a debugging technique it's not particularly subtle. Maybe that's a good thing.
- Handing in C++ code rather than an objective function seems a bit ugly.
- What else should it do?
- Multiple lines for multiple parameters could be interesting, where scales match (I could plot "fish_imm.rec.2010--2020" in the above).
- A 3d surface for 2 parameters is another obvious thing to do, but I'm not convinced it's worth the faff.
- Plot the maximum gradient instead of the double value
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels