Add diagnose() function for lme4 convergence diagnostics#6
Add diagnose() function for lme4 convergence diagnostics#6annahuynhly with Copilot wants to merge 3 commits into
diagnose() function for lme4 convergence diagnostics#6Conversation
Co-authored-by: annahuynhly <97189987+annahuynhly@users.noreply.github.com>
diagnose() function for lme4 convergence diagnostics
|
@copilot some issues (inconsistency between this new version and If I use Meanwhile, if I use the current version, then these variables get flagged: It is possible that the differences could be due to the optimizer; but do you think it could be caused by something else? |
|
(Trying again... specifying a different model.) @copilot some issues (inconsistency between this new version and If I use Meanwhile, if I use the current version, then these variables get flagged: It is possible that the differences could be due to the optimizer; but do you think it could be caused by something else? |
Co-authored-by: annahuynhly <97189987+annahuynhly@users.noreply.github.com> Agent-Logs-Url: https://github.com/annahuynhly/lme4/sessions/f9f81824-ca11-472c-a8df-a1ada1f29315
Good catch — this was not just optimizer differences. In our first pass,
Confirmed: the discrepancy was mainly from implementation scope, not just optimizer choice. Previously we only checked fixed-effect Z-stats via |
|
Okay, reporting this myself so I know what's going on: fundamentally, the issue as to why it's harder to port is because in However, the same cannot be said. Indeed, the So overall my question is: how do we actually get the standard errors for |
Ports
glmmTMB::diagnose()to lme4, giving users a structured way to isolate likely causes of convergence problems in fittedmerModobjects.What it checks
check_coefs): flags theta (RE Cholesky factor) parameters always; flags fixed-effect coefficients for GLMMs with unitless links (log,logit,cloglog,probit)check_scales): flags columns of the model matrix where|log10(sd)| > big_sd_log10(default 3, i.e. sd < 1e-3 or > 1e3)check_zstats): flags fixed effects viavcov(fit)and, when available, also flags theta/random-effects parameters using the optimization Hessiancheck_hessian): uses the stored numerical Hessian fromfit@optinfo$derivs$Hessian; identifies which parameters correspond to near-zero eigenvalue directionsEach check prints an explanation (suppressible via
explain = FALSE) and the function returns an invisible logical —TRUEif nothing suspicious was found.Usage
Files changed
R/diagnose.R— new function with full roxygen docsman/diagnose.Rd— Rd documentationtests/testthat/test-diagnose.R— testthat coverage for each check path, including theta/random-effects inclusion in Z-stat diagnostics outputNAMESPACE—export(diagnose)Note: the Hessian check requires
calc.derivs = TRUE(the default for smaller models). ForlmerModthe Hessian covers only theta parameters; forglmerModit covers theta + fixed effects, matching lme4's internal optimization parameterisation.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.