Visualization
Status — Reference
Mirrors drmTMB's Visualization (3 in drmTMB). DRM.jl keeps the base package plotting-dependency-free: these return the data a plot needs — a profile-deviance grid, a correlation summary — so any backend can render them. Drawing is optional via the DRMMakieExt package extension (Makie + AlgebraOfGraphics weakdeps); load a Makie backend and AlgebraOfGraphics to activate drm_figure. Default CI does not draw figures — it only gates the method-less stub.
Plotting data providers
DRM.profile_curve Function
profile_curve(fit, k; npoints = 41, span = 3.0, level = 0.95) -> NamedTuple1-D profile-likelihood curve for coefficient index k, the data needed for a profile diagnostic plot. At each grid value of θ[k], all nuisance parameters are re-optimised, so the returned curve is a likelihood-ratio profile rather than a Wald/quadratic approximation.
Returns (x, deviance, estimate, cutoff, k, param, coef, level):
x— grid values forθ[k], spanningθ̂[k] ± span·se[k]and including the MLE exactly;deviance—2(ℓ̂ - ℓ_profile)at eachxvalue;cutoff— theχ²₁(level)reference line used by profile intervals.
Requires the fitted objective (fit.nll); the model must be fit through drm.
DRM.parameter_surface Function
parameter_surface(fit, k1, k2; npoints = 25, span = 3.0) -> NamedTuple2-D profile-likelihood surface over two coefficients (global indices k1, k2 into coef(fit)), the data behind drmTMB's plot_parameter_surface. At each grid node the remaining parameters are profiled out (re-optimised), so the surface is the genuine profile deviance 2(ℓ̂ − ℓ_profile(θ_{k1}, θ_{k2})), not a quadratic approximation.
Returns (x, y, z, k1, k2):
x,y— the grid coordinate vectors forθ[k1],θ[k2](lengthnpoints), spanningθ̂[k] ± span·se[k].z—npoints × npointsmatrix of profile deviance (z[i,j]atx[i], y[j]);0at the MLE, rising away from it.χ²₂contours give joint confidence regions.
Requires the fitted objective (fit.nll); the model must be fit through drm.
DRM.corpairs_data Function
corpairs_data(fit) -> NamedTupleSummary of the fitted between-response residual correlation for plotting — the data behind drmTMB's plot_corpairs. Returns (rho = …, constant = …):
rho— the per-observationρ12 = tanh(Xρ·β̂_ρ)vector for bivariate models; empty for univariate models (no between-response correlation).constant—truewhenρ12does not vary across observations (rho12 ~ 1), in which case a single numberrho[1]summarises it;falsewhen it varies (rho12 ~ x) and the full vector / a covariate scatter is the right plot.
Drawing layer (optional Makie extension)
DRM.drm_figure Function
drm_figure(data; kind = <inferred>, kwargs...)Draw a DRM plotting-layer figure from a preparer NamedTuple (profile_curve / parameter_surface / corpairs_data). STUB: the drawing method is provided by the DRMMakieExt package extension, which activates only when a Makie backend and AlgebraOfGraphics are loaded (using CairoMakie, AlgebraOfGraphics / using GLMakie, AlgebraOfGraphics). Without them, calling this throws a MethodError asking you to load the plotting weak dependencies.
Supported kinds:
:profile←profile_curve— profile deviance with Florence's Confidence Eye (pale compatibility region where deviance ≤ cutoff, darker outline, hollow point estimate):parameter_surface←parameter_surface— 2-D profile-deviance heatmap / surface:corpairs←corpairs_data— residualρ12summary (constant point or per-observation scatter)
Drawing only — no estimation, no engine computation. Default CI does not load Makie; stub tests assert isempty(methods(drm_figure)) without the weakdeps.
DRM.plot_profile Function
plot_profile(fit, k; npoints = 41, span = 3.0, level = 0.95, kwargs...)Thin drmTMB-named alias: profile_curve then drm_figure (kind = :profile). Requires Makie + AlgebraOfGraphics (via DRMMakieExt).
DRM.plot_parameter_surface Function
plot_parameter_surface(fit, k1, k2; npoints = 25, span = 3.0, kwargs...)Thin drmTMB-named alias: parameter_surface then drm_figure (kind = :parameter_surface). Requires Makie + AlgebraOfGraphics (via DRMMakieExt).
DRM.plot_corpairs Function
plot_corpairs(fit; kwargs...)Thin drmTMB-named alias: corpairs_data then drm_figure (kind = :corpairs). Requires Makie + AlgebraOfGraphics (via DRMMakieExt).
To draw locally (not in default CI):
using CairoMakie, AlgebraOfGraphics # activates DRMMakieExt
pc = profile_curve(fit, 2)
fig = drm_figure(pc; kind = :profile) # Confidence Eye on the profile interval
# or: plot_profile(fit, 2)